Skip to content

Commit

Permalink
build: use pep621 pyproject.toml (#372)
Browse files Browse the repository at this point in the history
[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](renovatebot/renovate#10187)) or dependabot (see [#3290](dependabot/dependabot-core#3290))
  • Loading branch information
tekumara authored Jul 20, 2022
1 parent 31d9172 commit 550b6a3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 54 deletions.
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# needed by setup.py
include README.md
recursive-include src/aec/config-example *.toml *.yaml
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
49 changes: 47 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"]
51 changes: 3 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion src/aec/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.5.3"
__version__ = "2.5.4"

0 comments on commit 550b6a3

Please sign in to comment.