Skip to content

fix: allow installer to work on PEP 668 externally managed Python - #19

Closed
limingyaoo wants to merge 1 commit into
mainfrom
fix-pep668-installer
Closed

limingyaoo wants to merge 1 commit into
mainfrom
fix-pep668-installer

Conversation

@limingyaoo

Copy link
Copy Markdown
Member

Issue #, if available:

Same bug as aws-greengrass/aws-greengrass-cloudwatch-metrics#13; same fix as aws-greengrass/aws-greengrass-cloudwatch-metrics#19.

Description of changes:

  • installer.py: run both pip install calls with PIP_BREAK_SYSTEM_PACKAGES=1 set in the subprocess env. Existing env vars such as ALL_PROXY are still passed through.
  • tests/test_installer.py: unit tests for the default, HTTP-proxy and HTTPS-proxy paths.
  • .github/workflows/python.yml: new installer-on-os-python job that runs installer.py as root on each distro's own Python. The workflow's GITHUB_TOKEN is now read-only.

Why is this change necessary:

With UseInstaller: true, the install step fails on PEP 668 distros (Debian 12+, Ubuntu 23.04+) with error: externally-managed-environment. Running as root doesn't help. The --break-system-packages flag isn't an option because pip < 23.0.1 rejects it (Ubuntu 20.04/22.04). The env var lifts the check on newer pip, and older pip ignores it.

How was this change tested:

  • flake8 and pytest on Python 3.7 and 3.10: 4 tests pass. The 3 new tests fail against the current code.
  • Ran the new CI job's steps locally in Docker. With this PR it passes on Debian 13/12 and Ubuntu 24.04/22.04/20.04. With the current code it fails on Debian 13/12 and Ubuntu 24.04 (externally-managed-environment).

Any additional information or context required to review the change:

  • Only affects UseInstaller: true. The default is unchanged.
  • Releases ship from release_3.1.x, so this needs a cherry-pick after merge. The files are identical on both branches.

Checklist:

  • Updated the README if applicable
  • Updated or added new unit tests
  • Updated or added new integration tests
  • Updated or added new end-to-end tests
  • If your code makes a remote network call, it was tested with a proxy
  • You confirm that the change is backwards compatible

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@limingyaoo limingyaoo closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant