Skip to content

Commit 38ac457

Browse files
authored
chore: use pyproject.toml instead of setup.py/setup.cfg (#559)
1 parent a8e065e commit 38ac457

File tree

6 files changed

+100
-102
lines changed

6 files changed

+100
-102
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python-version: 3.9
3535
architecture: x64
3636
- name: Run tests
37-
run: pipx run nox -s test-dist -- 3.9
37+
run: pipx run nox -s test-sdist-3.9 test-wheel-3.9
3838

3939
test:
4040
name: CPython ${{ matrix.python }} ${{ matrix.platform[0] }} on ${{ matrix.platform[1] }}

noxfile.py

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["nox>=2025.2.9"]
3+
# ///
4+
15
from __future__ import annotations
26

37
import os
@@ -6,11 +10,14 @@
610

711
import nox
812

9-
nox.options.sessions = ["lint", "test-dist"]
13+
nox.needs_version = ">=2025.2.9"
1014

1115
PYTHON_ALL_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
1216
RUNNING_CI = "TRAVIS" in os.environ or "GITHUB_ACTIONS" in os.environ
1317

18+
wheel = ""
19+
sdist = ""
20+
1421

1522
@nox.session(python=["3.9"], reuse_venv=True)
1623
def lint(session: nox.Session) -> None:
@@ -21,12 +28,14 @@ def lint(session: nox.Session) -> None:
2128
session.run("pre-commit", "run", "--all-files")
2229

2330

24-
@nox.session()
31+
@nox.session(default=False)
2532
def coverage(session: nox.Session) -> None:
2633
"""
2734
Run coverage using unit tests.
2835
"""
29-
session.install(".[coverage]")
36+
pyproject = nox.project.load_toml("pyproject.toml")
37+
deps = nox.project.dependency_groups(pyproject, "coverage")
38+
session.install("-e", ".", *deps)
3039
session.run(
3140
"python",
3241
"-m",
@@ -55,14 +64,16 @@ def _docker_images(session: nox.Session) -> list[str]:
5564
return images_file.read_text().splitlines()
5665

5766

58-
@nox.session(python=PYTHON_ALL_VERSIONS)
67+
@nox.session(python=PYTHON_ALL_VERSIONS, default=False)
5968
def tests(session: nox.Session) -> None:
6069
"""
6170
Run tests.
6271
"""
6372
posargs = session.posargs
64-
extras = "coverage" if RUNNING_CI else "test"
65-
session.install("-e", f".[{extras}]")
73+
dep_group = "coverage" if RUNNING_CI else "test"
74+
pyproject = nox.project.load_toml("pyproject.toml")
75+
deps = nox.project.dependency_groups(pyproject, dep_group)
76+
session.install("-e", ".", *deps)
6677
if RUNNING_CI:
6778
posargs.extend(["--cov", "auditwheel", "--cov-branch"])
6879
# pull manylinux images that will be used.
@@ -76,62 +87,53 @@ def tests(session: nox.Session) -> None:
7687
session.run("coverage", "xml", "-ocoverage.xml")
7788

7889

79-
def _build(session: nox.Session, dist: Path) -> None:
90+
@nox.session(python=["3.9"], default=False)
91+
def build(session: nox.Session) -> None:
8092
session.install("build")
8193
tmp_dir = Path(session.create_tmp()) / "build-output"
8294
session.run("python", "-m", "build", "--outdir", str(tmp_dir))
8395
(wheel_path,) = tmp_dir.glob("*.whl")
8496
(sdist_path,) = tmp_dir.glob("*.tar.gz")
85-
dist.mkdir(exist_ok=True)
86-
wheel_path.rename(dist / wheel_path.name)
87-
sdist_path.rename(dist / sdist_path.name)
97+
Path("dist").mkdir(exist_ok=True)
98+
wheel_path.rename(f"dist/{wheel_path.name}")
99+
sdist_path.rename(f"dist/{sdist_path.name}")
88100

89-
90-
@nox.session(name="test-dist")
91-
def test_dist(session: nox.Session) -> None:
92-
"""
93-
Builds SDist & Wheels then run unit tests on those.
94-
"""
95-
tmp_dir = Path(session.create_tmp())
96-
dist = tmp_dir / "dist"
97-
_build(session, dist)
98-
python_versions = session.posargs or PYTHON_ALL_VERSIONS
99-
for version in python_versions:
100-
session.notify(f"_test_sdist-{version}", [str(dist)])
101-
session.notify(f"_test_wheel-{version}", [str(dist)])
101+
global sdist # noqa: PLW0603
102+
sdist = f"dist/{sdist_path.name}"
103+
global wheel # noqa: PLW0603
104+
wheel = f"dist/{wheel_path.name}"
102105

103106

104-
def _test_dist(session: nox.Session, path: str, pattern: str) -> None:
105-
(dist_path,) = Path(path).glob(pattern)
106-
session.install(f"{dist_path!s}[test]")
107+
def _test_dist(session: nox.Session, path: str) -> None:
108+
pyproject = nox.project.load_toml("pyproject.toml")
109+
deps = nox.project.dependency_groups(pyproject, "test")
110+
session.install(path, *deps)
107111
session.run("pytest", "tests/unit")
108112

109113

110-
@nox.session(python=PYTHON_ALL_VERSIONS)
111-
def _test_sdist(session: nox.Session) -> None:
114+
@nox.session(name="test-sdist", python=PYTHON_ALL_VERSIONS, requires=["build"])
115+
def test_sdist(session: nox.Session) -> None:
112116
"""
113117
Do not run explicitly.
114118
"""
115-
_test_dist(session, session.posargs[0], "*.tar.gz")
119+
_test_dist(session, sdist)
116120

117121

118-
@nox.session(python=PYTHON_ALL_VERSIONS)
119-
def _test_wheel(session: nox.Session) -> None:
122+
@nox.session(name="test-wheel", python=PYTHON_ALL_VERSIONS, requires=["build"])
123+
def test_wheel(session: nox.Session) -> None:
120124
"""
121125
Do not run explicitly.
122126
"""
123-
_test_dist(session, session.posargs[0], "*.whl")
127+
_test_dist(session, wheel)
124128

125129

126-
@nox.session
127-
def build(session: nox.Session) -> None:
128-
"""
129-
Make an SDist and a wheel.
130-
"""
131-
_build(session, Path("dist"))
130+
@nox.session(python=PYTHON_ALL_VERSIONS, reuse_venv=True, default=False)
131+
def develop(session: nox.Session) -> None:
132+
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
133+
pyproject = nox.project.load_toml("pyproject.toml")
134+
deps = nox.project.dependency_groups(pyproject, "dev")
135+
session.install("-e", ".", *deps)
132136

133137

134-
@nox.session(python=PYTHON_ALL_VERSIONS, reuse_venv=True)
135-
def develop(session: nox.Session) -> None:
136-
session.run("python", "-m", "pip", "install", "--upgrade", "pip", "setuptools")
137-
session.install("-e", ".[develop]")
138+
if __name__ == "__main__":
139+
nox.main()

pyproject.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,60 @@
22
requires = ["setuptools>=61", "setuptools_scm>=8"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "auditwheel"
7+
dynamic = ["version"]
8+
description = "Cross-distribution Linux wheels"
9+
readme = "README.rst"
10+
license = {text = "MIT" }
11+
requires-python = ">=3.9"
12+
authors = [
13+
{ name = "Robert T. McGibbon", email = "[email protected]" },
14+
]
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Environment :: Console",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: MIT License",
20+
"Operating System :: POSIX :: Linux",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3 :: Only",
28+
"Topic :: Software Development",
29+
"Topic :: Software Development :: Build Tools",
30+
"Topic :: Software Development :: Libraries :: Python Modules",
31+
]
32+
dependencies = [
33+
"packaging>=20.9",
34+
"pyelftools>=0.24",
35+
]
36+
37+
[project.scripts]
38+
auditwheel = "auditwheel.main:main"
39+
40+
[project.urls]
41+
Homepage = "https://github.com/pypa/auditwheel"
42+
43+
[dependency-groups]
44+
test = ["pytest>=3.4", "jsonschema", "patchelf", "pretend", "docker"]
45+
coverage = ["pytest-cov", {include-group = "test"}]
46+
dev = [{include-group = "test"}, {include-group = "coverage"}]
47+
48+
[tool.setuptools]
49+
include-package-data = true
50+
zip-safe = false
51+
52+
[tool.setuptools.packages.find]
53+
where = ["src"]
54+
namespaces = false
55+
56+
[tool.setuptools.package-data]
57+
auditwheel = ["*.json"]
58+
559
[tool.setuptools_scm]
660
# enable version inference
761

setup.cfg

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

setup.py

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

tests/integration/test_manylinux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def exec(self, cmd: str | list[str], expected_retcode: int = 0) -> str:
255255
def find_src_folder() -> Path | None:
256256
candidate = HERE.parent.parent.resolve(strict=True)
257257
contents = os.listdir(candidate)
258-
if "setup.py" in contents and "src" in contents:
258+
if "pyproject.toml" in contents and "src" in contents:
259259
return candidate
260260
return None
261261

0 commit comments

Comments
 (0)