Skip to content

Commit 2001878

Browse files
deronnaxterencehonlesbrowniebroke
authored
Migrate packaging to pyproject.toml (#9056)
Co-authored-by: Terence Honles <terence@honles.com> Co-authored-by: Terence Honles <terencehonles@users.noreply.github.com> Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
1 parent 0f57622 commit 2001878

File tree

5 files changed

+89
-155
lines changed

5 files changed

+89
-155
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ repos:
3131
hooks:
3232
- id: codespell
3333
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js
34+
additional_dependencies:
35+
# python doesn't come with a toml parser prior to 3.11
36+
- "tomli; python_version < '3.11'"
3437

3538
- repo: https://github.com/asottile/pyupgrade
3639
rev: v3.19.1
3740
hooks:
3841
- id: pyupgrade
3942
args: ["--py39-plus", "--keep-percent-format"]
43+
44+
- repo: https://github.com/tox-dev/pyproject-fmt
45+
rev: v2.6.0
46+
hooks:
47+
- id: pyproject-fmt

docs/community/project-management.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ The following template should be used for the description of the issue, and serv
6060

6161
- [ ] Create pull request for [release notes](https://github.com/encode/django-rest-framework/blob/mains/docs/topics/release-notes.md) based on the [*.*.* milestone](https://github.com/encode/django-rest-framework/milestones/***).
6262
- [ ] Update supported versions:
63-
- [ ] `setup.py` `python_requires` list
64-
- [ ] `setup.py` Python & Django version trove classifiers
63+
- [ ] `pyproject.toml` `python_requires` list
64+
- [ ] `pyproject.toml` Python & Django version trove classifiers
6565
- [ ] `README` Python & Django versions
6666
- [ ] `docs` Python & Django versions
6767
- [ ] Update the translations from [transifex](https://www.django-rest-framework.org/topics/project-management/#translations).
@@ -72,7 +72,9 @@ The following template should be used for the description of the issue, and serv
7272
- [ ] Confirm with @tomchristie that release is finalized and ready to go.
7373
- [ ] Ensure that release date is included in pull request.
7474
- [ ] Merge the release pull request.
75-
- [ ] Push the package to PyPI with `./setup.py publish`.
75+
- [ ] Install the release tools: `pip install build twine`
76+
- [ ] Build the package: `python -m build`
77+
- [ ] Push the package to PyPI with `twine upload dist/*`
7678
- [ ] Tag the release, with `git tag -a *.*.* -m 'version *.*.*'; git push --tags`.
7779
- [ ] Deploy the documentation with `mkdocs gh-deploy`.
7880
- [ ] Make a release announcement on the [discussion group](https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework).

pyproject.toml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [ "setuptools>=77.0.3" ]
4+
5+
[project]
6+
name = "djangorestframework"
7+
description = "Web APIs for Django, made easy."
8+
readme = "README.md"
9+
license = "BSD-3-Clause"
10+
authors = [ { name = "Tom Christie", email = "tom@tomchristie.com" } ]
11+
requires-python = ">=3.9"
12+
classifiers = [
13+
"Development Status :: 5 - Production/Stable",
14+
"Environment :: Web Environment",
15+
"Framework :: Django",
16+
"Framework :: Django :: 4.2",
17+
"Framework :: Django :: 5.0",
18+
"Framework :: Django :: 5.1",
19+
"Framework :: Django :: 5.2",
20+
"Intended Audience :: Developers",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3 :: Only",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Topic :: Internet :: WWW/HTTP",
30+
]
31+
dynamic = [ "version" ]
32+
33+
dependencies = [ "django>=4.2" ]
34+
urls.Changelog = "https://www.django-rest-framework.org/community/release-notes/"
35+
urls.Funding = "https://fund.django-rest-framework.org/topics/funding/"
36+
urls.Homepage = "https://www.django-rest-framework.org"
37+
urls.Source = "https://github.com/encode/django-rest-framework"
38+
39+
[tool.setuptools]
40+
41+
[tool.setuptools.dynamic]
42+
version = { attr = "rest_framework.__version__" }
43+
44+
[tool.setuptools.packages.find]
45+
include = [ "rest_framework*" ]
46+
47+
[tool.isort]
48+
skip = [ ".tox" ]
49+
atomic = true
50+
multi_line_output = 5
51+
extra_standard_library = [ "types" ]
52+
known_third_party = [ "pytest", "_pytest", "django", "pytz", "uritemplate" ]
53+
known_first_party = [ "rest_framework", "tests" ]
54+
55+
[tool.codespell]
56+
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
57+
skip = "*/kickstarter-announcement.md,*.js,*.map,*.po"
58+
ignore-words-list = "fo,malcom,ser"
59+
60+
[tool.pytest.ini_options]
61+
addopts = "--tb=short --strict-markers -ra"
62+
testpaths = [ "tests" ]
63+
filterwarnings = [ "ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF317Warning" ]
64+
65+
[tool.coverage.run]
66+
# NOTE: source is ignored with pytest-cov (but uses the same).
67+
source = [ "." ]
68+
include = [ "rest_framework/*", "tests/*" ]
69+
branch = true
70+
71+
[tool.coverage.report]
72+
include = [ "rest_framework/*", "tests/*" ]
73+
exclude_lines = [
74+
"pragma: no cover",
75+
"raise NotImplementedError",
76+
]

setup.cfg

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
1-
[metadata]
2-
license_files = LICENSE.md
3-
4-
[tool:pytest]
5-
addopts=--tb=short --strict-markers -ra
6-
testpaths = tests
7-
filterwarnings = ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF317Warning
8-
91
[flake8]
102
ignore = E501,W503,W504
113
banned-modules = json = use from rest_framework.utils import json!
12-
13-
[isort]
14-
skip=.tox
15-
atomic=true
16-
multi_line_output=5
17-
extra_standard_library=types
18-
known_third_party=pytest,_pytest,django,pytz,uritemplate
19-
known_first_party=rest_framework,tests
20-
21-
[coverage:run]
22-
# NOTE: source is ignored with pytest-cov (but uses the same).
23-
source = .
24-
include = rest_framework/*,tests/*
25-
branch = 1
26-
27-
[coverage:report]
28-
include = rest_framework/*,tests/*
29-
exclude_lines =
30-
pragma: no cover
31-
raise NotImplementedError
32-
33-
[codespell]
34-
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
35-
skip = */kickstarter-announcement.md,*.js,*.map,*.po
36-
ignore-words-list = fo,malcom,ser

setup.py

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

0 commit comments

Comments
 (0)