Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
81 lines (65 loc) · 3.08 KB
/
Copy pathsetup.sh
File metadata and controls
81 lines (65 loc) · 3.08 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
echo "============================================================"
echo "Setting Up Django Project Environment"
echo "This script will make a new venv and install the requirements, then start the Django Project"
echo "This project is tested on Python 3.8. It may not work on other versions"
echo "If this script does not work, you will need to start django manually. This script is only a helper to make it easier to start the project."
echo "Please follow the instructions in the README.txt file to start the project if you need to."
echo "============================================================"
# alias UV temporarily so we can get the path to it without restarting the terminal session
uv_temporary_path="$HOME/.local/bin/uv"
echo "$uv_temporary_path"
# Install UV for faster package management
if ! type "$uv_temporary_path" > /dev/null; then
curl -LsSf https://astral.sh/uv/install.sh | sh
else
echo "uv command found"
$uv_temporary_path --version
fi
if [ ! -f ".venv/bin/activate" ]; then
echo "Creating venv ... This may take a while"
$uv_temporary_path venv .venv
fi
if [ ! -f ".env" ]; then
cp "example_env.txt" ".env"
fi
echo "Installing requirements"
$uv_temporary_path pip install -r pyproject.toml --all-extras
if [ -f "teams_source/manage.py" ]; then
echo "Making migrations"
./.venv/bin/python teams_source/manage.py makemigrations
echo "Running migrations"
./.venv/bin/python teams_source/manage.py migrate teams_app
./.venv/bin/python teams_source/manage.py migrate
echo "Creating cache table"
./.venv/bin/python teams_source/manage.py createcachetable
echo "Loading fixtures"
for f in teams_source/teams_app/fixtures/*.*; do
echo "Loading fixture $f"
./.venv/bin/python teams_source/manage.py loaddata "$f"
done
if [ ! -f ".venv/user_created" ]; then
echo "----------------------------------------------------------------------------------------------------"
echo "----------------------------------------------------------------------------------------------------"
echo "Please create an admin user and password. You will need to use this to sign in to the admin panel."
echo "Please do not use a real password; this is a development environment."
echo "Create an admin user"
touch .venv/user_created
python teams_source/manage.py createsuperuser
else
echo "Super User already created"
fi
# Uncomment to collect static files
# echo "Collecting static files"
# python teams_source/manage.py collectstatic --noinput
ECHO Installing pre-commit hooks into `.git` for safer development
%uv_temporary_path% run pre-commit install
echo "Done"
echo "Run the web server with:"
echo "uv run .\teams_source\manage.py runserver"
echo "Please note that if this is your first time installing uv you may have to restart vscode"
echo "Alternatively, activate the virtual environment:"
echo ".\.venv\Scripts\activate"
echo "And then run the web server with:"
echo "python teams_source\manage.py runserver"
fi