diff --git a/deployment/ansible/playbooks/codeGrader_install_backend.yml b/deployment/ansible/playbooks/codeGrader_install_backend.yml index 0f02ba9..9c1145b 100644 --- a/deployment/ansible/playbooks/codeGrader_install_backend.yml +++ b/deployment/ansible/playbooks/codeGrader_install_backend.yml @@ -35,13 +35,16 @@ - libpq-dev - pip - git + - python3.11-venv state: present - - - name: Recursively remove directory for python venvs + + - name: Recursively remove directory /opt/CodeGrader_venv ansible.builtin.file: - path: /usr/lib/python3.11/EXTERNALLY-MANAGED + path: /opt/CodeGrader_venv state: absent - force: true + + - name: Create python venv for CodeGrader + shell: python3 -m venv /opt/CodeGrader_venv - name: Recursively remove directory /opt/CodeGrader ansible.builtin.file: @@ -57,6 +60,7 @@ - name: Install CodeGrader Backend requirements ansible.builtin.pip: requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt + virtualenv: /opt/CodeGrader_venv/ - name: Rename the setup Script shell: mv setup_backend.py setup.py @@ -64,6 +68,6 @@ chdir: /opt/CodeGrader - name: Install the CodeGrader Application Backend - shell: pip install . + shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install . args: chdir: /opt/CodeGrader diff --git a/deployment/ansible/playbooks/codeGrader_install_frontend.yml b/deployment/ansible/playbooks/codeGrader_install_frontend.yml index f601a41..f10ce84 100644 --- a/deployment/ansible/playbooks/codeGrader_install_frontend.yml +++ b/deployment/ansible/playbooks/codeGrader_install_frontend.yml @@ -40,13 +40,16 @@ - libpq-dev - pip - git + - python3.11-venv state: present - - - name: Recursively remove directory for python venvs + + - name: Recursively remove directory /opt/CodeGrader_venv ansible.builtin.file: - path: /usr/lib/python3.11/EXTERNALLY-MANAGED + path: /opt/CodeGrader_venv state: absent - force: true + + - name: Create python venv for CodeGrader + shell: python3 -m venv /opt/CodeGrader_venv - name: Recursively remove directory /opt/CodeGrader ansible.builtin.file: @@ -62,6 +65,7 @@ - name: Install CodeGrader Frontend requirements ansible.builtin.pip: requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt + virtualenv: /opt/CodeGrader_venv/ - name: Rename the setup Script shell: mv setup_frontend.py setup.py @@ -69,6 +73,6 @@ chdir: /opt/CodeGrader - name: Install the CodeGrader Application Frontend - shell: pip install . + shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install . args: chdir: /opt/CodeGrader diff --git a/deployment/ansible/playbooks/codeGrader_install_full.yml b/deployment/ansible/playbooks/codeGrader_install_full.yml index f7e424b..111faf5 100644 --- a/deployment/ansible/playbooks/codeGrader_install_full.yml +++ b/deployment/ansible/playbooks/codeGrader_install_full.yml @@ -36,12 +36,14 @@ - pip - git state: present - - - name: Recursively remove directory for python venvs + + - name: Recursively remove directory /opt/CodeGrader_venv ansible.builtin.file: - path: /usr/lib/python3.11/EXTERNALLY-MANAGED + path: /opt/CodeGrader_venv state: absent - force: true + + - name: Create python venv for CodeGrader + shell: python3 -m venv /opt/CodeGrader_venv - name: Recursively remove directory /opt/CodeGrader ansible.builtin.file: @@ -57,10 +59,12 @@ - name: Install CodeGrader Backend requirements ansible.builtin.pip: requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt + virtualenv: /opt/CodeGrader_venv/ - name: Install CodeGrader Frontend requirements ansible.builtin.pip: requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt + virtualenv: /opt/CodeGrader_venv/ - name: Rename the setup Script shell: mv setup_full.py setup.py @@ -68,6 +72,6 @@ chdir: /opt/CodeGrader - name: Install the CodeGrader Application Frontend and Backend - shell: pip install . + shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install . args: chdir: /opt/CodeGrader diff --git a/doc/Installation.md b/doc/Installation.md index b3dcce2..eb0d255 100644 --- a/doc/Installation.md +++ b/doc/Installation.md @@ -50,20 +50,29 @@ exit ``` Then proceed with to clone and install the software itself. +For running everything in a Virtual Python environment run: +``` +apt-get install python3-venv +python3 -m venv /opt/CodeGrader_venv/ +``` + ``` cd /opt rm -r /opt/CodeGrader git clone https://github.com/ooemperor/CodeGrader.git cd CodeGrader -pip install -r ./codeGrader/frontend/requirements.txt -pip install -r ./codeGrader/backend/requirements.txt +/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/frontend/requirements.txt +/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/backend/requirements.txt cd /opt/CodeGrader mv setup_full.py setup.py -pip install . +/opt/CodeGrader_venv/bin/python3.11 -m pip install . ``` -If you are running some Version of python higher than 3.9, it could be that there is an Error about Externally Managed python. -You can resolve this by running: +Everything that you run from right now on, that are scripts such as ```cgAddAdmin``` needs to be run from the python venv +with ```/opt/CodeGrader_venv/bin/cgAddAdmin```. This ensures proper execution within the Virtual Environment. + +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. +You can resolve this by running (not recommended): ``` rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED ``` diff --git a/services/cgAdminFrontend.service b/services/cgAdminFrontend.service index 8b5013d..f35627e 100644 --- a/services/cgAdminFrontend.service +++ b/services/cgAdminFrontend.service @@ -5,7 +5,7 @@ After=network.target [Service] User=root WorkingDirectory=/ -ExecStart=nohup /opt/CodeGrader_venv/bin/cgAdminFrontend > /var/log/cgAdminFrontend.log & +ExecStart=/opt/CodeGrader_venv/bin/cgAdminFrontend # optional items below Restart=always RestartSec=3 diff --git a/services/cgApiBackend.service b/services/cgApiBackend.service index b8fda5c..dab6eb3 100644 --- a/services/cgApiBackend.service +++ b/services/cgApiBackend.service @@ -5,7 +5,7 @@ After=network.target [Service] User=root WorkingDirectory=/ -ExecStart=nohup /opt/CodeGrader_venv/bin/cgApiBackend > /var/log/cgApiBackend.log & +ExecStart=/opt/CodeGrader_venv/bin/cgApiBackend # optional items below Restart=always RestartSec=3 diff --git a/services/cgEvaluationService.service b/services/cgEvaluationService.service index e28bd99..cf69126 100644 --- a/services/cgEvaluationService.service +++ b/services/cgEvaluationService.service @@ -5,7 +5,7 @@ After=network.target [Service] User=root WorkingDirectory=/ -ExecStart=nohup /opt/CodeGrader_venv/bin/cgEvaluationService > /var/log/cgEvaluationService.log & +ExecStart=/opt/CodeGrader_venv/bin/cgEvaluationService # optional items below Restart=always RestartSec=3 diff --git a/services/cgExecutionService.service b/services/cgExecutionService.service index 60149f2..7d92b57 100644 --- a/services/cgExecutionService.service +++ b/services/cgExecutionService.service @@ -5,7 +5,7 @@ After=network.target [Service] User=root WorkingDirectory=/ -ExecStart=nohup /opt/CodeGrader_venv/bin/cgExecutionService > /var/log/cgExecutionService.log & +ExecStart=/opt/CodeGrader_venv/bin/cgExecutionService # optional items below Restart=always RestartSec=3 diff --git a/services/cgUserFrontend.service b/services/cgUserFrontend.service index a143868..f228c74 100644 --- a/services/cgUserFrontend.service +++ b/services/cgUserFrontend.service @@ -5,7 +5,7 @@ After=network.target [Service] User=root WorkingDirectory=/ -ExecStart=nohup /opt/CodeGrader_venv/bin/cgUserFrontend > /var/log/cgUserFrontend.log & +ExecStart=/opt/CodeGrader_venv/bin/cgUserFrontend # optional items below Restart=always RestartSec=3