Skip to content

Commit

Permalink
Fix Python virtualenvs
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Nov 28, 2024
1 parent e6dce8f commit 393b877
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 18 deletions.
1 change: 0 additions & 1 deletion roles/python3/tasks/install-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
- python3-dev
- python3-pip
- python3-venv
- python3-virtualenv
- python3-wheel
state: present
16 changes: 12 additions & 4 deletions roles/yoda_external_user_service/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,30 @@
notify: Restart Apache webserver


- name: Ensure Yoda EUS virtualenv exists
- name: Ensure Yoda EUS venv exists
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.command: "{{ yoda_external_user_service_python3_path }} -m venv /var/www/extuser/yoda-external-user-service/venv"
args:
creates: "/var/www/extuser/yoda-external-user-service/venv"
creates: "/var/www/extuser/yoda-external-user-service/venv/bin/activate_this.py"


- name: Upgrade pip in EUS virtual environment
- name: Upgrade pip and virtualenv in Yoda EUS virtual environment
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.pip:
name:
- pip==24.3.1
- virtualenv==20.28.0
executable: /var/www/extuser/yoda-external-user-service/venv/bin/pip3
when: not ansible_check_mode


- name: Ensure Yoda EUS virtualenv exists
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.command: "/var/www/extuser/yoda-external-user-service/venv/bin/python3 -m virtualenv /var/www/extuser/yoda-external-user-service/venv"
args:
creates: "/var/www/extuser/yoda-external-user-service/venv/bin/activate_this.py"


# Change detection in git repositories is unreliable in some Ansible versions, so we always
Expand Down
2 changes: 1 addition & 1 deletion roles/yoda_external_user_service/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ openssl_private_dir: '/etc/ssl/private/'
openssl_certs_dir: '/etc/ssl/certs'

yoda_external_user_service_python3_path: /usr/bin/python3
yoda_external_user_service_python3_include_path: /usr/include/python3.8
yoda_external_user_service_python3_include_path: /usr/include/python3.12
yoda_external_user_service_site_config_dir: /etc/apache2/sites-available
yoda_external_user_service_site_enabled_config_dir: /etc/apache2/sites-enabled
yoda_external_user_service_site_config_file: 003-yoda-eus-vhost.conf
Expand Down
15 changes: 12 additions & 3 deletions roles/yoda_moai/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,32 @@
register: repochanges


- name: Ensure Yoda MOAI virtualenv exists
- name: Ensure Yoda MOAI venv exists
become_user: '{{ yoda_moai_user }}'
become: true
ansible.builtin.command: "{{ yoda_moai_python3_path }} -m venv {{ yoda_moai_home }}/yoda-moai/venv"
args:
creates: "{{ yoda_moai_home }}/yoda-moai/venv"
creates: "{{ yoda_moai_home }}/yoda-moai/venv/bin/activate_this.py"


- name: Upgrade pip in virtual environment
- name: Upgrade pip and virtualenv in Yoda MOAI environment
become_user: '{{ yoda_moai_user }}'
become: true
ansible.builtin.pip:
name:
- pip==24.3.1
- virtualenv==20.28.0
executable: /var/www/moai/yoda-moai/venv/bin/pip3


- name: Ensure Yoda MOAI virtualenv exists
become_user: '{{ yoda_moai_user }}'
become: true
ansible.builtin.command: "{{ yoda_moai_home }}/yoda-moai/venv/bin/python3 -m virtualenv {{ yoda_moai_home }}/yoda-moai/venv"
args:
creates: "{{ yoda_moai_home }}/yoda-moai/venv/bin/activate_this.py"


# We use the PySqlite3 dialect to avoid compatibility issues between SQLAlchemy
# and the old SQlite version bundled with CentOS 7
- name: Ensure PySQLite3 is installed in MOAI virtual environment
Expand Down
4 changes: 0 additions & 4 deletions roles/yoda_moai/templates/moai.wsgi.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import configparser
import os
import sys

activate_this = '/var/www/moai/yoda-moai/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))

from paste.deploy import loadapp
from logging.config import fileConfig

Expand Down
2 changes: 1 addition & 1 deletion roles/yoda_moai/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ openssl_private_dir: '/etc/ssl/private/'
openssl_certs_dir: '/etc/ssl/certs'

yoda_moai_python3_path: /usr/bin/python3
yoda_moai_python3_include_path: /usr/include/python3.8
yoda_moai_python3_include_path: /usr/include/python3.12

yoda_moai_sqlite3_include_path: /usr/include
yoda_moai_sqlite3_lib_path: /usr/lib/x86_64-linux-gnu
Expand Down
15 changes: 12 additions & 3 deletions roles/yoda_web_mock/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,33 @@
force: true


- name: Ensure Yoda web mock virtualenv exists
- name: Ensure Yoda web mock venv exists
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.command: "{{ yoda_web_mock_python3_path }} -m venv /var/www/webmock/venv"
ansible.builtin.command: "python3 -m venv /var/www/webmock/venv"
args:
creates: "/var/www/webmock/venv"


- name: Upgrade pip in Yoda web mock environment
- name: Upgrade pip and virtualenv in Yoda web mock environment
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.pip:
name:
- pip==24.3.1
- virtualenv==20.28.0
executable: /var/www/webmock/venv/bin/pip3
when: not ansible_check_mode


- name: Ensure Yoda web mock virtualenv exists
become_user: '{{ yoda_deployment_user }}'
become: true
ansible.builtin.command: "{{ yoda_web_mock_python3_path }} -m virtualenv /var/www/webmock/venv"
args:
creates: "/var/www/webmock/venv/bin/activate_this.py"


# Change detection in git repositories is unreliable in some Ansible versions, so we always
# run this task, just to be sure.
- name: Ensure Yoda web mock dependencies are installed
Expand Down
2 changes: 1 addition & 1 deletion roles/yoda_web_mock/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# copyright Utrecht University

yoda_web_mock_python3_path: /usr/bin/python3
yoda_web_mock_python3_path: /var/www/webmock/venv/bin/python3

0 comments on commit 393b877

Please sign in to comment.