Skip to content

Commit

Permalink
Merge pull request #474 from jarrodmillman/pyproject.toml
Browse files Browse the repository at this point in the history
Use pyproject.toml
  • Loading branch information
jarrodmillman committed Jul 2, 2023
2 parents 10acda9 + 47277ec commit 44d679e
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 97 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
branch = True
source = numpydoc
omit =
*/setup.py
numpydoc/tests/*
numpydoc/templates/*
21 changes: 18 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ on: [push, pull_request]

jobs:
pre-commit:
name: Linting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: |
pip install --upgrade pip
pip install -r requirements/developer.txt
pip list
- name: Lint
run: pre-commit run --all-files --show-diff-on-failure --color always
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
rev: v2.7.1
hooks:
- id: prettier
files: \.(html|md|yml|yaml)
files: \.(html|md|toml|yml|yaml)
args: [--prose-wrap=preserve]

- repo: https://github.com/adamchainz/blacken-docs
Expand All @@ -38,3 +38,11 @@ repos:
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: local
hooks:
- id: pyproject.toml
name: pyproject.toml
language: system
entry: python tools/generate_pyproject.toml.py
files: "pyproject.toml|requirements/.*\\.txt|tools/.*pyproject.*"
88 changes: 88 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
################################################################################
# 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']

[project]
name = 'numpydoc'
description = 'Sphinx extension to support docstrings in Numpy format'
readme = 'README.rst'
requires-python = '>=3.8'
dynamic = ['version']
keywords = [
'sphinx',
'numpy',
]
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Plugins',
'License :: OSI Approved :: BSD License',
'Topic :: Documentation',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]
dependencies = [
'sphinx>=5',
'Jinja2>=2.10',
'tabulate>=0.8.10',
"tomli>=1.1.0;python_version<'3.11'",
]

[[project.authors]]
name = 'Pauli Virtanen and others'
email = 'pav@iki.fi'

[project.license]
file = 'LICENSE.txt'

[project.urls]
Homepage = 'https://numpydoc.readthedocs.io'

[project.optional-dependencies]
doc = [
'numpy>=1.22',
'matplotlib>=3.5',
'pydata-sphinx-theme>=0.13',
'sphinx>=6',
]
test = [
'pytest',
'pytest-cov',
'matplotlib',
]

[project.scripts]
validate-docstrings = 'numpydoc.hooks.validate_docstrings:main'
[tool.setuptools]
include-package-data = false
packages = [
'numpydoc',
'numpydoc.hooks',
]

[tool.setuptools.package-data]
numpydoc = [
'tests/test_*.py',
'tests/tinybuild/Makefile',
'tests/tinybuild/index.rst',
'tests/tinybuild/*.py',
'templates/*.rst',
]
[tool.pytest.ini_options]
addopts = '''
--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc
--junit-xml=junit-results.xml --ignore=doc/ --ignore=tools/'''
junit_family = 'xunit2'
1 change: 1 addition & 0 deletions requirements/developer.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pre-commit>=3.3
rtoml
9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.

83 changes: 0 additions & 83 deletions setup.py

This file was deleted.

52 changes: 52 additions & 0 deletions tools/generate_pyproject.toml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python

import os
import sys

try:
import rtoml as toml
except ImportError:
print("Please install `rtoml` first: `pip install rtoml`")
sys.exit(1)


if not os.path.isfile("pyproject.toml"):
print("Please run this script from the skimage repository root:")
print(" python tools/generate_pyproject.toml.py")
sys.exit(1)


def parse_requirements_file(filename):
with open(filename) as fid:
requires = [l.strip() for l in fid.readlines() if not l.startswith("#")]
requires = [l for l in requires if l]

return requires


with open("tools/pyproject.toml.in") as f:
pyproject = toml.load(f)

# pyproject['project']['dependencies'] = \
# parse_requirements_file("requirements/default.txt")

pyproject["project"]["optional-dependencies"] = {
dep: parse_requirements_file(f"requirements/{dep}.txt") for dep in ["doc", "test"]
}

banner = f"""\
{"#" * 80}
# DO NOT EDIT
# AUTOGENERATED BY
#
# $ python tools/generate_pyproject.toml.py
#
# EDIT tools/pyproject.toml.in AND RUN THAT SCRIPT.
#
{"#" * 80}
"""

with open("pyproject.toml", "w") as f:
f.write(banner)
toml.dump(pyproject, f, pretty=True)
67 changes: 67 additions & 0 deletions tools/pyproject.toml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = [
"setuptools>=61.2",
]
build-backend = "setuptools.build_meta"

[project]
name = "numpydoc"
description = "Sphinx extension to support docstrings in Numpy format"
license = {file = "LICENSE.txt"}
dynamic = ['version']
keywords = [
"sphinx",
"numpy",
]
readme = "README.rst"
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Plugins",
"License :: OSI Approved :: BSD License",
"Topic :: Documentation",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
requires-python = ">=3.8"
dependencies = [
"sphinx>=5",
"Jinja2>=2.10",
"tabulate>=0.8.10",
"tomli>=1.1.0;python_version<'3.11'",
]

[[project.authors]]
name = "Pauli Virtanen and others"
email = "pav@iki.fi"

[project.urls]
Homepage = "https://numpydoc.readthedocs.io"

[project.optional-dependencies]

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

[tool.setuptools]
packages = [
"numpydoc",
"numpydoc.hooks",
]
include-package-data = false

[tool.setuptools.package-data]
numpydoc = [
"tests/test_*.py",
"tests/tinybuild/Makefile",
"tests/tinybuild/index.rst",
"tests/tinybuild/*.py",
"templates/*.rst",
]

[tool.pytest.ini_options]
addopts = "--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc\n--junit-xml=junit-results.xml --ignore=doc/ --ignore=tools/"
junit_family = "xunit2"

0 comments on commit 44d679e

Please sign in to comment.