Skip to content

Commit 2a44f18

Browse files
authored
Merge pull request #52 from ooemperor/dev
Using Python venv, updating documentation for python venv and updating service files for using journalctl
2 parents ca51569 + eac7b36 commit 2a44f18

9 files changed

+46
-25
lines changed

deployment/ansible/playbooks/codeGrader_install_backend.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@
3535
- libpq-dev
3636
- pip
3737
- git
38+
- python3.11-venv
3839
state: present
39-
40-
- name: Recursively remove directory for python venvs
40+
41+
- name: Recursively remove directory /opt/CodeGrader_venv
4142
ansible.builtin.file:
42-
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
43+
path: /opt/CodeGrader_venv
4344
state: absent
44-
force: true
45+
46+
- name: Create python venv for CodeGrader
47+
shell: python3 -m venv /opt/CodeGrader_venv
4548

4649
- name: Recursively remove directory /opt/CodeGrader
4750
ansible.builtin.file:
@@ -57,13 +60,14 @@
5760
- name: Install CodeGrader Backend requirements
5861
ansible.builtin.pip:
5962
requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt
63+
virtualenv: /opt/CodeGrader_venv/
6064

6165
- name: Rename the setup Script
6266
shell: mv setup_backend.py setup.py
6367
args:
6468
chdir: /opt/CodeGrader
6569

6670
- name: Install the CodeGrader Application Backend
67-
shell: pip install .
71+
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
6872
args:
6973
chdir: /opt/CodeGrader

deployment/ansible/playbooks/codeGrader_install_frontend.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@
4040
- libpq-dev
4141
- pip
4242
- git
43+
- python3.11-venv
4344
state: present
44-
45-
- name: Recursively remove directory for python venvs
45+
46+
- name: Recursively remove directory /opt/CodeGrader_venv
4647
ansible.builtin.file:
47-
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
48+
path: /opt/CodeGrader_venv
4849
state: absent
49-
force: true
50+
51+
- name: Create python venv for CodeGrader
52+
shell: python3 -m venv /opt/CodeGrader_venv
5053

5154
- name: Recursively remove directory /opt/CodeGrader
5255
ansible.builtin.file:
@@ -62,13 +65,14 @@
6265
- name: Install CodeGrader Frontend requirements
6366
ansible.builtin.pip:
6467
requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt
68+
virtualenv: /opt/CodeGrader_venv/
6569

6670
- name: Rename the setup Script
6771
shell: mv setup_frontend.py setup.py
6872
args:
6973
chdir: /opt/CodeGrader
7074

7175
- name: Install the CodeGrader Application Frontend
72-
shell: pip install .
76+
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
7377
args:
7478
chdir: /opt/CodeGrader

deployment/ansible/playbooks/codeGrader_install_full.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
- pip
3737
- git
3838
state: present
39-
40-
- name: Recursively remove directory for python venvs
39+
40+
- name: Recursively remove directory /opt/CodeGrader_venv
4141
ansible.builtin.file:
42-
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
42+
path: /opt/CodeGrader_venv
4343
state: absent
44-
force: true
44+
45+
- name: Create python venv for CodeGrader
46+
shell: python3 -m venv /opt/CodeGrader_venv
4547

4648
- name: Recursively remove directory /opt/CodeGrader
4749
ansible.builtin.file:
@@ -57,17 +59,19 @@
5759
- name: Install CodeGrader Backend requirements
5860
ansible.builtin.pip:
5961
requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt
62+
virtualenv: /opt/CodeGrader_venv/
6063

6164
- name: Install CodeGrader Frontend requirements
6265
ansible.builtin.pip:
6366
requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt
67+
virtualenv: /opt/CodeGrader_venv/
6468

6569
- name: Rename the setup Script
6670
shell: mv setup_full.py setup.py
6771
args:
6872
chdir: /opt/CodeGrader
6973

7074
- name: Install the CodeGrader Application Frontend and Backend
71-
shell: pip install .
75+
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
7276
args:
7377
chdir: /opt/CodeGrader

doc/Installation.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,29 @@ exit
5050
```
5151
Then proceed with to clone and install the software itself.
5252

53+
For running everything in a Virtual Python environment run:
54+
```
55+
apt-get install python3-venv
56+
python3 -m venv /opt/CodeGrader_venv/
57+
```
58+
5359
```
5460
cd /opt
5561
rm -r /opt/CodeGrader
5662
git clone https://github.com/ooemperor/CodeGrader.git
5763
cd CodeGrader
58-
pip install -r ./codeGrader/frontend/requirements.txt
59-
pip install -r ./codeGrader/backend/requirements.txt
64+
/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/frontend/requirements.txt
65+
/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/backend/requirements.txt
6066
cd /opt/CodeGrader
6167
mv setup_full.py setup.py
62-
pip install .
68+
/opt/CodeGrader_venv/bin/python3.11 -m pip install .
6369
```
6470

65-
If you are running some Version of python higher than 3.9, it could be that there is an Error about Externally Managed python.
66-
You can resolve this by running:
71+
Everything that you run from right now on, that are scripts such as ```cgAddAdmin``` needs to be run from the python venv
72+
with ```/opt/CodeGrader_venv/bin/cgAddAdmin```. This ensures proper execution within the Virtual Environment.
73+
74+
If you are running some Version of python higher than 3.9 without Virtual Environment, it could be that there is an Error about Externally Managed python.
75+
You can resolve this by running (not recommended):
6776
```
6877
rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
6978
```

services/cgAdminFrontend.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User=root
77
WorkingDirectory=/
8-
ExecStart=nohup /opt/CodeGrader_venv/bin/cgAdminFrontend > /var/log/cgAdminFrontend.log &
8+
ExecStart=/opt/CodeGrader_venv/bin/cgAdminFrontend
99
# optional items below
1010
Restart=always
1111
RestartSec=3

services/cgApiBackend.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User=root
77
WorkingDirectory=/
8-
ExecStart=nohup /opt/CodeGrader_venv/bin/cgApiBackend > /var/log/cgApiBackend.log &
8+
ExecStart=/opt/CodeGrader_venv/bin/cgApiBackend
99
# optional items below
1010
Restart=always
1111
RestartSec=3

services/cgEvaluationService.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User=root
77
WorkingDirectory=/
8-
ExecStart=nohup /opt/CodeGrader_venv/bin/cgEvaluationService > /var/log/cgEvaluationService.log &
8+
ExecStart=/opt/CodeGrader_venv/bin/cgEvaluationService
99
# optional items below
1010
Restart=always
1111
RestartSec=3

services/cgExecutionService.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User=root
77
WorkingDirectory=/
8-
ExecStart=nohup /opt/CodeGrader_venv/bin/cgExecutionService > /var/log/cgExecutionService.log &
8+
ExecStart=/opt/CodeGrader_venv/bin/cgExecutionService
99
# optional items below
1010
Restart=always
1111
RestartSec=3

services/cgUserFrontend.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User=root
77
WorkingDirectory=/
8-
ExecStart=nohup /opt/CodeGrader_venv/bin/cgUserFrontend > /var/log/cgUserFrontend.log &
8+
ExecStart=/opt/CodeGrader_venv/bin/cgUserFrontend
99
# optional items below
1010
Restart=always
1111
RestartSec=3

0 commit comments

Comments
 (0)