From d896918536e6f5a303e79908d48bad5408d835e4 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 28 Jun 2022 10:27:43 -0500 Subject: [PATCH] Use GitHub source; run tests --- .gitignore | 1 + generate-source.sh | 21 +++++++++++++++++++ python-azure-loganalytics.spec | 35 +++++++++++++++++++++++++------ remove-custom-wheel-builder.patch | 20 ------------------ sources | 2 +- 5 files changed, 52 insertions(+), 27 deletions(-) create mode 100755 generate-source.sh delete mode 100644 remove-custom-wheel-builder.patch diff --git a/.gitignore b/.gitignore index 5a3fd9d..77a6e43 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /azure-loganalytics-0.1.0.zip +/azure-loganalytics-0.1.0.tgz diff --git a/generate-source.sh b/generate-source.sh new file mode 100755 index 0000000..7bb5daf --- /dev/null +++ b/generate-source.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euxo pipefail + +export VERSION=0.1.0 +export PACKAGE_NAME=azure-loganalytics +WORKING_DIR=$(pwd) + +# Download the release and unpack it. +curl -LO https://github.com/Azure/azure-sdk-for-python/archive/refs/tags/${PACKAGE_NAME}_${VERSION}.tar.gz +tar xzf ${PACKAGE_NAME}_${VERSION}.tar.gz + +# Find the package directory in the SDK release and the parent directory. +PACKAGE_DIR=$(find azure-sdk-for-python-${PACKAGE_NAME}_${VERSION} -type d -name $PACKAGE_NAME) +PARENT_DIR=$(dirname $PACKAGE_DIR) + +# Build a tarball with a prefix directory that contains the package name and +# version. Store that in the directory where the script is running. +pushd $PARENT_DIR + tar --transform "s/^${PACKAGE_NAME}/${PACKAGE_NAME}-${VERSION}/" -cz \ + -f ${WORKING_DIR}/${PACKAGE_NAME}-${VERSION}.tgz $PACKAGE_NAME +popd \ No newline at end of file diff --git a/python-azure-loganalytics.spec b/python-azure-loganalytics.spec index c3785e8..2cedf56 100644 --- a/python-azure-loganalytics.spec +++ b/python-azure-loganalytics.spec @@ -1,3 +1,5 @@ +%bcond_without tests + %global srcname azure-loganalytics Name: python-%{srcname} @@ -6,14 +8,24 @@ Release: %autorelease Summary: Microsoft Azure Log Analytics Client Library for Python License: MIT URL: https://pypi.org/project/%{srcname}/ -Source0: %{pypi_source %{srcname} %{version} zip} -Patch0: remove-custom-wheel-builder.patch +# This source comes from making a git archive of the main azure-sdk-for-python +# repository. To reproduce the source code, run the generate-source.sh script. +Source0: %{srcname}-%{version}.tgz BuildArch: noarch - BuildRequires: python3-devel +%if %{with tests} +BuildRequires: python3dist(azure-devtools) +BuildRequires: python3dist(azure-mgmt-keyvault) +BuildRequires: python3dist(azure-mgmt-resource) +BuildRequires: python3dist(azure-sdk-tools) +BuildRequires: python3dist(msrestazure) +BuildRequires: python3dist(pytest) +BuildRequires: python3dist(pytest-aiohttp) +BuildRequires: python3dist(python-dotenv) +%endif %global _description %{expand: Microsoft Azure Log Analytics Client Library for Python} @@ -23,20 +35,21 @@ Microsoft Azure Log Analytics Client Library for Python} %package -n python3-%{srcname} Summary: %{summary} -Obsoletes: python3-azure-sdk < 5.0.1 + %description -n python3-%{srcname} %{_description} %prep -%autosetup -p0 -n %{srcname}-%{version} +%autosetup -n %{srcname}-%{version} # Remove the customized wheel builder included by Microsoft that adds # azure-nspkg to the requirements. +sed -i '/azure-namespace-package/d' setup.cfg rm -f azure_bdist_wheel.py %generate_buildrequires -%pyproject_buildrequires -r +%pyproject_buildrequires %build @@ -50,6 +63,16 @@ rm -f azure_bdist_wheel.py # files. Remove unneccessary __init__.py that conflicts with other packages. rm -rf %{buildroot}%{python3_sitelib}/azure/{__init__.py,__pycache__} +%pyproject_save_files azure + + +%check +%pyproject_check_import + +%if %{with tests} +%pytest +%endif + %files -n python3-%{srcname} %doc README.rst diff --git a/remove-custom-wheel-builder.patch b/remove-custom-wheel-builder.patch deleted file mode 100644 index 2786fa2..0000000 --- a/remove-custom-wheel-builder.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff -up ./MANIFEST.in.orig ./MANIFEST.in ---- ./MANIFEST.in.orig 2021-07-07 07:57:49.089075245 -0500 -+++ ./MANIFEST.in 2021-07-07 07:57:52.238053234 -0500 -@@ -1,2 +1 @@ - include *.rst --include azure_bdist_wheel.py -\ No newline at end of file -diff -up ./setup.cfg.orig ./setup.cfg ---- ./setup.cfg.orig 2021-07-07 07:57:42.345122388 -0500 -+++ ./setup.cfg 2021-07-07 07:57:55.897027655 -0500 -@@ -1,8 +1,6 @@ - [bdist_wheel] - universal = 1 --azure-namespace-package = azure-nspkg - - [egg_info] --tag_build = -+tag_build = - tag_date = 0 -- diff --git a/sources b/sources index c3c5794..58c8488 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (azure-loganalytics-0.1.0.zip) = f3e902f50e81a585e1660314da59bf29184c8a7f2ce3c06449949e7707631310e3bb12555079ea664fc44596dad53b272f16ac08e78d9069b2fb3f400836c6aa +SHA512 (azure-loganalytics-0.1.0.tgz) = a071104f6be2ceaddbbdba4ec1cb42947be32bccc644571436b9988d5eafba292c0262a09e7120513b00a72020bd5d20036b64389206704f66c6a5440a011b6e