From 085fb9f73e7fe761e9deb41ef2b1659664813f97 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 28 Jun 2022 12:39:43 -0500 Subject: [PATCH] Check imports using GitHub source code --- .gitignore | 1 + generate-source.sh | 21 +++++++++++++++++++++ python-azure-mgmt-batchai.spec | 30 ++++++++++++++++++++++++++---- sources | 2 +- 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100755 generate-source.sh diff --git a/.gitignore b/.gitignore index 0579211..dfc6975 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /azure-mgmt-batchai-2.0.0.zip /azure-mgmt-batchai-7.0.0b1.zip +/azure-mgmt-batchai-7.0.0b1.tgz diff --git a/generate-source.sh b/generate-source.sh new file mode 100755 index 0000000..57b3ba6 --- /dev/null +++ b/generate-source.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euxo pipefail + +export VERSION=7.0.0b1 +export PACKAGE_NAME=azure-mgmt-batchai +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-mgmt-batchai.spec b/python-azure-mgmt-batchai.spec index a5e70dd..a042cc5 100644 --- a/python-azure-mgmt-batchai.spec +++ b/python-azure-mgmt-batchai.spec @@ -1,3 +1,6 @@ +# No tests available from upstream yet. +%bcond_with tests + %global srcname azure-mgmt-batchai Name: python-%{srcname} @@ -6,7 +9,9 @@ Release: %autorelease Summary: Microsoft Azure Batch AI Management Client Library for Python License: MIT URL: https://pypi.org/project/%{srcname}/ -Source0: %{pypi_source %{srcname} %{version} zip} +# 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 @@ -14,6 +19,15 @@ Epoch: 1 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(pytest) +BuildRequires: python3dist(pytest-aiohttp) +BuildRequires: python3dist(python-dotenv) +%endif %global _description %{expand: Microsoft Azure Batch AI Management Client Library for Python} @@ -23,16 +37,16 @@ Microsoft Azure Batch AI Management 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} %generate_buildrequires -%pyproject_buildrequires -r +%pyproject_buildrequires %build @@ -44,6 +58,14 @@ Obsoletes: python3-azure-sdk < 5.0.1 %pyproject_save_files azure +%check +%pyproject_check_import + +%if %{with tests} +%pytest +%endif + + %files -n python3-%{srcname} -f %{pyproject_files} %doc README.md CHANGELOG.md diff --git a/sources b/sources index 9acb8d9..72cccc9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (azure-mgmt-batchai-7.0.0b1.zip) = c81be868cb87ff9d2acc82b83581844586a31ecbb8b4a3a8e2025cfcc658009030dd97ce873b6b2d0d2ab175ac4ba21ed4c1906f08f047c8c84fc4081e26be2b +SHA512 (azure-mgmt-batchai-7.0.0b1.tgz) = 0893276a24dba766a031e68a7b617d0f21c954c6238ac5d5b422376772261c659cde35f68d032020a84c3cb621565c1b71f89eec2e8fd5dd6921d0ea7bc3f6c0