Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ repos:
- id: pyproject.toml
name: pyproject.toml
language: system
entry: python tools/generate_pyproject.toml.py
files: "pyproject.toml|requirements/.*\\.txt|tools/.*pyproject.*"
entry: python tools/generate_requirements.py
files: "pyproject.toml|requirements/.*\\.txt|tools/.*generate.*"
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
################################################################################
# DO NOT EDIT
# AUTOGENERATED BY
#
# $ python tools/generate_pyproject.toml.py
#
# EDIT tools/pyproject.toml.in AND RUN THAT SCRIPT.
#
################################################################################

[build-system]
build-backend = 'setuptools.build_meta'
requires = ['setuptools>=61.2']
Expand Down Expand Up @@ -67,6 +57,7 @@ test = [

[project.scripts]
validate-docstrings = 'numpydoc.hooks.validate_docstrings:main'

[tool.setuptools]
include-package-data = false
packages = [
Expand All @@ -84,6 +75,7 @@ numpydoc = [
'tests/tinybuild/*.py',
'templates/*.rst',
]

[tool.pytest.ini_options]
addopts = '''
--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc
Expand Down
2 changes: 1 addition & 1 deletion requirements/developer.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pre-commit>=3.3
rtoml
tomli; python_version < '3.11'
1 change: 1 addition & 0 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated from pyproject.toml
numpy>=1.22
matplotlib>=3.5
pydata-sphinx-theme>=0.13
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated from pyproject.toml
pytest
pytest-cov
matplotlib
52 changes: 0 additions & 52 deletions tools/generate_pyproject.toml.py

This file was deleted.

22 changes: 22 additions & 0 deletions tools/generate_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Generate requirements/*.txt files from pyproject.toml."""

import sys
from pathlib import Path

try: # standard module since Python 3.11
import tomllib as toml
except ImportError:
try: # available for older Python via pip
import tomli as toml
except ImportError:
sys.exit("Please install `tomli` first: `pip install tomli`")

repo_dir = (Path(__file__).parent / "..").resolve()
req_dir = repo_dir / "requirements"
pyproject = toml.loads((repo_dir / "pyproject.toml").read_text())

for key, opt_list in pyproject["project"]["optional-dependencies"].items():
lines = ["# Generated from pyproject.toml"] + opt_list
req_fname = req_dir / f"{key}.txt"
req_fname.write_text("\n".join(lines) + "\n")
71 changes: 0 additions & 71 deletions tools/pyproject.toml.in

This file was deleted.