Skip to content

Commit 7189db4

Browse files
authored
psfgh-115: Migrate to the pyproject.toml (psf#149)
1 parent d373c5e commit 7189db4

File tree

6 files changed

+74
-80
lines changed

6 files changed

+74
-80
lines changed

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
python-version: '3.x'
1717
- name: Install dependencies
1818
run: |
19-
python -m pip install --user --upgrade setuptools wheel
19+
python -m pip install --user --upgrade build
2020
- name: Build
2121
run: |
22-
python setup.py sdist bdist_wheel
22+
python -m build
2323
2424
- name: Publish distribution 📦 to PyPI
2525
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'

pyperf/tests/test_misc.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ def test_parse_run_list(self):
6767
self.assertRaises(ValueError, parse_run_list, '1,')
6868

6969
def test_setup_version(self):
70-
import setup
71-
self.assertEqual(pyperf.__version__, setup.VERSION)
70+
try:
71+
from importlib.metadata import version
72+
except ModuleNotFoundError:
73+
# Workaround for Python 3.7
74+
from importlib_metadata import version
75+
76+
self.assertEqual(pyperf.__version__, version("pyperf"))
7277

7378
def test_doc_version(self):
7479
doc_path = os.path.join(os.path.dirname(__file__), '..', '..', 'doc')

pyproject.toml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Prepare a release:
2+
#
3+
# - git pull --rebase
4+
# - update version in pyperf/__init__.py and doc/conf.py
5+
# - set release date in doc/changelog.rst
6+
# - git commit -a -m "prepare release x.y"
7+
# - Remove untracked files/dirs: git clean -fdx
8+
# - run tests: tox --parallel auto
9+
# - git push or send the PR to the repository
10+
# - check Github Action CI: https://github.com/psf/pyperf/actions/workflows/build.yml
11+
#
12+
# Release a new version:
13+
#
14+
# - go to the GitHub release tab: https://github.com/psf/pyperf/releases
15+
# - click "Draft a new release" and fill the contents
16+
# - finally click the "Publish release" button! Done!
17+
# - monitor the publish status: https://github.com/psf/pyperf/actions/workflows/publish.yml
18+
#
19+
# After the release:
20+
#
21+
# - set version to n+1
22+
# - git commit -a -m "post-release"
23+
# - git push or send the PR to the repository
24+
25+
[build-system]
26+
requires = ["setuptools >= 61"]
27+
build-backend = "setuptools.build_meta"
28+
29+
[project]
30+
name = "pyperf"
31+
dynamic = ["version"]
32+
license = {text = "MIT"}
33+
description = "Python module to run and analyze benchmarks"
34+
readme = "README.rst"
35+
urls = {Homepage = "https://github.com/psf/pyperf"}
36+
authors= [{name="Victor Stinner", email="[email protected]"}]
37+
maintainers = [{name = "Dong-hee Na", email="[email protected]"}]
38+
classifiers = [
39+
"Development Status :: 5 - Production/Stable",
40+
"Intended Audience :: Developers",
41+
"License :: OSI Approved :: MIT License",
42+
"Natural Language :: English",
43+
"Operating System :: OS Independent",
44+
"Programming Language :: Python :: 3",
45+
"Topic :: Software Development :: Libraries :: Python Modules"
46+
]
47+
requires-python = ">=3.7"
48+
dependencies = ["psutil>=5.9.0"]
49+
50+
[project.optional-dependencies]
51+
dev = [
52+
'tox',
53+
'importlib-metadata; python_version < "3.8"'
54+
]
55+
56+
[project.scripts]
57+
pyperf = "pyperf.__main__:main"
58+
59+
[tool.setuptools]
60+
packages = ["pyperf", "pyperf.tests"]
61+
62+
[tool.setuptools.dynamic]
63+
version = {attr = "pyperf.__version__"}

setup.py

-74
This file was deleted.

test-requirements.txt

-1
This file was deleted.

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[tox]
22
envlist = py3, pypy3, doc, pep8
3+
isolated_build = True
34

45
[testenv]
5-
deps=-r test-requirements.txt
6+
extras=dev
67
commands=
78
python -bb -Wd -m unittest discover -s pyperf/tests/ -v
89

0 commit comments

Comments
 (0)