forked from postgres/pgcommitfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dev.py
More file actions
executable file
·35 lines (27 loc) · 937 Bytes
/
run_dev.py
File metadata and controls
executable file
·35 lines (27 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
"""Run uWSGI with Django static files mapping.
The reason we don't hardcode the path to the static admin directory in the
uwsgi_dev.ini file is because the path contains the python version, something
like:
env/lib/python3.12/site-packages/django/...
Requiring everyone to use the same python version is not practical, so instead
we have this tiny script that will find the path to the Django admin static
files and run uWSGI with the correct path.
"""
import subprocess
import sys
from importlib.machinery import PathFinder
django_path = PathFinder().find_spec("django").submodule_search_locations[0]
django_admin_path = django_path + "/contrib/admin/static/admin"
if len(sys.argv) > 1:
ini_file = sys.argv[1]
else:
ini_file = "uwsgi_dev.ini"
subprocess.run(
[
"uwsgi",
"--static-map",
f"/media/admin={django_path}/contrib/admin/static/admin",
ini_file,
]
)