|
3 | 3 | # See COPYRIGHT.txt, AUTHORS.txt, and LICENSE.txt in the project root directory. |
4 | 4 |
|
5 | 5 | # Upgrade/Deployment for Roundware Server (http://www.roundware.org/) |
6 | | -# Tested with Ubuntu 14.04 LTS 64 bit |
| 6 | +# Updated for Python 3.11 and Django 4.2 compatibility |
7 | 7 | # |
8 | 8 | # Use this to update production code. |
9 | 9 |
|
@@ -34,37 +34,60 @@ cp $SOURCE_PATH/files/home-user-profile /home/$USERNAME/.profile |
34 | 34 | # Set paths/directories |
35 | 35 | WWW_PATH="/var/www/roundware" |
36 | 36 | CODE_PATH="$WWW_PATH/source" |
37 | | -VENV_PATH="$WWW_PATH" |
| 37 | +VENV_PATH="/var/www/roundware-venv" # Updated: venv outside code directory |
38 | 38 |
|
39 | 39 | # Install/Update the production code |
40 | 40 | # TODO: Better deployment method. |
41 | 41 | rm -rf $CODE_PATH |
42 | 42 | mkdir -p $CODE_PATH |
43 | 43 | cp -R $SOURCE_PATH/. $CODE_PATH |
44 | 44 |
|
| 45 | +# Create or recreate virtual environment with Python 3.11 |
| 46 | +if [ -d "$VENV_PATH" ]; then |
| 47 | + echo "Removing existing virtual environment..." |
| 48 | + rm -rf $VENV_PATH |
| 49 | +fi |
| 50 | + |
| 51 | +echo "Creating new virtual environment with Python 3.11..." |
| 52 | +python3.11 -m venv $VENV_PATH |
| 53 | + |
45 | 54 | # Activate the environment |
46 | 55 | source $VENV_PATH/bin/activate |
47 | 56 |
|
| 57 | +# Verify Python version |
| 58 | +python --version |
| 59 | + |
48 | 60 | # Set python path to use production code |
49 | 61 | export PYTHONPATH=$CODE_PATH |
50 | 62 |
|
51 | 63 | # Install upgrade pip |
52 | 64 | python -m pip install -U pip wheel setuptools |
53 | 65 |
|
54 | | -# Install Roundware requirements |
55 | | -python -m pip install -r $CODE_PATH/requirements.txt --upgrade |
| 66 | +# Install Roundware requirements (updated path) |
| 67 | +if [ -f "$CODE_PATH/requirements/common.txt" ]; then |
| 68 | + echo "Installing from requirements/common.txt..." |
| 69 | + python -m pip install -r $CODE_PATH/requirements/common.txt --upgrade |
| 70 | +elif [ -f "$CODE_PATH/requirements.txt" ]; then |
| 71 | + echo "Installing from requirements.txt..." |
| 72 | + python -m pip install -r $CODE_PATH/requirements.txt --upgrade |
| 73 | +else |
| 74 | + echo "Error: No requirements file found!" |
| 75 | + exit 1 |
| 76 | +fi |
| 77 | + |
56 | 78 | if [ $ROUNDWARE_DEV ]; then |
57 | 79 | python -m pip install -r $CODE_PATH/requirements/dev.txt --upgrade |
58 | 80 | fi |
59 | 81 |
|
60 | 82 | # Set $USERNAME to own WWW_PATH files |
61 | 83 | chown $USERNAME:$USERNAME -R $WWW_PATH |
| 84 | +chown $USERNAME:$USERNAME -R $VENV_PATH |
62 | 85 |
|
63 | 86 | # Run database migrations |
64 | | -su - $USERNAME -c "$CODE_PATH/roundware/manage.py migrate --noinput" |
| 87 | +su - $USERNAME -c "$VENV_PATH/bin/python $CODE_PATH/roundware/manage.py migrate --noinput" |
65 | 88 |
|
66 | 89 | # Collect static files for production |
67 | | -su - $USERNAME -c "$CODE_PATH/roundware/manage.py collectstatic --noinput" |
| 90 | +su - $USERNAME -c "$VENV_PATH/bin/python $CODE_PATH/roundware/manage.py collectstatic --noinput" |
68 | 91 |
|
69 | 92 | systemctl restart apache2 |
70 | 93 |
|
|
0 commit comments