Skip to content

Commit 2df1594

Browse files
committed
Switch to pyproject.toml
With [PEP 621 support added to setuptools](pypa/setuptools#2970) last year, and with pip supporting editable installs as of 21.3, we can move to `pyproject.toml` and deprecate `setup.py`. The file remains for legacy pip support. Because [flake8 does not want to support pyproject.tml yet](PyCQA/flake8#234), unlike all the other tools we use, I’m removing it in favor of [ruff](https://github.com/charliermarsh/ruff). This change also enables support for Wagtail 3.x by removing the `<3` version pin. This will result in the last release of TreeModelAdmin to support Wagtail < 4. Wagtail 4.x is not yet supported. The version is bumped to 1.5.0 for anticipated release to permit installing with Wagtail 3.x. I’ve also brought in some quality-of-life improvements for coverage checking from the Django-Flags tox/GHA setup.
1 parent 1d7bc3d commit 2df1594

File tree

6 files changed

+174
-117
lines changed

6 files changed

+174
-117
lines changed

.github/workflows/test.yml

+52-26
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
name: lint
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v2
1212

1313
- name: Set up Python
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v4
1515
with:
16-
python-version: 3.9
16+
python-version: 3.8
1717

1818
- name: Install dependencies
1919
run: |
@@ -32,31 +32,25 @@ jobs:
3232
strategy:
3333
matrix:
3434
toxenv:
35-
- py36-dj22-wag211
36-
- py36-dj22-waglatest
37-
- py36-dj32-waglatest
38-
- py39-dj22-wag211
39-
- py39-dj22-waglatest
40-
- py39-dj32-waglatest
35+
- py38-dj3-wag2
36+
- py38-dj3-wag3
37+
- py38-dj3-waglatest
38+
- py38-dj4-waglatest
4139
include:
42-
- toxenv: py36-dj22-wag211
43-
python-version: 3.6
44-
- toxenv: py36-dj22-waglatest
45-
python-version: 3.6
46-
- toxenv: py36-dj32-waglatest
47-
python-version: 3.6
48-
- toxenv: py39-dj22-wag211
49-
python-version: 3.9
50-
- toxenv: py39-dj22-waglatest
51-
python-version: 3.9
52-
- toxenv: py39-dj32-waglatest
53-
python-version: 3.9
40+
- toxenv: py38-dj3-wag2
41+
python-version: 3.8
42+
- toxenv: py38-dj3-wag3
43+
python-version: 3.8
44+
- toxenv: py36-dj3-waglatest
45+
python-version: 3.8
46+
- toxenv: py38-dj4-waglatest
47+
python-version: 3.8
5448

5549
steps:
56-
- uses: actions/checkout@v1
50+
- uses: actions/checkout@v3
5751

5852
- name: Set up Python
59-
uses: actions/setup-python@v1
53+
uses: actions/setup-python@v4
6054
with:
6155
python-version: ${{ matrix.python-version }}
6256

@@ -68,8 +62,40 @@ jobs:
6862
- name: Run tox
6963
run: |
7064
tox
71-
coveralls
7265
env:
7366
TOXENV: ${{ matrix.toxenv }}
74-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
75-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Store test coverage
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: coverage
72+
path: .coverage.*
73+
74+
coverage:
75+
name: coverage
76+
runs-on: ubuntu-latest
77+
needs:
78+
- test
79+
80+
steps:
81+
- uses: actions/checkout@v3
82+
with:
83+
fetch-depth: 0
84+
85+
- name: Set up Python
86+
uses: actions/setup-python@v4
87+
with:
88+
python-version: "3.10"
89+
90+
- name: Install dependencies
91+
run: |
92+
python -m pip install --upgrade pip
93+
pip install tox
94+
95+
- name: Retrieve test coverage
96+
uses: actions/download-artifact@v2
97+
with:
98+
name: coverage
99+
100+
- name: Check coverage
101+
run: tox -e coverage

.pre-commit-config.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ repos:
55
- id: black
66
args: ["treemodeladmin", "setup.py", "--line-length=79"]
77
exclude: migrations
8-
- repo: https://gitlab.com/pycqa/flake8
9-
rev: 4.0.1
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
rev: v0.0.188
1010
hooks:
11-
- id: flake8
12-
additional_dependencies: [flake8-bugbear==22.1.11]
11+
- id: ruff
1312
- repo: https://github.com/pycqa/isort
1413
rev: 5.10.1
1514
hooks:

pyproject.toml

+67-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
1+
[project]
2+
name = "wagtail-treemodeladmin"
3+
version = "1.5.0"
4+
description = "TreeModelAdmin for Wagtail"
5+
readme = "README.md"
6+
requires-python = ">=3.8"
7+
license = {text = "CC0"}
8+
authors = [
9+
{name = "CFPB", email = "[email protected]" }
10+
]
11+
dependencies = [
12+
"wagtail>=2.15,<4",
13+
]
14+
classifiers = [
15+
"Framework :: Django",
16+
"Framework :: Django :: 3.2",
17+
"Framework :: Django :: 4",
18+
"Framework :: Wagtail",
19+
"Framework :: Wagtail :: 2",
20+
"Framework :: Wagtail :: 3",
21+
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
22+
"License :: Public Domain",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3",
25+
]
26+
27+
[project.optional-dependencies]
28+
testing = [
29+
"coverage[toml]",
30+
]
31+
32+
[project.urls]
33+
"Homepage" = "https://github.com/cfpb/wagtail-treemodeladmin"
34+
"Bug Reports" = "https://github.com/cfpb/wagtail-treemodeladmin/issues"
35+
"Source" = "https://github.com/cfpb/wagtail-treemodeladmin"
36+
37+
[build-system]
38+
requires = ["setuptools>=43.0.0", "wheel"]
39+
build-backend = "setuptools.build_meta"
40+
41+
[tool.setuptools.package-data]
42+
treemodeladmin = [
43+
"templates/treemodeladmin/*",
44+
"templates/treemodeladmin/includes/*",
45+
"static/treemodeladmin/css/*",
46+
]
47+
148
[tool.black]
249
line-length = 79
3-
target-version = ['py36', 'py38']
50+
target-version = ["py38"]
451
include = '\.pyi?$'
552
exclude = '''
653
(
@@ -14,8 +61,6 @@ exclude = '''
1461
| dist
1562
| migrations
1663
| site
17-
| \*.json
18-
| \*.csv
1964
)/
2065
)
2166
'''
@@ -37,5 +82,22 @@ sections = [
3782
"LOCALFOLDER"
3883
]
3984

40-
[build-system]
41-
requires = ["setuptools", "wheel"]
85+
[tool.ruff]
86+
exclude = [
87+
".git",
88+
".tox",
89+
"__pycache__",
90+
"*/migrations/*.py",
91+
"*/tests/treemodeladmintest/migrations/*",
92+
]
93+
ignore = []
94+
select = [
95+
"E",
96+
"F",
97+
"W",
98+
]
99+
100+
[tool.coverage.run]
101+
omit = [
102+
"treemodeladmin/tests/*",
103+
]

setup.py

+2-40
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,4 @@
1-
from setuptools import find_packages, setup
1+
from setuptools import setup
22

3-
install_requires = [
4-
"wagtail>=2.11,<3",
5-
]
63

7-
testing_extras = ["coverage>=3.7.0"]
8-
9-
setup(
10-
name="wagtail-treemodeladmin",
11-
url="https://github.com/cfpb/wagtail-treemodeladmin",
12-
author="CFPB",
13-
author_email="[email protected]",
14-
description="TreeModelAdmin for Wagtail",
15-
long_description=open("README.md", "r", encoding="utf-8").read(),
16-
long_description_content_type="text/markdown",
17-
license="CC0",
18-
version="1.5.0",
19-
include_package_data=True,
20-
packages=find_packages(),
21-
package_data={
22-
"treemodeladmin": [
23-
"templates/treemodeladmin/*",
24-
"templates/treemodeladmin/includes/*",
25-
"static/treemodeladmin/css/*",
26-
]
27-
},
28-
python_requires=">=3.6",
29-
install_requires=install_requires,
30-
extras_require={"testing": testing_extras},
31-
classifiers=[
32-
"Framework :: Django",
33-
"Framework :: Django :: 2.2",
34-
"Framework :: Django :: 3.1",
35-
"Framework :: Wagtail",
36-
"Framework :: Wagtail :: 2",
37-
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
38-
"License :: Public Domain",
39-
"Programming Language :: Python",
40-
"Programming Language :: Python :: 3",
41-
],
42-
)
4+
setup()

tox.ini

+23-36
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,47 @@
22
skipsdist=True
33
envlist=
44
lint,
5-
py{36,39}-dj{22}-wag{211,latest}
6-
py{36,39}-dj{32}-wag{latest}
5+
py{38,311}-dj{3}-wag{2,3,latest},
6+
coverage
77

88
[testenv]
99
install_command=pip install -e ".[testing]" -U {opts} {packages}
1010
commands=
11-
coverage erase
11+
python -b -m coverage run --parallel-mode --source='wagtailflags' {envbindir}/django-admin test {posargs}
12+
1213
coverage run --source='treemodeladmin' {envbindir}/django-admin test {posargs}
13-
coverage report -m
1414
setenv=
1515
DJANGO_SETTINGS_MODULE=treemodeladmin.tests.settings
1616

1717
basepython=
18-
py36: python3.6
19-
py39: python3.9
18+
py38: python3.8
19+
py311: python3.11
2020

2121
deps=
22-
dj22: Django>=2.2,<2.3
23-
dj32: Django>=3.2,<3.3
24-
wag211: wagtail>=2.11,<2.12
22+
dj3: Django>=3.2,<4
23+
dj4: Django>=4.1,<5
24+
wag2: wagtail>=2.15,<3
25+
wag3: wagtail>=3,<4
2526
waglatest: wagtail<3
2627

2728
[testenv:lint]
28-
basepython=python3.9
29+
basepython=python3.8
2930
deps=
3031
black
31-
flake8
32+
ruff
3233
isort
3334
commands=
34-
black --check treemodeladmin setup.py
35-
flake8 treemodeladmin setup.py
35+
black --check treemodeladmin
36+
ruff treemodeladmin
3637
isort --check-only --diff treemodeladmin
3738

38-
[flake8]
39-
ignore=E732,W503,W504
40-
exclude=
41-
.git,
42-
.tox,
43-
__pycache__,
44-
*/migrations/*.py,
45-
*/tests/treemodeladmintest/migrations/*
46-
47-
[isort]
48-
combine_as_imports=1
49-
lines_after_imports=2
50-
include_trailing_comma=1
51-
multi_line_output=3
52-
skip=.tox,migrations
53-
use_parentheses=1
54-
known_django=django
55-
known_wagtail=wagtail
56-
default_section=THIRDPARTY
57-
sections=FUTURE,STDLIB,DJANGO,WAGTAIL,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
39+
[testenv:coverage]
40+
basepython=python3.8
41+
deps=
42+
coverage[toml]
43+
diff_cover
44+
commands=
45+
coverage combine
46+
coverage xml
47+
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100
5848

59-
[coverage:run]
60-
omit =
61-
treemodeladmin/tests/*

treemodeladmin/tests/settings.py

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22

3+
import wagtail
4+
35

46
DEBUG = True
57

@@ -26,19 +28,38 @@
2628
"wagtail.contrib.forms",
2729
"wagtail.contrib.modeladmin",
2830
"wagtail.contrib.settings",
29-
"wagtail.tests.testapp",
3031
"wagtail.admin",
31-
"wagtail.core",
3232
"wagtail.documents",
3333
"wagtail.images",
3434
"wagtail.sites",
3535
"wagtail.users",
3636
)
3737

38-
WAGTAILADMIN_RICH_TEXT_EDITORS = {
39-
"default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"},
40-
"custom": {"WIDGET": "wagtail.tests.testapp.rich_text.CustomRichTextArea"},
41-
}
38+
if wagtail.VERSION >= (3, 0):
39+
WAGTAIL_APPS += (
40+
"wagtail",
41+
"wagtail.test.testapp",
42+
)
43+
44+
WAGTAILADMIN_RICH_TEXT_EDITORS = {
45+
"default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"},
46+
"custom": {
47+
"WIDGET": "wagtail.test.testapp.rich_text.CustomRichTextArea"
48+
},
49+
}
50+
51+
else:
52+
WAGTAIL_APPS += (
53+
"wagtail.core",
54+
"wagtail.tests.testapp",
55+
)
56+
57+
WAGTAILADMIN_RICH_TEXT_EDITORS = {
58+
"default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"},
59+
"custom": {
60+
"WIDGET": "wagtail.tests.testapp.rich_text.CustomRichTextArea"
61+
},
62+
}
4263

4364
MIDDLEWARE = (
4465
"django.middleware.common.CommonMiddleware",

0 commit comments

Comments
 (0)