Skip to content

Commit 4a746be

Browse files
committed
switch CI to use hatch commands
1 parent 5891b41 commit 4a746be

19 files changed

+188
-342
lines changed

.github/workflows/publish-develop-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
with:
1919
python-version: 3.x
20-
- run: pip install -r requirements/build-docs.txt
20+
- name: Install dependencies
21+
run: pip install --upgrade pip hatch uv
2122
- name: Publish Develop Docs
2223
run: |
2324
git config user.name github-actions
2425
git config user.email github-actions@github.com
25-
cd docs
26-
mike deploy --push develop
26+
hatch run docs:deploy_develop
2727
concurrency:
2828
group: publish-docs

.github/workflows/publish-latest-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
with:
1919
python-version: 3.x
20-
- run: pip install -r requirements/build-docs.txt
20+
- name: Install dependencies
21+
run: pip install --upgrade pip hatch uv
2122
- name: Publish ${{ github.event.release.name }} Docs
2223
run: |
2324
git config user.name github-actions
2425
git config user.email github-actions@github.com
25-
cd docs
26-
mike deploy --push --update-aliases ${{ github.event.release.name }} latest
26+
hatch run docs:deploy_latest ${{ github.ref_name }}
2727
concurrency:
2828
group: publish-docs

.github/workflows/publish-py.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ jobs:
2020
with:
2121
python-version: "3.x"
2222
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install -r requirements/build-pkg.txt
23+
run: pip install --upgrade pip hatch uv
2624
- name: Build and publish
2725
env:
2826
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2927
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3028
run: |
31-
python -m build --sdist --wheel --outdir dist .
29+
hatch build --clean
3230
twine upload dist/*

.github/workflows/test-docs.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,11 @@ jobs:
2323
- uses: actions/setup-python@v5
2424
with:
2525
python-version: 3.x
26-
# - name: Check docs links
27-
# uses: umbrelladocs/action-linkspector@v1
28-
# with:
29-
# github_token: ${{ secrets.github_token }}
30-
# reporter: github-pr-review
31-
# fail_on_error: false
26+
- name: Install Python Dependencies
27+
run: pip install --upgrade pip hatch uv
28+
- name: Check documentation links
29+
run: hatch run docs:linkcheck
3230
- name: Check docs build
33-
run: |
34-
pip install -r requirements/build-docs.txt
35-
cd docs
36-
mkdocs build --strict
31+
run: hatch run docs:build
3732
- name: Check docs examples
38-
run: |
39-
pip install -r requirements/check-types.txt
40-
pip install -r requirements/check-style.txt
41-
mypy --show-error-codes docs/examples/python/
42-
ruff check docs/examples/python/
33+
run: hatch run docs:check-examples

.github/workflows/test-src.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install Python Dependencies
29-
run: pip install -r requirements/test-run.txt
29+
run: pip install --upgrade pip hatch uv
3030
- name: Run Tests
31-
run: nox -t test
31+
run: hatch test --python ${{ matrix.python-version }}

.linkspector.yml

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

noxfile.py

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

pyproject.toml

Lines changed: 142 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,150 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling", "hatch-build-scripts"]
44

5-
[tool.mypy]
6-
exclude = ['migrations/.*']
7-
ignore_missing_imports = true
8-
warn_unused_configs = true
9-
warn_redundant_casts = true
10-
warn_unused_ignores = true
11-
check_untyped_defs = true
5+
[project]
6+
name = "reactpy_django"
7+
description = "It's React, but in Python. Now with Django integration."
8+
readme = "README.md"
9+
keywords = [
10+
"React",
11+
"ReactJS",
12+
"ReactPy",
13+
"components",
14+
"asgi",
15+
"django",
16+
"http",
17+
"server",
18+
"reactive",
19+
"interactive",
20+
]
21+
license = "MIT"
22+
authors = [{ name = "Mark Bakhit", email = "archiethemonger@gmail.com" }]
23+
requires-python = ">=3.9"
24+
classifiers = [
25+
"Framework :: Django",
26+
"Framework :: Django :: 4.0",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Operating System :: OS Independent",
32+
"Intended Audience :: Developers",
33+
"Intended Audience :: Science/Research",
34+
"Topic :: Multimedia :: Graphics",
35+
"Topic :: Software Development :: Widget Sets",
36+
"Topic :: Software Development :: User Interfaces",
37+
"Environment :: Web Environment",
38+
"Typing :: Typed",
39+
]
40+
dependencies = [
41+
"channels>=4.0.0",
42+
"django>=4.2.0",
43+
"reactpy>=1.0.0, <2.0.0",
44+
"reactpy-router>=1.0.0, <2.0.0",
45+
"dill>=0.3.5",
46+
"orjson >=3.6.0",
47+
"nest_asyncio>=1.5.0",
48+
"typing_extensions",
49+
]
50+
dynamic = ["version"]
51+
urls.Changelog = "https://reactive-python.github.io/reactpy-django/latest/about/changelog/"
52+
urls.Documentation = "https://reactive-python.github.io/reactpy-django/"
53+
urls.Source = "https://github.com/reactive-python/reactpy-django"
1254

13-
[tool.ruff.lint.isort]
14-
known-first-party = ["src", "tests"]
55+
[tool.hatch.version]
56+
path = "src/reactpy_django/__init__.py"
1557

16-
[tool.ruff.lint]
17-
ignore = ["E501"]
58+
[tool.hatch.build.targets.sdist]
59+
include = ["/src"]
60+
artifacts = ["/src/reactpy_django/static/client.js"]
61+
62+
[tool.hatch.build.targets.wheel]
63+
artifacts = ["/src/reactpy_django/static/client.js"]
64+
65+
[tool.hatch.metadata]
66+
license-files = { paths = ["LICENSE.md"] }
67+
68+
[tool.hatch.envs.default]
69+
installer = "uv"
70+
71+
[[tool.hatch.build.hooks.build-scripts.scripts]]
72+
commands = [
73+
"bun install --cwd src/js",
74+
"bun build src/js/src/index.tsx --outfile src/reactpy_django/static/client.js --minify",
75+
'cd scripts && python copy_dir.py "src/js/node_modules/@pyscript/core/dist" "src/reactpy_django/static/pyscript"',
76+
'cd scripts && python copy_dir.py "src/js/node_modules/morphdom/dist" "src/reactpy_django/static/morphdom"',
77+
]
78+
artifacts = []
79+
80+
# >>> Hatch Test Suite <<<
81+
82+
[tool.hatch.envs.hatch-test]
83+
extra-dependencies = [
84+
"playwright",
85+
"twisted",
86+
"channels[daphne]>=4.0.0",
87+
"tblib",
88+
"whitenoise", # TODO: Switch to ServeStatic
89+
]
90+
matrix-name-format = "{variable}-{value}"
91+
92+
[[tool.hatch.envs.hatch-test.matrix]]
93+
python = ["3.9", "3.10", "3.11", "3.12"]
94+
95+
# >>> Hatch Documentation Scripts <<<
96+
97+
[tool.hatch.envs.docs]
98+
template = "docs"
99+
detached = true
100+
dependencies = [
101+
"mkdocs",
102+
"mkdocs-git-revision-date-localized-plugin",
103+
"mkdocs-material==9.4.0",
104+
"mkdocs-include-markdown-plugin",
105+
"mkdocs-spellcheck[all]",
106+
"mkdocs-git-authors-plugin",
107+
"mkdocs-minify-plugin",
108+
"mike",
109+
"mypy", # TODO: Replace with ruff perhaps?
110+
"django-stubs[compatible-mypy]",
111+
"linkcheckmd",
112+
"reactpy_django @ {root:uri}",
113+
]
114+
115+
[tool.hatch.envs.docs.scripts]
116+
serve = ["cd docs && mkdocs serve"]
117+
build = ["cd docs && mkdocs build --strict"]
118+
linkcheck = [
119+
"linkcheckMarkdown docs/ -v -r",
120+
"linkcheckMarkdown README.md -v -r",
121+
"linkcheckMarkdown CHANGELOG.md -v -r",
122+
]
123+
deploy_latest = ["cd docs && mike deploy --push --update-aliases {args} latest"]
124+
deploy_develop = ["cd docs && mike deploy --push develop"]
125+
126+
# >>> Generic Tools <<<
18127

19128
[tool.ruff]
20129
extend-exclude = ["*/migrations/*", ".venv/*", ".eggs/*", ".nox/*", "build/*"]
21130
line-length = 120
131+
format.preview = true
132+
lint.extend-ignore = [
133+
"ARG001", # Unused function argument
134+
"ARG002", # Unused method argument
135+
"ARG004", # Unused static method argument
136+
"FBT001", # Boolean-typed positional argument in function definition
137+
"FBT002", # Boolean default positional argument in function definition
138+
"PLR2004", # Magic value used in comparison
139+
"SIM115", # Use context handler for opening files
140+
"SLF001", # Private member accessed
141+
"E501", # Line too long
142+
]
143+
lint.preview = true
144+
lint.isort.known-first-party = ["src", "tests"]
145+
146+
[tool.pytest.ini_options]
147+
addopts = """\
148+
--strict-config
149+
--strict-markers
150+
"""

requirements.txt

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

requirements/build-docs.txt

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

0 commit comments

Comments
 (0)