Add tasks to build python

This commit is contained in:
Sonny Bakker 2022-10-10 10:50:08 +02:00
parent 82c346506d
commit 092b78cce6
3 changed files with 78 additions and 2 deletions

View file

@ -21,11 +21,14 @@
- import_tasks: 'tasks/main.yml' - import_tasks: 'tasks/main.yml'
- import_tasks: 'tasks/dotfiles.yml' - import_tasks: 'tasks/dotfiles.yml'
- import_tasks: 'tasks/neovim.yml' - import_tasks: 'tasks/neovim.yml'
- name: gather the package facts - name: gather package facts
package_facts: package_facts:
manager: pacman manager: pacman
- import_tasks: 'tasks/aur.yml' - import_tasks: 'tasks/aur.yml'
when: aur_packages|map(attribute='package_name')|list is not subset(ansible_facts.packages) when: aur_packages|map(attribute='package_name')|list is not subset(ansible_facts.packages)
- import_tasks: 'tasks/docker.yml' - import_tasks: 'tasks/docker.yml'
- name: setup python versions
include_tasks: 'tasks/python.yml'
loop: '{{ python_versions }}'
vars_files: vars_files:
- 'vars.yml' - 'vars.yml'

65
tasks/python.yml Normal file
View file

@ -0,0 +1,65 @@
- name: 'check for {{ item.binary }} binary'
command: 'which {{ item.binary }}'
changed_when: false
failed_when: python_installed.rc not in [ 0, 1 ]
register: python_installed
- name: 'check for {{ item.binary }} download'
stat:
path: '{{ python_build_dir }}/python-{{ item.version }}.tgz'
register: python_download
- block:
# TODO: verify for checksum
- name: 'retrieve python {{ item.version }} source'
become: true
get_url:
url: '{{ python_download_url }}/{{ item.version }}/Python-{{ item.version }}.tgz'
dest: '{{ python_build_dir }}/python-{{ item.version }}.tgz'
owner: '{{ ansible_user_id }}'
group: '{{ ansible_user_id }}'
when: not python_download.stat.exists
- name: 'extract python {{ item.version }} sources'
become: true
unarchive:
src: '{{ python_build_dir }}/python-{{ item.version }}.tgz'
dest: '{{ python_build_dir }}'
include: 'Python-{{ item.version }}'
- name: rename source directory
become: true
ansible.builtin.command: 'mv {{ python_build_dir}}/Python-{{ item.version }} {{ python_build_dir }}/{{ item.path }}'
- name: set correct permissions
become: true
file:
path: '{{ python_build_dir }}/{{ item.path }}'
recurse: true
owner: '{{ ansible_user_id }}'
group: '{{ ansible_user_id }}'
state: directory
- name: configure build
ansible.builtin.command: 'sh ./configure --prefix={{ python_install_dir }}/{{ item.path }}'
args:
chdir: '{{ python_build_dir }}/{{ item.path }}/'
- name: make build
ansible.builtin.command: 'make'
args:
chdir: '{{ python_build_dir }}/{{ item.path }}/'
- name: install build
become: true
ansible.builtin.command: 'make install'
args:
chdir: '{{ python_build_dir }}/{{ item.path }}/'
- name: 'create symlink for python {{ item.version }}'
become: true
file:
src: '{{ python_install_dir }}/{{ item.path }}/bin/{{ item.binary }}'
dest: '/usr/bin/{{ item.binary }}'
state: link
when: python_installed.rc not in [ 0 ]

View file

@ -2,7 +2,6 @@ ansible_connection: local
ansible_python_interpreter: '/usr/bin/env python' ansible_python_interpreter: '/usr/bin/env python'
packages: packages:
- base-devel
- python - python
- git - git
- vim - vim
@ -29,6 +28,8 @@ aur_packages:
} }
aur_build_dir: '/usr/local/src' aur_build_dir: '/usr/local/src'
python_build_dir: '/usr/local/src'
python_install_dir: '/opt'
xdg_config_dir: '{{ ansible_env.HOME }}/.config' xdg_config_dir: '{{ ansible_env.HOME }}/.config'
xdg_data_dir: '{{ ansible_env.HOME }}/.local/share' xdg_data_dir: '{{ ansible_env.HOME }}/.local/share'
@ -68,5 +69,12 @@ language_servers:
- vscode-langservers-extracted - vscode-langservers-extracted
- typescript-language-server - typescript-language-server
python_download_url: 'https://www.python.org/ftp/python'
python_versions:
- { version: 3.9.14, path: 'python3.9', binary: 'python3.9' }
- { version: 3.8.14, path: 'python3.8', binary: 'python3.8' }
- { version: 3.7.14, path: 'python3.7', binary: 'python3.7' }
- { version: 3.6.15, path: 'python3.6', binary: 'python3.6' }
gitlab_domain: 'git.fudiggity.nl' gitlab_domain: 'git.fudiggity.nl'
gitlab_host_key: 'git.fudiggity.nl ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNmvcxza79T7JZMkifmquwXH/kMUqDnKs9Oob+JrRvn' gitlab_host_key: 'git.fudiggity.nl ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNmvcxza79T7JZMkifmquwXH/kMUqDnKs9Oob+JrRvn'