Improve python version detection when symlinking libraries

The previous code assumed that the major version ('python3') could be
obtained by removing the last two characters from 'python3.X. This
does not work for pyhton releases 3.10 and onward, so this patch
changes the code to split the string on '.' and take the first portion.

Change-Id: I771cac2fc9badb61c22cfde65775aee97c31f89c
This commit is contained in:
Jonathan Rosser 2022-04-21 07:52:16 +01:00
parent 908e3ac7b1
commit 43d785eff2
1 changed files with 1 additions and 1 deletions

View File

@ -23,7 +23,7 @@
- name: Search for lib files to link
vars:
_venv_python_major_version: "{{ (_python_venv_details.files[0].path | basename)[:-2] }}"
_venv_python_major_version: "{{ (_python_venv_details.files[0].path | basename | split('.') )[0] }}"
shell: >-
{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('dpkg -L ' ~ (venv_packages_to_symlink | join(' ')), 'rpm -ql ' ~ (venv_packages_to_symlink | join(' ')) ) }}
| egrep '^.*{{ _venv_python_major_version }}.*/(site|dist)-packages/.*'