Skip to content

Commit 6c4cb1f

Browse files
committed
Migrate setup to pyproject.toml
1 parent 5d5abc3 commit 6c4cb1f

File tree

7 files changed

+95
-105
lines changed

7 files changed

+95
-105
lines changed

.github/workflows/deployment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
- uses: actions/checkout@v3
2222
- uses: actions/setup-python@v4
2323
- name: Install dependencies
24-
run: pip install setuptools wheel twine
24+
run: pip install build twine
2525
- name: Build a binary wheel and a source tarball
26-
run: python setup.py sdist bdist_wheel
26+
run: python3 -m build
2727
- name: Publish distribution 📦 to Test PyPI
2828
if: ${{ needs.has.outputs.secrets }}
2929
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/linting.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ jobs:
77
- uses: actions/checkout@v2
88
- uses: actions/setup-python@v2
99
- uses: psf/black@stable
10-
with:
11-
options: "--skip-magic-trailing-comma"
1210
isort:
1311
runs-on: ubuntu-latest
1412
steps:
@@ -23,6 +21,6 @@ jobs:
2321
- uses: actions/checkout@v2
2422
- uses: actions/setup-python@v2
2523
- name: Install dependencies
26-
run: pip install flake8
24+
run: pip install flake8 flake8-pyproject
2725
- name: Run flake8
2826
run: flake8 .

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ coverage.xml
1717
dist/
1818
docs/_build/
1919
htmlcov/
20-
pyproject.toml
2120
__pycache__/

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ repos:
33
rev: 22.10.0
44
hooks:
55
- id: black
6-
args: [--skip-magic-trailing-comma]
76
- repo: https://github.com/PyCQA/isort
87
rev: 5.10.1
98
hooks:
@@ -12,3 +11,5 @@ repos:
1211
rev: 5.0.4
1312
hooks:
1413
- id: flake8
14+
additional_dependencies:
15+
- flake8-pyproject

pyproject.toml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = ["setuptools"]
4+
5+
[project]
6+
authors = [{ name = "Timo Ludwig", email = "ti.ludwig@web.de" }]
7+
classifiers = [
8+
"Development Status :: 5 - Production/Stable",
9+
"Environment :: Web Environment",
10+
"Framework :: Django :: 3.2",
11+
"Framework :: Django :: 4.0",
12+
"Framework :: Django :: 4.1",
13+
"Framework :: Django",
14+
"Framework :: Sphinx :: Extension",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: Apache Software License",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.7",
21+
"Programming Language :: Python :: 3.8",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python",
24+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
25+
"Topic :: Internet :: WWW/HTTP",
26+
"Topic :: Software Development :: Libraries :: Application Frameworks",
27+
"Topic :: Software Development :: Libraries :: Python Modules",
28+
]
29+
dependencies = ["Django>=2.2", "Sphinx>=0.5", "pprintpp"]
30+
description = "Improve the Sphinx autodoc for Django classes."
31+
dynamic = ["version"]
32+
keywords = ["django", "docstrings", "extension", "sphinx"]
33+
license = { text = "Apache2 2.0 License" }
34+
name = "sphinxcontrib-django2"
35+
readme = "README.rst"
36+
requires-python = ">=3.7"
37+
38+
[project.urls]
39+
"Bug Tracker" = "https://github.com/timoludwig/sphinxcontrib-django2/issues"
40+
"Documentation" = "https://sphinxcontrib-django2.readthedocs.io/"
41+
"Release Notes" = "https://github.com/timoludwig/sphinxcontrib-django2/blob/develop/CHANGES.rst"
42+
"Source Code" = "https://github.com/timoludwig/sphinxcontrib-django2"
43+
44+
[project.optional-dependencies]
45+
dev = ["pre-commit"]
46+
doc = ["sphinx-last-updated-by-git", "sphinx-rtd-theme"]
47+
optional = [
48+
"django-mptt",
49+
"django-phonenumber-field[phonenumbers]",
50+
"psycopg2-binary",
51+
]
52+
test = ["coverage", "pytest", "requests-mock"]
53+
54+
[tool.setuptools.dynamic]
55+
version = { attr = "sphinxcontrib_django2.__version__" }
56+
57+
[tool.setuptools.packages.find]
58+
include = ["sphinxcontrib_django2*"]
59+
60+
[tool.black]
61+
skip-magic-trailing-comma = true
62+
63+
[tool.coverage.run]
64+
command_line = "-m pytest"
65+
source = ["sphinxcontrib_django2"]
66+
67+
[tool.pytest.ini_options]
68+
addopts = "-ra -q"
69+
minversion = "6.0"
70+
testpaths = ["tests"]
71+
72+
[tool.flake8]
73+
ignore = [
74+
"D1", # Missing docstrings
75+
"E203", # whitespace before ':' in slice (incompatible with black)
76+
"E731", # Allow lambdas
77+
"F405", # name undefined due to star imports
78+
"W503", # line break before binary operator (incompatible with black)
79+
]
80+
max-line-length = 99
81+
82+
[tool.isort]
83+
known_first_party = "sphinxcontrib_django2"
84+
# Approach Black compatibility (just run black after isort)
85+
include_trailing_comma = true
86+
line_length = 88
87+
multi_line_output = 3

