Skip to content

Commit

Permalink
Merge pull request #59 from cisagov/bugfix/fix-broken-python2-builds
Browse files Browse the repository at this point in the history
Add `--break-system-packages` to shady `pip` commands if supported
  • Loading branch information
jsf9k authored Sep 20, 2024
2 parents 0e880a3 + b6dc22e commit 8ba4778
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ jobs:
scenario: python2
- platform: debian13-systemd
scenario: python2
# Kali cannot build the wheels for HarmJ0y/ImpDump on ARM64.
- architecture: arm64
platform: kali-systemd
scenario: python2
# Ubuntu Noble does not offer Python 2.
- platform: ubuntu-24-systemd
scenario: python2
Expand Down
19 changes: 10 additions & 9 deletions molecule/python2/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@ platforms:
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- cgroupns_mode: host
command: /lib/systemd/systemd
image: docker.io/cisagov/docker-kali-ansible:latest
name: kali-systemd-arm64
platform: arm64
pre_build_image: true
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
# Kali cannot build the wheels for HarmJ0y/ImpDump on ARM64.
# - cgroupns_mode: host
# command: /lib/systemd/systemd
# image: docker.io/cisagov/docker-kali-ansible:latest
# name: kali-systemd-arm64
# platform: arm64
# pre_build_image: true
# privileged: true
# volumes:
# - /sys/fs/cgroup:/sys/fs/cgroup:rw
# This Ansible role only supports Debian-based platforms for now.
# - cgroupns_mode: host
# command: /lib/systemd/systemd
Expand Down
9 changes: 9 additions & 0 deletions tasks/create_python_venv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
- virtualenv
when: not assessment_tool_python2

- name: Set pip_break_system_packages if necessary
ansible.builtin.set_fact:
pip_break_system_packages: --break-system-packages
when:
- ansible_distribution in ["Debian", "Kali", "Ubuntu"]
- ansible_distribution_release not in ["bullseye", "buster", "focal", "jammy"]

# The shadiness is necessary because, on modern distributions, pip
# (correctly) refuses to uninstall Python packages installed via
# system packages.
Expand All @@ -33,6 +40,7 @@
register: shady_uninstall
- name: Shadily install necessary packages for Python 2 via pip
ansible.builtin.pip:
extra_args: "{{ pip_break_system_packages | default(omit) }}"
name:
- platformdirs
# virtualenv 20.22.0 removed support for creating Python 2
Expand Down Expand Up @@ -66,6 +74,7 @@
# run.
when: shady_install.changed # noqa: no-handler
ansible.builtin.pip:
extra_args: "{{ pip_break_system_packages | default(omit) }}"
name:
- platformdirs
- virtualenv
Expand Down

0 comments on commit 8ba4778

Please sign in to comment.