Skip to content

Commit e221ded

Browse files
committed
Add new dev helpful scripts
1 parent 9c02410 commit e221ded

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ installer = "uv"
7676
commands = [
7777
"bun install --cwd src/js",
7878
'bun build src/js/src/index.ts --outdir="src/reactpy_django/static/reactpy_django/" --minify --sourcemap=linked',
79-
'cd src/build_scripts && python copy_dir.py "src/js/node_modules/@pyscript/core/dist" "src/reactpy_django/static/reactpy_django/pyscript"',
80-
'cd src/build_scripts && python copy_dir.py "src/js/node_modules/morphdom/dist" "src/reactpy_django/static/reactpy_django/morphdom"',
79+
'cd src/scripts && python copy_dir.py "src/js/node_modules/@pyscript/core/dist" "src/reactpy_django/static/reactpy_django/pyscript"',
80+
'cd src/scripts && python copy_dir.py "src/js/node_modules/morphdom/dist" "src/reactpy_django/static/reactpy_django/morphdom"',
8181
]
8282
artifacts = []
8383

@@ -96,6 +96,7 @@ extra-dependencies = [
9696
"servestatic",
9797
"django-bootstrap5",
9898
"decorator",
99+
"uvicorn[standard]",
99100
]
100101
matrix-name-format = "{variable}-{value}"
101102

src/scripts/install_deps.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Development/debug script to parse pyproject.toml to find dependecies then install them in the local
3+
environment via `uv pip install -U <pkg_names>`
4+
"""
5+
6+
import subprocess
7+
from pathlib import Path
8+
9+
import toml
10+
11+
DEPENDENCIES = set()
12+
13+
14+
def find_deps(data):
15+
"""Recurse through all categories and find any list with `dependencies` in the name, then combine
16+
all dependencies into a single list"""
17+
if isinstance(data, dict):
18+
for key, value in data.items():
19+
if "dependencies" in key and isinstance(value, list) and value and isinstance(value[0], str):
20+
DEPENDENCIES.update(value)
21+
else:
22+
find_deps(value)
23+
elif isinstance(data, list):
24+
for item in data:
25+
find_deps(item)
26+
27+
28+
def install_deps():
29+
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
30+
pyproject_data = toml.load(pyproject_path)
31+
find_deps(pyproject_data)
32+
DEPENDENCIES.remove("ruff") # ruff only exists in dev dependencies for CI purposes.
33+
subprocess.run(["uv", "pip", "install", "-U", *DEPENDENCIES], check=False) # noqa: S607
34+
35+
36+
if __name__ == "__main__":
37+
install_deps()

src/scripts/run_django.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Development/debug script to run Django's development server in the local environment.
3+
You should run the `install_deps.py` script before this to ensure all dependencies are installed.
4+
"""
5+
6+
import subprocess
7+
import sys
8+
from pathlib import Path
9+
10+
if __name__ == "__main__":
11+
# Run server and pass through any additional command line arguments (e.g. for specifying a different port)
12+
subprocess.run(
13+
[sys.executable, "manage.py", "runserver", *sys.argv[1:]],
14+
check=True,
15+
cwd=Path(__file__).parent.parent.parent / "tests",
16+
)

0 commit comments

Comments
 (0)