-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathmaster-pbgui-python312.yml
More file actions
127 lines (112 loc) · 4.22 KB
/
master-pbgui-python312.yml
File metadata and controls
127 lines (112 loc) · 4.22 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
# Create a new PBGui venv with Python 3.12 on localhost (Master)
# Steps:
# 1. Install python3.12-venv
# 2. Create a new python3.12 venv for PBGui (parallel to existing venv)
# 3. Install PBGui requirements for Python 3.12 (requirements.txt)
# Notes:
# - This playbook intentionally does NOT stop/restart Streamlit/PBGui.
# - Switch-over (symlink/rename + restart) should be done in a separate step.
- hosts: localhost
gather_facts: "{{ debug }}"
vars:
ansible_become_password: "{{ user_pw }}"
user_pw: "{{ user_pw }}"
# PBGui repo directory (required)
pbgdir: "{{ pbgdir }}"
# Target venv directory for Python 3.12 PBGui (new/parallel)
# NOTE:
# - must not reference itself (would cause recursive templating)
# - must not rely on gathered facts (gather_facts may be disabled)
# Can still be overridden via --extra-vars pbgvenv312=...
# Default: create venv next to the PBGui repo folder (matches setup/mig_py312.sh)
# Examples:
# - pbgdir=~/software/pbgui -> ~/software/venv_pbgui312
# - pbgdir=~/pbgui -> ~/venv_pbgui312
pbgvenv312: "{{ (pbgdir | dirname) }}/venv_pbgui312"
tasks:
- name: display facts
debug:
var: ansible_facts
tags: debug,never
- name: Detect OS + arch (for Ubuntu 20.04 x86_64 uv path)
shell: |
set -euo pipefail
. /etc/os-release
echo "${ID:-unknown} ${VERSION_ID:-unknown}"
uname -m
args:
executable: /bin/bash
register: os_arch
changed_when: false
- name: Set use_uv_python312 flag (Ubuntu 20.04 + x86_64)
set_fact:
use_uv_python312: >-
{{ (os_arch.stdout_lines[0].startswith('ubuntu 20.04'))
and (os_arch.stdout_lines[1] == 'x86_64') }}
uv_bin: "{{ lookup('env', 'HOME') }}/.local/bin/uv"
changed_when: false
- name: Install python3.12-venv
apt:
pkg:
- python3.12-venv
update_cache: yes
clean: yes
become: yes
when: not (use_uv_python312 | default(false))
- name: Install curl + ca-certificates for uv (Ubuntu 20.04 x86_64)
apt:
pkg:
- curl
- ca-certificates
update_cache: yes
clean: yes
become: yes
when: use_uv_python312 | default(false)
- name: Install uv (Ubuntu 20.04 x86_64)
shell: |
set -euo pipefail
curl -LsSf https://astral.sh/uv/install.sh | sh
args:
executable: /bin/bash
creates: "{{ uv_bin }}"
when: use_uv_python312 | default(false)
- name: Install Python 3.12 via uv (Ubuntu 20.04 x86_64)
shell: |
set -euo pipefail
"{{ uv_bin }}" python install 3.12
args:
executable: /bin/bash
register: uv_python_install
changed_when: uv_python_install.rc == 0 and (uv_python_install.stdout | default('')) != ''
when: use_uv_python312 | default(false)
- name: Create Python 3.12 venv for PBGui via uv (Ubuntu 20.04 x86_64)
shell: |
set -euo pipefail
"{{ uv_bin }}" venv --python 3.12 "{{ pbgvenv312 }}"
args:
executable: /bin/bash
creates: "{{ pbgvenv312 }}/bin/activate"
when: (use_uv_python312 | default(false)) and pbgdir != "" and pbgvenv312 != ""
- name: Ensure pip exists in uv venv (Ubuntu 20.04 x86_64)
shell: |
set -euo pipefail
"{{ pbgvenv312 }}/bin/python" -m ensurepip --upgrade
args:
executable: /bin/bash
when: (use_uv_python312 | default(false)) and pbgdir != "" and pbgvenv312 != ""
- name: Install PBGui requirements into uv venv (Ubuntu 20.04 x86_64)
shell: |
set -euo pipefail
"{{ pbgvenv312 }}/bin/python" -m pip install --upgrade pip
"{{ pbgvenv312 }}/bin/python" -m pip install -r "{{ pbgdir }}/requirements.txt"
args:
executable: /bin/bash
when: (use_uv_python312 | default(false)) and pbgdir != "" and pbgvenv312 != ""
- name: create python3.12 venv for PBGui
pip:
virtualenv_command: python3.12 -m venv
virtualenv: "{{ pbgvenv312 }}"
requirements: "{{ pbgdir }}/requirements.txt"
extra_args: --upgrade pip
when: (not (use_uv_python312 | default(false))) and pbgdir != "" and pbgvenv312 != ""