Просмотр исходного кода

Migrate packaging to pyproject.toml (PEP 621)

Replace setup.py/setup.cfg with a PEP 621 pyproject.toml using
setuptools build backend. Version is read dynamically from
cloudbridge.__version__. Coverage config moves into
[tool.coverage.run]; flake8 stays in setup.cfg (no pyproject support).

Drop stale Py2/old-Py3 classifiers and bdist_wheel universal flag;
declare requires-python = ">=3.13" to match tox.ini and CI.

Update deploy workflow to use `python -m build`, and pip-cache keys
in integration workflows to hash pyproject.toml.
Nuwan Goonasekera 1 день назад
Родитель
Сommit
7df4a94ad5
7 измененных файлов с 127 добавлено и 132 удалено
  1. 3 3
      .github/workflows/deploy.yaml
  2. 1 1
      .github/workflows/integration-cloud.yaml
  3. 1 1
      .github/workflows/integration.yaml
  4. 110 0
      pyproject.toml
  5. 0 11
      setup.cfg
  6. 0 114
      setup.py
  7. 12 2
      tox.ini

+ 3 - 3
.github/workflows/deploy.yaml

@@ -23,11 +23,11 @@ jobs:
         python-version: 3.13
     - name: Install dependencies
       run: |
-        python3 -m pip install --upgrade pip setuptools
-        python3 -m pip install --upgrade twine wheel
+        python3 -m pip install --upgrade pip
+        python3 -m pip install --upgrade build twine
     - name: Create and check packages
       run: |
-        python3 setup.py sdist bdist_wheel
+        python3 -m build
         twine check dist/*
         ls -l dist
     - name: Publish distribution 📦 to Test PyPI

+ 1 - 1
.github/workflows/integration-cloud.yaml

@@ -73,7 +73,7 @@ jobs:
         uses: actions/cache@v5
         with:
           path: ~/.cache/pip
-          key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/setup.py', '**/requirements.txt') }}
+          key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements.txt') }}
 
       - name: Install required packages
         run: pip install tox

+ 1 - 1
.github/workflows/integration.yaml

@@ -71,7 +71,7 @@ jobs:
         uses: actions/cache@v5
         with:
           path: ~/.cache/pip
-          key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/setup.py', '**/requirements.txt') }}
+          key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements.txt') }}
 
       - name: Install required packages
         run: pip install tox

+ 110 - 0
pyproject.toml

@@ -0,0 +1,110 @@
+[build-system]
+requires = ["setuptools>=77.0", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "cloudbridge"
+description = "A simple layer of abstraction over multiple cloud providers."
+readme = "README.rst"
+license = "MIT"
+license-files = ["LICENSE"]
+requires-python = ">=3.13"
+authors = [
+    { name = "Galaxy and GVL Projects", email = "help@genome.edu.au" },
+]
+keywords = ["cloud", "aws", "azure", "gcp", "openstack", "iaas"]
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Environment :: Console",
+    "Intended Audience :: Developers",
+    "Intended Audience :: System Administrators",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python",
+    "Programming Language :: Python :: 3",
+    "Programming Language :: Python :: 3.13",
+    "Programming Language :: Python :: Implementation :: CPython",
+    "Topic :: Software Development :: Libraries :: Python Modules",
+]
+dependencies = [
+    "six>=1.11",
+    "tenacity>=6.0",
+    "deprecation>=2.0.7",
+    "pyeventsystem<2",
+]
+dynamic = ["version"]
+
+[project.urls]
+Homepage = "http://cloudbridge.cloudve.org/"
+Source = "https://github.com/CloudVE/cloudbridge"
+Issues = "https://github.com/CloudVE/cloudbridge/issues"
+
+[project.optional-dependencies]
+aws = [
+    "boto3>=1.9.86,<2.0.0",
+]
+# Install azure>=3.0.0 package to find which of the azure libraries listed
+# below are compatible with each other. List individual libraries instead
+# of using the azure umbrella package to speed up installation.
+# Minimums match SDK generation tested against the model-class
+# serialization fixes in cloudbridge/providers/azure/. Older SDKs may
+# work but are not covered by integration tests.
+azure = [
+    "azure-identity>=1.20.0,<2.0.0",
+    "azure-common>=1.1.28,<2.0.0",
+    "azure-core>=1.30.0,<2.0.0",
+    "azure-mgmt-devtestlabs>=9.0.0,<10.0.0",
+    "azure-mgmt-resource>=23.0.0,<26.0.0",
+    "azure-mgmt-subscription>=3.0.0,<4.0.0",
+    "azure-mgmt-compute>=34.0.0,<39.0.0",
+    "azure-mgmt-network>=28.0.0,<31.0.0",
+    "azure-mgmt-storage>=22.0.0,<25.0.0",
+    "azure-storage-blob>=12.20.0,<13.0.0",
+    "azure-data-tables>=12.4.0,<13.0.0",
+    "paramiko<6.0.0",
+]
+gcp = [
+    "google-api-python-client>=2.0,<3.0.0",
+]
+# Minimums match SDK generation tested against the OpenStack
+# provider fixes in cloudbridge/providers/openstack/. The previous
+# floors were circa-2018 and exposed Nova/Neutron APIs (e.g. the
+# add_floating_ip_to_server action) that are gone from any modern
+# OpenStack deployment.
+openstack = [
+    "openstacksdk>=3.0.0,<5.0.0",
+    "python-novaclient>=17.0.0,<20.0",
+    "python-swiftclient>=4.0.0,<5.0",
+    "python-neutronclient>=11.0.0,<13.0",
+    "python-keystoneclient>=4.0.0,<7.0",
+]
+full = [
+    "cloudbridge[aws,azure,gcp,openstack]",
+]
+# httpretty is required with/for moto 1.0.0 or AWS tests fail
+dev = [
+    "cloudbridge[full]",
+    "tox>=4.0.0",
+    "pytest",
+    "moto[ec2,s3]>=5.0.0",
+    "packaging",
+    "sphinx>=1.3.1",
+    "pydevd",
+    "flake8>=3.3.0",
+    "flake8-import-order>=0.12",
+]
+
+[tool.setuptools.dynamic]
+version = { attr = "cloudbridge.__version__" }
+
+[tool.setuptools.packages.find]
+include = ["cloudbridge*"]
+exclude = ["tests*"]
+
+[tool.coverage.run]
+branch = true
+source = ["cloudbridge"]
+omit = [
+    "cloudbridge/interfaces/*",
+    "cloudbridge/__init__.py",
+]
+parallel = true

+ 0 - 11
setup.cfg

