diff --git a/.gitignore b/.gitignore index 050570e..80a8fd1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /azure-mgmt-consumption-8.0.0.zip /azure-mgmt-consumption-2.0.0.zip +/azure-mgmt-consumption-2.0.0.tgz diff --git a/generate-source.sh b/generate-source.sh new file mode 100755 index 0000000..9ed2597 --- /dev/null +++ b/generate-source.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euxo pipefail + +export VERSION=2.0.0 +export PACKAGE_NAME=azure-mgmt-consumption +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-consumption-remove-nspkg.patch b/python-azure-consumption-remove-nspkg.patch deleted file mode 100644 index eb731c1..0000000 --- a/python-azure-consumption-remove-nspkg.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff -up ./setup.cfg.orig ./setup.cfg ---- ./setup.cfg.orig 2021-07-22 16:37:20.836524174 -0500 -+++ ./setup.cfg 2021-07-22 16:37:28.147481481 -0500 -@@ -1,6 +1,5 @@ - [bdist_wheel] - universal = 1 --azure-namespace-package = azure-mgmt-nspkg - - [egg_info] - tag_build = diff --git a/python-azure-mgmt-consumption.spec b/python-azure-mgmt-consumption.spec index efd3189..9ad446b 100644 --- a/python-azure-mgmt-consumption.spec +++ b/python-azure-mgmt-consumption.spec @@ -1,22 +1,37 @@ +# EPEL9 does not have python-aiohttp packaged yet. +%if 0%{?fedora} +%bcond_without tests +%else +%bcond_with tests +%endif + %global srcname azure-mgmt-consumption Name: python-%{srcname} Version: 2.0.0 -Release: 4%{?dist} +Release: %autorelease Summary: Microsoft Azure Consumption Client Library for Python License: MIT URL: https://pypi.org/project/%{srcname}/ -Source0: %{pypi_source %{srcname} %{version} zip} -Patch0: python-azure-consumption-remove-nspkg.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 Epoch: 1 BuildArch: noarch - BuildRequires: python3-devel -BuildRequires: pyproject-rpm-macros +%if %{with tests} +BuildRequires: python3dist(azure-devtools) +BuildRequires: python3dist(azure-mgmt-keyvault) +BuildRequires: python3dist(azure-mgmt-resource) +BuildRequires: python3dist(azure-sdk-tools) +BuildRequires: python3dist(pytest) +BuildRequires: python3dist(pytest-aiohttp) +BuildRequires: python3dist(python-dotenv) +%endif %global _description %{expand: Microsoft Azure Consumption Client Library for Python} @@ -26,7 +41,7 @@ Microsoft Azure Consumption Client Library for Python} %package -n python3-%{srcname} Summary: %{summary} -Obsoletes: python3-azure-sdk < 5.0.1 + %description -n python3-%{srcname} %{_description} @@ -34,11 +49,12 @@ Obsoletes: python3-azure-sdk < 5.0.1 %autosetup -p0 -n %{srcname}-%{version} # Remove the custom wheel builder. +sed -i '/azure-namespace-package/d' setup.cfg rm -fv azure_bdist_wheel.py %generate_buildrequires -%pyproject_buildrequires -r +%pyproject_buildrequires %build @@ -53,6 +69,16 @@ rm -fv azure_bdist_wheel.py rm -rf %{buildroot}%{python3_sitelib}/azure/{__init__.py,__pycache__} rm -rf %{buildroot}%{python3_sitelib}/azure/mgmt/{__init__.py,__pycache__} +%pyproject_save_files azure + + +%check +%pyproject_check_import + +%if %{with tests} +%pytest +%endif + %files -n python3-%{srcname} %doc README.rst HISTORY.rst @@ -61,17 +87,4 @@ rm -rf %{buildroot}%{python3_sitelib}/azure/mgmt/{__init__.py,__pycache__} %changelog -* Wed Sep 08 2021 Major Hayden - 1:2.0.0-4 -- Move obsoletes into subpackage - -* Mon Jul 26 2021 Major Hayden - 1:2.0.0-3 -- Remove conflicting namespace package files - -* Fri Jul 23 2021 Major Hayden - 1:2.0.0-2 -- Add epoch number for 2.0.0 downgrade - -* Thu Jul 22 2021 Major Hayden - 2.0.0-1 -- Downgrade to 2.0.0 - -* Tue Jun 01 2021 Major Hayden - 8.0.0-1 -- First package. +%autochangelog diff --git a/sources b/sources index 49897eb..96fdd68 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (azure-mgmt-consumption-2.0.0.zip) = 57879641214bfb5faa347d23be6e8149cf676e487bc18b2d588abaa4f7d27b6b93d74d098e8ce45aa451de97a01c102b1a56dbd83c8fb21641d6cb9868bc5427 +SHA512 (azure-mgmt-consumption-2.0.0.tgz) = dbf0350e76ca60e42fe5fa970b4ac691db7f44921e46f7d69962490db737c823e9044c657bb77082f6e35eb7f887ab03be418eadfa09de4fae851fab8ced4342