Skip to content

Commit e68c077

Browse files
authored
✨ NEW: Add python_install_dev option (#8)
1 parent b3049fb commit e68c077

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ See `defaults/main.yml`
2727
roles:
2828
- role: marvel-nccr.python
2929
vars:
30+
python_base_version: "3.7"
31+
python_install_dev: true
3032
python_venv_path: "/tmp/my_venv"
3133
python_venv_packages:
3234
- pip
@@ -35,6 +37,11 @@ See `defaults/main.yml`
3537
python_venv_state: latest
3638
```
3739
40+
## Known Issues
41+
42+
- Python 3.7 is not available on CentOS 8
43+
- `python_install_dev` and `python_install_tk` will not work for Fedora 31 if no Python 3.7 (`python3-devel` and `python3-tkinter` will be installed, which only work for the default python 3.7 version)
44+
3845
## Development and testing
3946

4047
This role uses [Molecule](https://molecule.readthedocs.io/en/latest/#) and [Docker](https://www.docker.com/) for tests.

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
root_user: "root"
22
python_base_version: "3.7"
3+
python_install_dev: false # install libraries and header files needed for Python development
4+
35
python_venv_path:
46
python_venv_state: latest
57
python_venv_packages:

molecule/default/molecule.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ provisioner:
3333
vars:
3434
ansible_python_interpreter: /usr/bin/python3
3535
python_base_version: "${MOLECULE_PYTHON_VERSION:-3.7}"
36-
python_venv_path: /tmp/test_venv
36+
python_install_dev: true
3737
python_install_tk: true
38+
python_venv_path: /tmp/test_venv
3839
run_tests: true

tasks/setup-debian.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@
2323
# and for the version of Python specified by this option.
2424
- python3-setuptools
2525
- python{{ python_base_version }}
26-
- python{{ python_base_version }}-dev
2726
- python{{ python_base_version }}-venv
2827
- wget
2928

30-
- name: Install distutils
29+
- name: Install python{{ python_base_version }}-dev
30+
when: python_install_dev|bool
31+
become: true
32+
become_user: "{{ root_user }}"
33+
apt:
34+
name:
35+
- python{{ python_base_version }}-dev
36+
37+
- name: Install python{{ python_base_version }}-distutils
38+
# this is only separate for 18.04
3139
when: ansible_distribution_major_version|int == 18
3240
become: true
3341
become_user: "{{ root_user }}"

tasks/setup-redhat.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,39 @@
44
yum:
55
update_cache: true
66
name:
7-
- python{{ python_base_version | replace('.', '') }}
7+
- python{{ python_base_version | replace('.', '') }} # note this also installs venv
88
- wget
99

10+
- name: install development headers
11+
when: python_install_dev|bool
12+
block:
13+
- name: Install python{{ python_base_version }} development headers
14+
become: true
15+
become_user: "{{ root_user }}"
16+
yum:
17+
name:
18+
- python{{ python_base_version | replace('.', '') }}-devel
19+
rescue:
20+
- name: Install python3 development headers (fallback)
21+
become: true
22+
become_user: "{{ root_user }}"
23+
yum:
24+
name:
25+
- python3-devel # TODO fedora yum does not have python3x-devel available by default
26+
1027
- name: install tkinter
1128
when: python_install_tk|bool
1229
block:
13-
- name: Install Tk GUI toolkit for python{{ python_base_version | replace('.', '') }}
30+
- name: Install Tk GUI toolkit for python{{ python_base_version }}
1431
become: true
1532
become_user: "{{ root_user }}"
1633
yum:
1734
name:
18-
- python{{ python_base_version | replace('.', '') }}-tkinter # TODO this may not be correct
35+
- python{{ python_base_version | replace('.', '') }}-tkinter
1936
rescue:
2037
- name: Install Tk GUI toolkit for python3 (fallback)
2138
become: true
2239
become_user: "{{ root_user }}"
2340
yum:
2441
name:
25-
- python3-tkinter
42+
- python3-tkinter # TODO fedora yum does not have python3x-devel available by default

0 commit comments

Comments
 (0)