@@ -1,14 +1,3 @@
-[coverage:run]
-branch = True
-source = cloudbridge
-omit =
-  cloudbridge/interfaces/*
-  cloudbridge/__init__.py
-parallel = True
-
-[bdist_wheel]
-universal = 1
-
 [flake8]
 application_import_names = cloudbridge, tests
 max-line-length = 120

+ 0 - 114
setup.py

@@ -1,114 +0,0 @@
-"""
-CloudBridge provides a uniform interface to multiple IaaS cloud providers.
-"""
-
-import ast
-import os
-import re
-
-from setuptools import find_packages, setup
-
-# Cannot use "from cloudbridge import get_version" because that would try to
-# import the six package which may not be installed yet.
-reg = re.compile(r'__version__\s*=\s*(.+)')
-with open(os.path.join('cloudbridge', '__init__.py')) as f:
-    for line in f:
-        m = reg.match(line)
-        if m:
-            version = ast.literal_eval(m.group(1))
-            break
-
-REQS_BASE = [
-    'six>=1.11',
-    'tenacity>=6.0',
-    'deprecation>=2.0.7',
-    'pyeventsystem<2'
-]
-REQS_AWS = [
-    'boto3>=1.9.86,<2.0.0'
-]
-# Install azure>=3.0.0 package to find which of the azure libraries listed
-# below are compatible with each other. List individual libraries instead
-# of using the azure umbrella package to speed up installation.
-REQS_AZURE = [
-    # Minimums match SDK generation tested against the model-class
-    # serialization fixes in cloudbridge/providers/azure/. Older SDKs may
-    # work but are not covered by integration tests.
-    'azure-identity>=1.20.0,<2.0.0',
-    'azure-common>=1.1.28,<2.0.0',
-    'azure-core>=1.30.0,<2.0.0',
-    'azure-mgmt-devtestlabs>=9.0.0,<10.0.0',
-    'azure-mgmt-resource>=23.0.0,<26.0.0',
-    'azure-mgmt-subscription>=3.0.0,<4.0.0',
-    'azure-mgmt-compute>=34.0.0,<39.0.0',
-    'azure-mgmt-network>=28.0.0,<31.0.0',
-    'azure-mgmt-storage>=22.0.0,<25.0.0',
-    'azure-storage-blob>=12.20.0,<13.0.0',
-    'azure-data-tables>=12.4.0,<13.0.0',
-    'paramiko<6.0.0'
-]
-REQS_GCP = [
-    'google-api-python-client>=2.0,<3.0.0'
-]
-REQS_OPENSTACK = [
-    # Minimums match SDK generation tested against the OpenStack
-    # provider fixes in cloudbridge/providers/openstack/. The previous
-    # floors were circa-2018 and exposed Nova/Neutron APIs (e.g. the
-    # add_floating_ip_to_server action) that are gone from any modern
-    # OpenStack deployment.
-    'openstacksdk>=3.0.0,<5.0.0',
-    'python-novaclient>=17.0.0,<20.0',
-    'python-swiftclient>=4.0.0,<5.0',
-    'python-neutronclient>=11.0.0,<13.0',
-    'python-keystoneclient>=4.0.0,<7.0'
-]
-REQS_FULL = REQS_AWS + REQS_GCP + REQS_OPENSTACK + REQS_AZURE
-# httpretty is required with/for moto 1.0.0 or AWS tests fail
-REQS_DEV = ([
-    'tox>=4.0.0',
-    'pytest',
-    'moto[ec2,s3]>=5.0.0',
-    'packaging',
-    'sphinx>=1.3.1',
-    'pydevd',
-    'flake8>=3.3.0',
-    'flake8-import-order>=0.12'] + REQS_FULL
-)
-
-setup(
-    name='cloudbridge',
-    version=version,
-    description='A simple layer of abstraction over multiple cloud providers.',
-    long_description=__doc__,
-    author='Galaxy and GVL Projects',
-    author_email='help@genome.edu.au',
-    url='http://cloudbridge.cloudve.org/',
-    install_requires=REQS_BASE,
-    extras_require={
-        ':python_version<"3.3"': ['ipaddress'],
-        'azure': REQS_AZURE,
-        'gcp': REQS_GCP,
-        'aws': REQS_AWS,
-        'openstack': REQS_OPENSTACK,
-        'full': REQS_FULL,
-        'dev': REQS_DEV
-    },
-    packages=find_packages(),
-    license='MIT',
-    classifiers=[
-        'Development Status :: 5 - Production/Stable',
-        'Environment :: Console',
-        'Intended Audience :: Developers',
-        'Intended Audience :: System Administrators',
-        'License :: OSI Approved :: MIT License',
-        'Operating System :: OS Independent',
-        'Programming Language :: Python',
-        'Topic :: Software Development :: Libraries :: Python Modules',
-        'Programming Language :: Python :: 2.7',
-        'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.4',
-        'Programming Language :: Python :: 3.5',
-        'Programming Language :: Python :: 3.6',
-        'Programming Language :: Python :: Implementation :: CPython'],
-    test_suite="tests"
-)

+ 12 - 2
tox.ini

@@ -9,7 +9,7 @@
 envlist = {py3.13,pypy}-{aws,azure,gcp,openstack,mock},lint
 
 [testenv]
-commands = # see setup.cfg for options sent to pytest and coverage
+commands = # see pyproject.toml for coverage options; setup.cfg for flake8
            coverage run --source=cloudbridge -m pytest -v {posargs:-n 5 tests/}
            # Combine parallel-mode data files and emit Cobertura XML for upload
            # by coverallsapp/github-action in CI. Locally this produces
@@ -31,6 +31,16 @@ passenv =
     aws: CB_IMAGE_AWS
     aws: CB_VM_TYPE_AWS
     aws: CB_PLACEMENT_AWS
+    # Standard boto3 credential env vars — set by aws-actions/configure-aws-credentials
+    # in CI (OIDC) and by `aws configure` locally. Required because tox does not
+    # forward arbitrary env vars to the test process.
+    aws: AWS_ACCESS_KEY_ID
+    aws: AWS_SECRET_ACCESS_KEY
+    aws: AWS_SESSION_TOKEN
+    aws: AWS_REGION
+    aws: AWS_DEFAULT_REGION
+    # Cloudbridge-specific names, kept for backward compatibility with local dev
+    # configs that set these.
     aws: AWS_ACCESS_KEY
     aws: AWS_SECRET_KEY
     azure: CB_IMAGE_AZURE
@@ -77,5 +87,5 @@ deps =
     pytest-xdist
 
 [testenv:lint]
-commands = flake8 cloudbridge tests setup.py
+commands = flake8 cloudbridge tests
 deps = flake8