Skip to content

Commit 2ff4152

Browse files
authored
Move to modern package configuration (#27)
* Move to modern package configuration * Add GitHub Actions configuration * Add testing deps for mypy
1 parent 72f3df4 commit 2ff4152

File tree

7 files changed

+382
-101
lines changed

7 files changed

+382
-101
lines changed

.github/workflows/packaging.yml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Packaging
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
format:
8+
name: Check formatting
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- name: Install tox
18+
run: python -m pip install tox
19+
20+
- name: Run black
21+
run: tox -e format
22+
23+
lint:
24+
name: Lint
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.12"
32+
33+
- name: Install tox
34+
run: python -m pip install tox
35+
36+
- name: Run flake8
37+
run: tox -e lint
38+
39+
typecheck:
40+
name: Type check
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- uses: actions/setup-python@v5
46+
with:
47+
python-version: "3.12"
48+
49+
- name: Install tox
50+
run: python -m pip install tox
51+
52+
- name: Run mypy
53+
run: tox -e typecheck
54+
55+
test:
56+
name: Test
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
python:
61+
- version: "3.13"
62+
toxenv: "py313"
63+
- version: "3.12"
64+
toxenv: "py312"
65+
- version: "3.11"
66+
toxenv: "py311"
67+
- version: "3.10"
68+
toxenv: "py310"
69+
- version: "3.9"
70+
toxenv: "py39"
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- uses: actions/setup-python@v5
75+
with:
76+
python-version: ${{ matrix.python.version }}
77+
78+
- name: Install tox
79+
run: python -m pip install tox
80+
81+
- name: Run pytest
82+
run: tox -e ${{ matrix.python.toxenv }}
83+
84+
build_source_dist:
85+
name: Build source distribution
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- uses: actions/setup-python@v5
91+
with:
92+
python-version: "3.12"
93+
94+
- name: Install build
95+
run: python -m pip install build
96+
97+
- name: Run build
98+
run: python -m build --sdist
99+
100+
- uses: actions/upload-artifact@v4
101+
with:
102+
path: dist/*.tar.gz
103+
104+
publish:
105+
needs: [format, lint, typecheck, test]
106+
if: startsWith(github.ref, 'refs/tags')
107+
runs-on: ubuntu-latest
108+
environment: release
109+
permissions:
110+
id-token: write
111+
contents: write
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Set up Python
116+
uses: actions/setup-python@v5
117+
with:
118+
python-version: 3.9
119+
120+
- name: Install pypa/build
121+
run: python -m pip install build
122+
123+
- name: Build distribution
124+
run: python -m build --outdir dist/
125+
126+
- name: Publish distribution to Test PyPI
127+
uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
repository_url: https://test.pypi.org/legacy/
130+
131+
- name: Publish distribution to PyPI
132+
uses: pypa/gh-action-pypi-publish@release/v1
133+
134+
- name: Publish distribution to GitHub release
135+
uses: softprops/action-gh-release@v2
136+
with:
137+
files: |
138+
dist/django_webmention-*.whl
139+
dist/django_webmention-*.tar.gz
140+
env:
141+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pyproject.toml

+233-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,235 @@
1+
[project]
2+
name = "django-webmention"
3+
version = "3.0.0"
4+
description = "A pluggable implementation of webmention for Django projects"
5+
authors = [
6+
{ name = "Dane Hillard", email = "github@danehillard.com" },
7+
]
8+
license = { file = "LICENSE" }
9+
classifiers = [
10+
"Development Status :: 5 - Production/Stable",
11+
"Intended Audience :: Developers",
12+
"Framework :: Django",
13+
"Framework :: Django :: 3.2",
14+
"Framework :: Django :: 4.0",
15+
"Framework :: Django :: 4.1",
16+
"Topic :: Internet :: WWW/HTTP :: Indexing/Search",
17+
"License :: OSI Approved :: MIT License",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
26+
]
27+
dependencies = [
28+
"Django>=4.2.0",
29+
"requests>=2.32.3",
30+
]
31+
32+
[project.urls]
33+
Repository = "https://github.com/easy-as-python/django-webmention"
34+
35+
[tool.setuptools.packages.find]
36+
where = ["src"]
37+
exclude = ["test*"]
38+
39+
######################
40+
# Tool configuration #
41+
######################
42+
143
[tool.black]
244
line-length = 120
3-
target-version = ['py35', 'py36', 'py37', 'py38']
45+
target-version = ["py39", "py310", "py311", "py312", "py313"]
46+
47+
[tool.mypy]
48+
python_version = "3.9"
49+
warn_unused_configs = true
50+
show_error_context = true
51+
pretty = true
52+
namespace_packages = true
53+
check_untyped_defs = true
54+
55+
[[tool.mypy.overrides]]
56+
module = [
57+
"django.core.urlresolvers",
58+
]
59+
ignore_missing_imports = true
60+
61+
[tool.coverage.run]
62+
branch = true
63+
omit = [
64+
"manage.py",
65+
"webmention/checks.py",
66+
"*test*",
67+
"*/migrations/*",
68+
"*/admin.py",
69+
"*/__init__.py",
70+
]
71+
72+
[tool.coverage.report]
73+
precision = 2
74+
show_missing = true
75+
skip_covered = true
76+
77+
[tool.coverage.paths]
78+
source = [
79+
"src/webmention",
80+
"*/site-packages/webmention",
81+
]
82+
83+
[tool.pytest.ini_options]
84+
DJANGO_SETTINGS_MODULE = "tests.settings"
85+
testpaths = ["tests"]
86+
addopts = ["-ra", "-q", "--cov=webmention"]
87+
xfail_strict = true
88+
89+
[tool.tox]
90+
envlist = [
91+
"py39-django4.2",
92+
"py39-django5.0",
93+
"py39-django5.1",
94+
"py310-django4.2",
95+
"py310-django5.0",
96+
"py310-django5.1",
97+
"py311-django4.2",
98+
"py311-django5.0",
99+
"py311-django5.1",
100+
"py312-django4.2",
101+
"py312-django5.0",
102+
"py312-django5.1",
103+
"py313-django4.2",
104+
"py313-django5.0",
105+
"py313-django5.1",
106+
]
107+
108+
[tool.tox.env_run_base]
109+
deps = [
110+
"pytest",
111+
"pytest-cov",
112+
"pytest-django",
113+
]
114+
commands = [
115+
["pytest", { replace = "posargs", default = [], extend = true }],
116+
]
117+
118+
[tool.tox.env."py39-django4.2"]
119+
deps = [
120+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
121+
"Django>=4.2,<4.3",
122+
]
123+
124+
[tool.tox.env."py39-django5.0"]
125+
deps = [
126+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
127+
"Django>=5.0,<5.1",
128+
]
129+
130+
[tool.tox.env."py39-django5.1"]
131+
deps = [
132+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
133+
"Django>=5.1,<5.2",
134+
]
135+
136+
[tool.tox.env."py310-django4.2"]
137+
deps = [
138+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
139+
"Django>=4.2,<4.3",
140+
]
141+
142+
[tool.tox.env."py310-django5.0"]
143+
deps = [
144+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
145+
"Django>=5.0,<5.1",
146+
]
147+
148+
[tool.tox.env."py310-django5.1"]
149+
deps = [
150+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
151+
"Django>=5.1,<5.2",
152+
]
153+
154+
[tool.tox.env."py311-django4.2"]
155+
deps = [
156+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
157+
"Django>=4.2,<4.3",
158+
]
159+
160+
[tool.tox.env."py311-django5.0"]
161+
deps = [
162+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
163+
"Django>=5.0,<5.1",
164+
]
165+
166+
[tool.tox.env."py311-django5.1"]
167+
deps = [
168+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
169+
"Django>=5.1,<5.2",
170+
]
171+
172+
[tool.tox.env."py312-django4.2"]
173+
deps = [
174+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
175+
"Django>=4.2,<4.3",
176+
]
177+
178+
[tool.tox.env."py312-django5.0"]
179+
deps = [
180+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
181+
"Django>=5.0,<5.1",
182+
]
183+
184+
[tool.tox.env."py312-django5.1"]
185+
deps = [
186+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
187+
"Django>=5.1,<5.2",
188+
]
189+
190+
[tool.tox.env."py313-django4.2"]
191+
deps = [
192+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
193+
"Django>=4.2,<4.3",
194+
]
195+
196+
[tool.tox.env."py313-django5.0"]
197+
deps = [
198+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
199+
"Django>=5.0,<5.1",
200+
]
201+
202+
[tool.tox.env."py313-django5.1"]
203+
deps = [
204+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
205+
"Django>=5.1,<5.2",
206+
]
207+
208+
[tool.tox.env.lint]
209+
skip_install = true
210+
deps = [
211+
"ruff",
212+
]
213+
commands = [
214+
["ruff", "check", { replace = "posargs", default = ["--diff", "src/webmention", "tests"], extend = true }],
215+
]
216+
217+
[tool.tox.env.format]
218+
skip_install = true
219+
deps = [
220+
"black",
221+
]
222+
commands = [
223+
["black", { replace = "posargs", default = ["--check", "--diff", "src/webmention", "tests"], extend = true }],
224+
]
225+
226+
[tool.tox.env.typecheck]
227+
deps = [
228+
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
229+
"mypy",
230+
"django-types",
231+
"types-requests",
232+
]
233+
commands = [
234+
["mypy", { replace = "posargs", default = ["src/webmention", "tests"], extend = true }],
235+
]

0 commit comments

Comments
 (0)