From 62f2bcdab2e9055a9b100307af5a43445a76b4f6 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:51:12 +0200 Subject: [PATCH 1/4] remove `MANIFEST.in` --- MANIFEST.in | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 3261f0dd..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include LICENSE -include CHANGES.rst -include README.rst -graft aiobotocore -global-exclude *.pyc *.swp From 9fbc5dab7c3c658772257a91325f3c09f8b02bd6 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:52:22 +0200 Subject: [PATCH 2/4] remove arguments `include_package_data` and `packages` from call to `setuptools.setup()` --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index cd600536..9ca2d186 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import os import re -from setuptools import find_packages, setup +from setuptools import setup # NOTE: If updating requirements make sure to also check Pipfile for any locks # NOTE: When updating botocore make sure to update awscli/boto3 versions below @@ -62,9 +62,7 @@ def read_version(): url='https://github.com/aio-libs/aiobotocore', download_url='https://pypi.python.org/pypi/aiobotocore', license='Apache License 2.0', - packages=find_packages(include=['aiobotocore']), python_requires='>=3.8', install_requires=install_requires, extras_require=extras_require, - include_package_data=True, ) From 2eecf60d88faf1ac8032dde043330943f69778f6 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:16:58 +0200 Subject: [PATCH 3/4] add PEP 517/518 compatible `[build-system]` table to `pyproject.toml` --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 398309e0..140ea57a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + [tool.pytest.ini_options] asyncio_mode = "auto" cache_dir = "/tmp/pytest_aiobotocore_cache" From 0d06dd290be438bb81be22800ece2b7a62456867 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:06:34 +0200 Subject: [PATCH 4/4] add PEP 621 compatible `[project]` table to `pyproject.toml` --- CONTRIBUTING.rst | 4 +-- pyproject.toml | 49 +++++++++++++++++++++++++++++++ requirements-dev.in | 3 ++ setup.py | 67 +------------------------------------------ tests/test_patches.py | 2 +- tests/test_version.py | 48 ++++++++++++++++++++++++------- 6 files changed, 93 insertions(+), 80 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a79a6723..6e4466ee 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -68,9 +68,9 @@ botocore calls eventually called. The best way I've seen to upgrade botocore support is by performing the following: -1. Download sources of the release of botocore you're trying to upgrade to, and the version of botocore that aiobotocore is currently locked to (see setup.py) and do a folder based file comparison of the botocore folders (tools like DiffMerge are nice). +1. Download sources of the release of botocore you're trying to upgrade to, and the version of botocore that aiobotocore is currently locked to (see pyproject.toml) and do a folder based file comparison of the botocore folders (tools like DiffMerge are nice). 2. Manually apply the relevant changes to their aiobotocore equivalent(s). Note that sometimes new functions are added which will need to be overridden (like `__enter__` -> `__aenter__`) -3. Update the "extras" in setup.py to the versions which match the botocore version you are targeting. +3. Update the "project.optional-dependencies" in pyproject.toml to the versions which match the botocore version you are targeting. 4. Now do a directory diff between aiobotocore and your target version botocore directory to ensure the changes were propagated. See next section describing types of changes we must validate and support. diff --git a/pyproject.toml b/pyproject.toml index 140ea57a..63cefb4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,55 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" +[project] +name = "aiobotocore" +description = "Async client for aws services using botocore and aiohttp" +requires-python = ">=3.8" +authors = [ + { name = "Nikolay Novik", email = "nickolainovik@gmail.com" }, +] +license = { text = "Apache License 2.0" } +classifiers = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Natural Language :: English', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Environment :: Web Environment', + 'Framework :: AsyncIO', +] + +dynamic = ["version", "readme"] + +dependencies = [ + "botocore >=1.34.70, <1.34.163", # NOTE: When updating, always keep `project.optional-dependencies` aligned + "aiohttp >=3.9.2, <4.0.0", + "wrapt >=1.10.10, <2.0.0", + "aioitertools >=0.5.1, <1.0.0", +] + +[project.optional-dependencies] +awscli = [ + "awscli >=1.32.70, <1.33.45", +] +boto3 = [ + "boto3 >=1.34.70, <1.34.163", +] + +[project.urls] +Repository = "https://github.com/aio-libs/aiobotocore" +Documentation = "https://aiobotocore.readthedocs.io" + +[tool.setuptools.dynamic] +version = { attr = "aiobotocore.__version__" } +readme = { file = ["README.rst", "CHANGES.rst"] } + [tool.pytest.ini_options] asyncio_mode = "auto" cache_dir = "/tmp/pytest_aiobotocore_cache" diff --git a/requirements-dev.in b/requirements-dev.in index fccbf490..a5fa8a6c 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -12,6 +12,9 @@ setuptools==67.8.0;python_version>="3.12" # this is needed for test_patches dill~=0.3.3 +# this is needed for test_version +tomli; python_version < "3.11" + # this is needed when running setup.py check -rms Pygments diff --git a/setup.py b/setup.py index 9ca2d186..60684932 100644 --- a/setup.py +++ b/setup.py @@ -1,68 +1,3 @@ -import os -import re - from setuptools import setup -# NOTE: If updating requirements make sure to also check Pipfile for any locks -# NOTE: When updating botocore make sure to update awscli/boto3 versions below -install_requires = [ - # pegged to also match items in `extras_require` - 'botocore>=1.34.70,<1.34.163', - 'aiohttp>=3.9.2,<4.0.0', - 'wrapt>=1.10.10, <2.0.0', - 'aioitertools>=0.5.1,<1.0.0', -] - -extras_require = { - 'awscli': ['awscli>=1.32.70,<1.33.45'], - 'boto3': ['boto3>=1.34.70,<1.34.163'], -} - - -def read(f): - return open(os.path.join(os.path.dirname(__file__), f)).read().strip() - - -def read_version(): - regexp = re.compile(r"^__version__\W*=\W*'([\d.abrc]+)'") - init_py = os.path.join( - os.path.dirname(__file__), 'aiobotocore', '__init__.py' - ) - with open(init_py) as f: - for line in f: - match = regexp.match(line) - if match is not None: - return match.group(1) - raise RuntimeError('Cannot find version in aiobotocore/__init__.py') - - -setup( - name='aiobotocore', - version=read_version(), - description='Async client for aws services using botocore and aiohttp', - long_description='\n\n'.join((read('README.rst'), read('CHANGES.rst'))), - long_description_content_type='text/x-rst', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Natural Language :: English', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Environment :: Web Environment', - 'Framework :: AsyncIO', - ], - author="Nikolay Novik", - author_email="nickolainovik@gmail.com", - url='https://github.com/aio-libs/aiobotocore', - download_url='https://pypi.python.org/pypi/aiobotocore', - license='Apache License 2.0', - python_requires='>=3.8', - install_requires=install_requires, - extras_require=extras_require, -) +setup() diff --git a/tests/test_patches.py b/tests/test_patches.py index f00543bc..280b81a1 100644 --- a/tests/test_patches.py +++ b/tests/test_patches.py @@ -135,7 +135,7 @@ # REPLACE = backwards incompatible change # APPEND = officially supporting more versions of botocore/aiohttp -# If you're changing these, most likely need to update setup.py as well. +# If you're changing these, most likely need to update dependencies in pyproject.toml as well. _API_DIGESTS = { # args.py ClientArgsCreator.get_client_args: { diff --git a/tests/test_version.py b/tests/test_version.py index e45fcdb4..aa3ecce0 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,6 +1,7 @@ import ast import operator import re +import sys from datetime import datetime from itertools import chain from pathlib import Path @@ -19,6 +20,11 @@ import aiobotocore +if sys.version_info >= (3, 11): + import tomllib +else: + import tomli as tomllib + _root_path = Path(__file__).absolute().parent.parent @@ -52,9 +58,7 @@ class VersionInfo(NamedTuple): specifier_set: SpecifierSet -def _get_boto_module_versions( - setup_content: str, ensure_plus_one_patch_range: bool = False -): +def _get_requirements_from_setup_py(setup_content: str): parsed = ast.parse(setup_content) top_level_vars = {"install_requires", "requires", "extras_require"} assignments = dict() @@ -67,13 +71,28 @@ def _get_boto_module_versions( value = ast.literal_eval(node.value) assignments[target_name] = value - module_versions = dict() - - for ver in chain( + return chain( assignments.get("install_requires", []), assignments.get("requires", []), assignments.get("extras_require", {}).values(), - ): + ) + + +def _get_requirements_from_pyproject_toml(pyproject_content: str): + content = tomllib.loads(pyproject_content) + + return chain( + content["project"].get("dependencies", []), + *content["project"].get("optional-dependencies", {}).values(), + ) + + +def _get_boto_module_versions( + requirements, ensure_plus_one_patch_range: bool = False +): + module_versions = dict() + + for ver in requirements: if isinstance(ver, str): ver: InstallRequirement = install_req_from_line(ver) elif isinstance(ver, list): @@ -165,16 +184,21 @@ def test_release_versions(): ), 'Current release must be after last release' # get aioboto reqs - with (_root_path / 'setup.py').open() as f: + with (_root_path / 'pyproject.toml').open() as f: content = f.read() - aioboto_reqs = _get_boto_module_versions(content, False) + aioboto_reqs = _get_boto_module_versions( + _get_requirements_from_pyproject_toml(content), + False, + ) # get awscli reqs awscli_resp = requests.get( f"https://raw.githubusercontent.com/aws/aws-cli/" f"{aioboto_reqs['awscli'].least_version}/setup.py" ) - awscli_reqs = _get_boto_module_versions(awscli_resp.text) + awscli_reqs = _get_boto_module_versions( + _get_requirements_from_setup_py(awscli_resp.text) + ) assert awscli_reqs['botocore'].specifier_set.contains( aioboto_reqs['botocore'].least_version ) @@ -184,7 +208,9 @@ def test_release_versions(): f"https://raw.githubusercontent.com/boto/boto3/" f"{aioboto_reqs['boto3'].least_version}/setup.py" ) - boto3_reqs = _get_boto_module_versions(boto3_resp.text) + boto3_reqs = _get_boto_module_versions( + _get_requirements_from_setup_py(boto3_resp.text) + ) assert boto3_reqs['botocore'].specifier_set.contains( aioboto_reqs['botocore'].least_version )