Skip to content

Commit b56cd27

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix python interpreter when installing in venv"
2 parents 4caf5f6 + 4d15891 commit b56cd27

File tree

1 file changed

+7
-3
lines changed
  • playbooks/roles/bifrost-pip-install/tasks

1 file changed

+7
-3
lines changed

playbooks/roles/bifrost-pip-install/tasks/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
# source installation if the package itself is in constraints.
3333
- not source_install | bool
3434

35+
- name: "Detect Python version in virtualenv"
36+
command: "{{ ansible_python_interpreter }} -c 'import sys; print(\".\".join(map(str, sys.version_info[:3])))'"
37+
register: ansible_python_interpreter_version
38+
3539
- name: "Install {{ package }} package from pip using virtualenv"
3640
pip:
3741
name: "{{ package }}"
@@ -45,7 +49,7 @@
4549
retries: "{{ pip_install_retries }}"
4650
delay: "{{ pip_install_delay }}"
4751
when: not source_install | bool
48-
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_facts.python_version is version('3.12', '<') else bifrost_venv_env }}"
52+
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_python_interpreter_version.stdout is version('3.12', '<') else bifrost_venv_env }}"
4953

5054
- name: "Install requirements from {{ sourcedir }} using pip"
5155
pip:
@@ -56,7 +60,7 @@
5660
retries: 5
5761
delay: 10
5862
when: source_install | bool
59-
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_facts.python_version is version('3.12', '<') else bifrost_venv_env }}"
63+
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_python_interpreter_version.stdout is version('3.12', '<') else bifrost_venv_env }}"
6064

6165
# NOTE(dtantsur): do not use constraints here, it does not work when the
6266
# package itself is constrained.
@@ -66,4 +70,4 @@
6670
editable: "{{ developer_mode | bool }}"
6771
extra_args: "{{ extra_args }}"
6872
when: source_install | bool
69-
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_facts.python_version is version('3.12', '<') else bifrost_venv_env }}"
73+
environment: "{{ (bifrost_venv_env | combine({'SETUPTOOLS_USE_DISTUTILS': 'stdlib'})) if ansible_python_interpreter_version.stdout is version('3.12', '<') else bifrost_venv_env }}"

0 commit comments

Comments
 (0)