Skip to content

Commit 44d679e

Browse files
Merge pull request #474 from jarrodmillman/pyproject.toml
Use pyproject.toml
2 parents 10acda9 + 47277ec commit 44d679e

File tree

9 files changed

+235
-97
lines changed

9 files changed

+235
-97
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
branch = True
33
source = numpydoc
44
omit =
5-
*/setup.py
65
numpydoc/tests/*
76
numpydoc/templates/*

.github/workflows/lint.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ on: [push, pull_request]
44

55
jobs:
66
pre-commit:
7-
name: Linting
87
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.11"]
11+
912
steps:
1013
- uses: actions/checkout@v3
11-
- uses: actions/setup-python@v4
12-
- uses: pre-commit/[email protected]
14+
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
20+
- name: Install packages
21+
run: |
22+
pip install --upgrade pip
23+
pip install -r requirements/developer.txt
24+
pip list
25+
26+
- name: Lint
27+
run: pre-commit run --all-files --show-diff-on-failure --color always

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
rev: v2.7.1
2626
hooks:
2727
- id: prettier
28-
files: \.(html|md|yml|yaml)
28+
files: \.(html|md|toml|yml|yaml)
2929
args: [--prose-wrap=preserve]
3030

3131
- repo: https://github.com/adamchainz/blacken-docs
@@ -38,3 +38,11 @@ repos:
3838
hooks:
3939
- id: pyupgrade
4040
args: [--py38-plus]
41+
42+
- repo: local
43+
hooks:
44+
- id: pyproject.toml
45+
name: pyproject.toml
46+
language: system
47+
entry: python tools/generate_pyproject.toml.py
48+
files: "pyproject.toml|requirements/.*\\.txt|tools/.*pyproject.*"

pyproject.toml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
################################################################################
2+
# DO NOT EDIT
3+
# AUTOGENERATED BY
4+
#
5+
# $ python tools/generate_pyproject.toml.py
6+
#
7+
# EDIT tools/pyproject.toml.in AND RUN THAT SCRIPT.
8+
#
9+
################################################################################
10+
11+
[build-system]
12+
build-backend = 'setuptools.build_meta'
13+
requires = ['setuptools>=61.2']
14+
15+
[project]
16+
name = 'numpydoc'
17+
description = 'Sphinx extension to support docstrings in Numpy format'
18+
readme = 'README.rst'
19+
requires-python = '>=3.8'
20+
dynamic = ['version']
21+
keywords = [
22+
'sphinx',
23+
'numpy',
24+
]
25+
classifiers = [
26+
'Development Status :: 4 - Beta',
27+
'Environment :: Plugins',
28+
'License :: OSI Approved :: BSD License',
29+
'Topic :: Documentation',
30+
'Programming Language :: Python',
31+
'Programming Language :: Python :: 3',
32+
'Programming Language :: Python :: 3.8',
33+
'Programming Language :: Python :: 3.9',
34+
'Programming Language :: Python :: 3.10',
35+
'Programming Language :: Python :: 3.11',
36+
]
37+
dependencies = [
38+
'sphinx>=5',
39+
'Jinja2>=2.10',
40+
'tabulate>=0.8.10',
41+
"tomli>=1.1.0;python_version<'3.11'",
42+
]
43+
44+
[[project.authors]]
45+
name = 'Pauli Virtanen and others'
46+
47+
48+
[project.license]
49+
file = 'LICENSE.txt'
50+
51+
[project.urls]
52+
Homepage = 'https://numpydoc.readthedocs.io'
53+
54+
[project.optional-dependencies]
55+
doc = [
56+
'numpy>=1.22',
57+
'matplotlib>=3.5',
58+
'pydata-sphinx-theme>=0.13',
59+
'sphinx>=6',
60+
]
61+
test = [
62+
'pytest',
63+
'pytest-cov',
64+
'matplotlib',
65+
]
66+
67+
[project.scripts]
68+
validate-docstrings = 'numpydoc.hooks.validate_docstrings:main'
69+
[tool.setuptools]
70+
include-package-data = false
71+
packages = [
72+
'numpydoc',
73+
'numpydoc.hooks',
74+
]
75+
76+
[tool.setuptools.package-data]
77+
numpydoc = [
78+
'tests/test_*.py',
79+
'tests/tinybuild/Makefile',
80+
'tests/tinybuild/index.rst',
81+
'tests/tinybuild/*.py',
82+
'templates/*.rst',
83+
]
84+
[tool.pytest.ini_options]
85+
addopts = '''
86+
--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc
87+
--junit-xml=junit-results.xml --ignore=doc/ --ignore=tools/'''
88+
junit_family = 'xunit2'

requirements/developer.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pre-commit>=3.3
2+
rtoml

setup.cfg

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

setup.py

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

tools/generate_pyproject.toml.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import sys
5+
6+
try:
7+
import rtoml as toml
8+
except ImportError:
9+
print("Please install `rtoml` first: `pip install rtoml`")
10+
sys.exit(1)
11+
12+
13+
if not os.path.isfile("pyproject.toml"):
14+
print("Please run this script from the skimage repository root:")
15+
print(" python tools/generate_pyproject.toml.py")
16+
sys.exit(1)
17+
18+
19+
def parse_requirements_file(filename):
20+
with open(filename) as fid:
21+
requires = [l.strip() for l in fid.readlines() if not l.startswith("#")]
22+
requires = [l for l in requires if l]
23+
24+
return requires
25+
26+
27+
with open("tools/pyproject.toml.in") as f:
28+
pyproject = toml.load(f)
29+
30+
# pyproject['project']['dependencies'] = \
31+
# parse_requirements_file("requirements/default.txt")
32+
33+
pyproject["project"]["optional-dependencies"] = {
34+
dep: parse_requirements_file(f"requirements/{dep}.txt") for dep in ["doc", "test"]
35+
}
36+
37+
banner = f"""\
38+
{"#" * 80}
39+
# DO NOT EDIT
40+
# AUTOGENERATED BY
41+
#
42+
# $ python tools/generate_pyproject.toml.py
43+
#
44+
# EDIT tools/pyproject.toml.in AND RUN THAT SCRIPT.
45+
#
46+
{"#" * 80}
47+
48+
"""
49+
50+
with open("pyproject.toml", "w") as f:
51+
f.write(banner)
52+
toml.dump(pyproject, f, pretty=True)

tools/pyproject.toml.in

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=61.2",
4+
]
5+
build-backend = "setuptools.build_meta"
6+
7+
[project]
8+
name = "numpydoc"
9+
description = "Sphinx extension to support docstrings in Numpy format"
10+
license = {file = "LICENSE.txt"}
11+
dynamic = ['version']
12+
keywords = [
13+
"sphinx",
14+
"numpy",
15+
]
16+
readme = "README.rst"
17+
classifiers = [
18+
"Development Status :: 4 - Beta",
19+
"Environment :: Plugins",
20+
"License :: OSI Approved :: BSD License",
21+
"Topic :: Documentation",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
]
29+
requires-python = ">=3.8"
30+
dependencies = [
31+
"sphinx>=5",
32+
"Jinja2>=2.10",
33+
"tabulate>=0.8.10",
34+
"tomli>=1.1.0;python_version<'3.11'",
35+
]
36+
37+
[[project.authors]]
38+
name = "Pauli Virtanen and others"
39+
40+
41+
[project.urls]
42+
Homepage = "https://numpydoc.readthedocs.io"
43+
44+
[project.optional-dependencies]
45+
46+
[project.scripts]
47+
validate-docstrings = "numpydoc.hooks.validate_docstrings:main"
48+
49+
[tool.setuptools]
50+
packages = [
51+
"numpydoc",
52+
"numpydoc.hooks",
53+
]
54+
include-package-data = false
55+
56+
[tool.setuptools.package-data]
57+
numpydoc = [
58+
"tests/test_*.py",
59+
"tests/tinybuild/Makefile",
60+
"tests/tinybuild/index.rst",
61+
"tests/tinybuild/*.py",
62+
"templates/*.rst",
63+
]
64+
65+
[tool.pytest.ini_options]
66+
addopts = "--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc\n--junit-xml=junit-results.xml --ignore=doc/ --ignore=tools/"
67+
junit_family = "xunit2"

0 commit comments

Comments
 (0)