Skip to content

Commit 1edaa51

Browse files
authored
Move to pyproject.toml (#58)
The ``setup.py`` is becoming obsolete, so we modernize to ``pyproject.toml``, which is the newer format for setup configuration.
1 parent e6a5f78 commit 1edaa51

File tree

5 files changed

+93
-189
lines changed

5 files changed

+93
-189
lines changed

check_init_and_setup_coincide.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

check_version_consistent.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Check that the version in ``pyproject.toml`` and ``__init__.py`` coincide."""
2+
3+
import importlib.metadata
4+
import sys
5+
6+
import abnf_to_regexp
7+
8+
9+
def main() -> None:
10+
"""Execute the main routine."""
11+
init_version = abnf_to_regexp.__version__
12+
13+
pyproject_toml_version = importlib.metadata.version("abnf-to-regexp")
14+
15+
if init_version != pyproject_toml_version:
16+
print(
17+
f"The version in {abnf_to_regexp.__file__} is: {init_version!r}, "
18+
f"but the version in pyproject.toml is: {pyproject_toml_version!r}",
19+
file=sys.stderr,
20+
)
21+
sys.exit(1)
22+
23+
24+
if __name__ == "__main__":
25+
main()

precommit.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Step(enum.Enum):
1414
PYLINT = "pylint"
1515
TEST = "test"
1616
DOCTEST = "doctest"
17-
CHECK_INIT_AND_SETUP_COINCIDE = "check-init-and-setup-coincide"
17+
CHECK_VERSION_CONSISTENT = "check-version-consistent"
1818
CHECK_HELP_IN_README = "check-help-in-readme"
1919

2020

@@ -72,8 +72,7 @@ def main() -> int:
7272
black_targets = [
7373
"abnf_to_regexp",
7474
"precommit.py",
75-
"setup.py",
76-
"check_init_and_setup_coincide.py",
75+
"check_version_consistent.py",
7776
"check_help_in_readme.py",
7877
"dev_scripts"
7978
]
@@ -160,14 +159,18 @@ def main() -> int:
160159
print("Skipped doctesting.")
161160

162161
if (
163-
Step.CHECK_INIT_AND_SETUP_COINCIDE in selects
164-
and Step.CHECK_INIT_AND_SETUP_COINCIDE not in skips
162+
Step.CHECK_VERSION_CONSISTENT in selects
163+
and Step.CHECK_VERSION_CONSISTENT not in skips
165164
):
166-
print("Checking that abnf_to_regexp/__init__.py and setup.py coincide...")
167-
subprocess.check_call([sys.executable, "check_init_and_setup_coincide.py"])
165+
print(
166+
"Checking that the version is consistent between "
167+
"abnf_to_regexp/__init__.py and pyproject.toml ..."
168+
)
169+
subprocess.check_call([sys.executable, "check_version_consistent.py"])
168170
else:
169171
print(
170-
"Skipped checking that abnf_to_regexp/__init__.py and " "setup.py coincide."
172+
"Skipped checking that the versions in abnf_to_regexp/__init__.py "
173+
"and pyproject.toml coincide."
171174
)
172175

173176
if Step.CHECK_HELP_IN_README in selects and Step.CHECK_HELP_IN_README not in skips:

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "abnf-to-regexp"
7+
version = "1.1.3"
8+
description = "Convert ABNF grammars to Python regular expressions."
9+
readme = "README.rst"
10+
license = {text = "MIT"}
11+
authors = [
12+
{name = "Marko Ristin", email = "[email protected]"}
13+
]
14+
keywords = ["abnf", "backus-naur", "convert", "regular", "expressions"]
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"License :: OSI Approved :: MIT License",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
]
24+
requires-python = ">=3.9"
25+
dependencies = [
26+
"icontract>=2.5.1,<3",
27+
"regex==2021.4.4",
28+
"abnf>=2.0,<2.3.0",
29+
"sortedcontainers>=2,<3",
30+
]
31+
32+
[project.optional-dependencies]
33+
dev = [
34+
"black==24.3.0",
35+
"mypy==1.18.2",
36+
"pylint==3.3.9; python_version>='3.9' and python_version<'3.12'",
37+
"pylint==4.0.2; python_version>='3.12'",
38+
"pydocstyle>=2.1.1,<3",
39+
"coverage>=7,<8",
40+
"docutils>=0.14,<1",
41+
"pygments>=2,<3",
42+
]
43+
44+
[project.scripts]
45+
abnf-to-regexp = "abnf_to_regexp.main:main"
46+
47+
[project.urls]
48+
Homepage = "https://github.com/aas-core-works/abnf-to-regexp"
49+
50+
[tool.setuptools]
51+
packages = ["abnf_to_regexp"]
52+
53+
[tool.setuptools.package-data]
54+
abnf_to_regexp = ["py.typed"]
55+
56+
[tool.setuptools.exclude-package-data]
57+
"*" = ["tests*"]

setup.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)