7a58814cda
We have support for installing python from pyenv, but it currently requires setting the python version explicitly as an argument. If the repo in question has a .python-version file, we shouldn't need to require the user to provide that version a second time. Instead, we can read from the file for the install step. Change-Id: Ic4c2d3fc7f55169cec5211010fc3a9622fa324d1
47 lines
1.7 KiB
YAML
47 lines
1.7 KiB
YAML
- name: Include OS-specific variables
|
|
include_vars: "{{ zj_distro_os }}"
|
|
loop_control:
|
|
loop_var: zj_distro_os
|
|
with_first_found:
|
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
|
|
- "{{ ansible_distribution }}.{{ ansible_architecture }}.yaml"
|
|
- "{{ ansible_distribution }}.yaml"
|
|
- "{{ ansible_os_family }}.yaml"
|
|
|
|
- name: Put .python-version contents into variable
|
|
when:
|
|
- python_version is not defined
|
|
set_fact:
|
|
python_version: "{{ lookup('ansible.builtin.file', zuul.executor.work_root ~ '/' ~ zuul.project.src_dir ~ '/.python-version') }}"
|
|
|
|
- name: Install python build depends
|
|
become: true
|
|
package:
|
|
name: "{{ python_build_depends }}"
|
|
|
|
- name: Clone pyenv repo
|
|
git:
|
|
repo: https://github.com/pyenv/pyenv.git
|
|
dest: "{{ ansible_user_dir }}/.pyenv"
|
|
version: master
|
|
|
|
# NOTE(mnaser): python-build does not allow us to let it install Python from a specific
|
|
# series so we have to do some magic to find out what's the latest
|
|
# release from a series
|
|
- name: Determine Python version
|
|
shell: |
|
|
set -o pipefail
|
|
{{ ansible_user_dir }}/.pyenv/plugins/python-build/bin/python-build --definitions | grep ^{{ python_version }} | tail -1
|
|
args:
|
|
executable: /bin/bash
|
|
register: _python_version
|
|
|
|
# NOTE(mnaser): We install Python globally in the system, as that's somewhat
|
|
# similar to behaviour of installing a Python package. It also
|
|
# avoids us having to mess around $PATH.
|
|
- name: Install python
|
|
become: true
|
|
command: "{{ ansible_user_dir }}/.pyenv/plugins/python-build/bin/python-build {{ _python_version.stdout }} /usr/local"
|
|
environment:
|
|
CFLAGS: -O2
|