Skip to content

Commit 47277ec

Browse files
committed
Update pyproject.toml with requirements
1 parent 454e838 commit 47277ec

File tree

6 files changed

+157
-4
lines changed

6 files changed

+157
-4
lines changed

.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/action@v3.0.0
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
[build-system]
212
build-backend = 'setuptools.build_meta'
313
requires = ['setuptools>=61.2']
@@ -74,5 +84,5 @@ numpydoc = [
7484
[tool.pytest.ini_options]
7585
addopts = '''
7686
--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc
77-
--junit-xml=junit-results.xml --ignore=doc/'''
87+
--junit-xml=junit-results.xml --ignore=doc/ --ignore=tools/'''
7888
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

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+
email = "pav@iki.fi"
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)