setup.cfg

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

setup.py

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,4 @@
1-
#!/usr/bin/env python
2-
import codecs
3-
import re
4-
from os import path
1+
#!/usr/bin/env python3
2+
from setuptools import setup
53

6-
from setuptools import find_packages, setup
7-
8-
9-
def read(*parts):
10-
file_path = path.join(path.dirname(__file__), *parts)
11-
return codecs.open(file_path, encoding="utf-8").read()
12-
13-
14-
def find_version(*parts):
15-
version_file = read(*parts)
16-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
17-
if version_match:
18-
return str(version_match.group(1))
19-
raise RuntimeError("Unable to find version string.")
20-
21-
22-
setup(
23-
name="sphinxcontrib-django2",
24-
version=find_version("sphinxcontrib_django2", "__init__.py"),
25-
license="Apache 2.0",
26-
description="Improve the Sphinx autodoc for Django classes.",
27-
long_description=read("README.rst"),
28-
author="Timo Ludwig",
29-
author_email="ti.ludwig@web.de",
30-
url="https://github.com/timoludwig/sphinxcontrib-django2",
31-
download_url="https://github.com/timoludwig/sphinxcontrib-django2/zipball/main",
32-
packages=find_packages(exclude=("example*",)),
33-
install_requires=["Django>=2.2", "Sphinx>=0.5", "pprintpp"],
34-
extras_require={
35-
"dev": ["pre-commit"],
36-
"test": ["pytest", "requests-mock", "codecov"],
37-
"doc": ["sphinx-rtd-theme", "sphinx-last-updated-by-git"],
38-
"optional": [
39-
"psycopg2-binary",
40-
"django-mptt",
41-
"django-phonenumber-field[phonenumbers]",
42-
],
43-
},
44-
include_package_data=True,
45-
zip_safe=False,
46-
classifiers=[
47-
"Development Status :: 5 - Production/Stable",
48-
"Environment :: Web Environment",
49-
"Framework :: Django",
50-
"Framework :: Django :: 3.2",
51-
"Framework :: Django :: 4.0",
52-
"Framework :: Django :: 4.1",
53-
"Framework :: Sphinx :: Extension",
54-
"Intended Audience :: Developers",
55-
"License :: OSI Approved :: Apache Software License",
56-
"Operating System :: OS Independent",
57-
"Programming Language :: Python",
58-
"Programming Language :: Python :: 3.7",
59-
"Programming Language :: Python :: 3.8",
60-
"Programming Language :: Python :: 3.9",
61-
"Programming Language :: Python :: 3.10",
62-
"Programming Language :: Python :: 3.11",
63-
"Topic :: Internet :: WWW/HTTP",
64-
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
65-
"Topic :: Software Development :: Libraries :: Application Frameworks",
66-
"Topic :: Software Development :: Libraries :: Python Modules",
67-
],
68-
)
4+
setup()

0 commit comments

Comments
 (0)