From 550b6a35ba520d81adb6c499aa9c4b42a3a4dcca Mon Sep 17 00:00:00 2001 From: Oliver Mannion <125105+tekumara@users.noreply.github.com> Date: Thu, 21 Jul 2022 09:59:28 +1000 Subject: [PATCH] build: use pep621 pyproject.toml (#372) [PEP 621](https://peps.python.org/pep-0621) provides a standardised way for storing project metadata including dependencies declaratively in pyproject.toml, instead of setup.py which is very dynamic. PEP 621 is now [supported by setuptools](https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html). This PR uses project settings in pyproject.toml to configure setuptools to build the sdist and wheel. The built distribution is the same, except the PKG-INFO now includes classifies, keywords, and the full text of the license. NB: pyproject.toml dependencies are not yet supported by renovatebot (see [#10187](https://github.com/renovatebot/renovate/issues/10187)) or dependabot (see [#3290](https://github.com/dependabot/dependabot-core/issues/3290)) --- MANIFEST.in | 2 -- Makefile | 2 +- pyproject.toml | 49 +++++++++++++++++++++++++++++++++++++++++-- setup.py | 51 +++------------------------------------------ src/aec/__init__.py | 2 +- 5 files changed, 52 insertions(+), 54 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 913c0176..2137523a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1 @@ -# needed by setup.py -include README.md recursive-include src/aec/config-example *.toml *.yaml diff --git a/Makefile b/Makefile index 788e85cb..779cce8c 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ $(pip): $(venv)/bin/python --version $(pip) install pip~=22.1 -$(venv): setup.py $(pip) +$(venv): pyproject.toml $(pip) $(pip) install -e '.[dev]' touch $(venv) diff --git a/pyproject.toml b/pyproject.toml index e1e630cb..c33b28cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,53 @@ -# use PyCharm default line length of 120 +[project] +name = "aec-cli" +description = "AWS EC2 CLI" +dynamic = ["version"] +readme = "README.md" +license = { file = "LICENSE" } +keywords = ["AWS", "EC2", "command line", "cli"] +classifiers = ["License :: OSI Approved :: MIT License"] +requires-python = ">=3.6" +dependencies = [ + "boto3==1.24.1", + "importlib_resources==5.7.1", + "pytoml==0.1.21", + "pytz==2022.1", + "rich==12.4.4", + "typing_extensions==4.2.0", +] + +[project.optional-dependencies] +dev = [ + "black==22.3.0", + "build~=0.7", + "boto3-stubs[ec2,compute-optimizer,ssm,s3]==1.21.27", + "cogapp~=3.3", + "darglint==1.8.1", + "isort==5.10.1", + "flake8==4.0.1", + "flake8-annotations~=2.9", + "flake8-colors==0.1.9", + "moto[ec2]==3.1.11", + "pre-commit~=2.19", + "pyfakefs==4.5.6", + "pytest~=7.1", + "pytest-mock==3.7.0", + "twine~=4.0", +] + +[project.scripts] +aec = "aec.main:main" + +[project.urls] +homepage = "https://github.com/seek-oss/aec" [build-system] requires = ["setuptools", "wheel"] +[tool.setuptools.dynamic] +version = { attr = "aec.__version__" } + +# use PyCharm default line length of 120 [tool.black] line-length = 120 @@ -11,4 +56,4 @@ line-length = 120 line_length = 120 multi_line_output = 3 include_trailing_comma = true -skip = [ ".tox", "dist", "node_modules" , ".venv", "build", ".git", "typings"] +skip = [".tox", "dist", "node_modules", ".venv", "build", ".git", "typings"] diff --git a/setup.py b/setup.py index a076ef4d..2eedd08f 100644 --- a/setup.py +++ b/setup.py @@ -1,49 +1,4 @@ -from pathlib import Path +# minimal setup.py so pip install -e works +from setuptools import setup -from setuptools import find_packages, setup - -import src.aec as aec - -long_description = Path("README.md").read_text() - -setup( - name="aec-cli", - version=aec.__version__, - description="AWS EC2 CLI", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/seek-oss/aec", - license="MIT", - entry_points={"console_scripts": ["aec = aec.main:main"]}, - python_requires=">=3.6", - packages=find_packages(where="src"), - package_dir={"": "src"}, - include_package_data=True, - install_requires=[ - "boto3==1.24.1", - "importlib_resources==5.7.1", - "pytoml==0.1.21", - "pytz==2022.1", - "rich==12.4.4", - "typing_extensions==4.2.0", - ], - extras_require={ - "dev": [ - "black==22.3.0", - "build~=0.7", - "boto3-stubs[ec2,compute-optimizer,ssm,s3]==1.21.27", - "cogapp~=3.3", - "darglint==1.8.1", - "isort==5.10.1", - "flake8==4.0.1", - "flake8-annotations~=2.9", - "flake8-colors==0.1.9", - "moto[ec2]==3.1.11", - "pre-commit~=2.19", - "pyfakefs==4.5.6", - "pytest~=7.1", - "pytest-mock==3.7.0", - "twine~=4.0", - ] - }, -) +setup() diff --git a/src/aec/__init__.py b/src/aec/__init__.py index 43b48b6f..f4a337e1 100644 --- a/src/aec/__init__.py +++ b/src/aec/__init__.py @@ -1 +1 @@ -__version__ = "2.5.3" +__version__ = "2.5.4"