Skip to content

Commit

Permalink
Add default distro packages for wheel builds
Browse files Browse the repository at this point in the history
There are some packages which absolutely must be there
for all wheel builds, or for installing without wheels.
Without them, pip is totally unable to compile the
package due to missing headers or tooling.

This patch adds a default, minimal, set of compilers
and python headers.

Rather than use include_vars, with_first_found as we
do in most other roles, we use vars/main and a dict
based on ansible_os_family. The role is often included
by other roles, and we'd rather not risk the search
path being incorrect (there are constant bugs related
to this in ansible). Using this mechanism takes away
the need for an include_vars task and avoids any pathing
issues.

Change-Id: I4ef11e47e4d3fe5adc65e9888e660a5a121d205b
  • Loading branch information
Jesse Pretorius committed Oct 31, 2018
1 parent d515b0d commit c54aa81
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions defaults/main.yml
Expand Up @@ -25,6 +25,10 @@
# Optional variables
#

# Distribution packages which must be installed
# on all hosts when building python wheels.
venv_build_base_distro_package_list: "{{ _venv_build_base_distro_package_list[ansible_os_family | lower] }}"

# Distribution packages which must be installed
# on the host for the purpose of building the
# python wheels.
Expand Down
2 changes: 1 addition & 1 deletion tasks/python_venv_install.yml
Expand Up @@ -20,7 +20,7 @@

- name: Install distro packages for venv build
package:
name: "{{ (venv_build_host != inventory_hostname) | ternary(venv_install_distro_package_list, venv_build_distro_package_list + venv_install_distro_package_list) }}"
name: "{{ (venv_build_host != inventory_hostname) | ternary(venv_install_distro_package_list, (venv_build_base_distro_package_list + venv_build_distro_package_list + venv_install_distro_package_list) | unique) }}"
state: "{{ venv_distro_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/python_venv_wheel_build.yml
Expand Up @@ -21,7 +21,7 @@
block:
- name: Install distro packages for wheel build
package:
name: "{{ venv_build_distro_package_list }}"
name: "{{ (venv_build_base_distro_package_list + venv_build_distro_package_list) | unique }}"
state: "{{ venv_distro_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}"
Expand Down
33 changes: 33 additions & 0 deletions vars/main.yml
@@ -0,0 +1,33 @@
---
# Copyright 2018, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_venv_build_base_distro_package_list:
debian:
- cmake
- gcc
- "{{ (venv_python_executable == 'python2') | ternary('pkg-config', 'python3-pkgconfig') }}"
- "{{ (venv_python_executable == 'python2') | ternary('python-dev', 'python3-dev') }}"
redhat:
- autoconf
- cmake
- gcc
- gcc-c++
- "{{ (venv_python_executable == 'python2') | ternary('python2-devel', 'python3-devel') }}"
suse:
- autoconf
- cmake
- gcc
- gcc-c++
- "{{ (venv_python_executable == 'python2') | ternary('python-devel', 'python3-devel') }}"

0 comments on commit c54aa81

Please sign in to comment.