Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pip install to handle "error: externally-managed-environment" #1320

Conversation

mboersma
Copy link
Contributor

@mboersma mboersma commented Oct 10, 2023

What this PR does / why we need it:

Adds a new pip3_install bash function that will retry installation if a certain error is raised.

Recently the e2e build environment was updated such that PEP 668 became implemented. This means that pip3 install <package> raises an error telling the user to do apt-get install python-<package> instead. Here is one example of that failure.

This makes sense for distro vendors, but image-builder doesn't control the distro and has specific requirements for some tools (Packer, ansible, ansible-lint).

Which issue(s) this PR fixes:

Fixes #

Additional context

I looked at the recommended approach–using a Python virtualenv–but it's not a great fit with our set of scripts and would require more significant refactoring.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 10, 2023
Copy link
Member

@AverageMarcus AverageMarcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

Do you happen to know if the E2E environment changes were announced anywhere? Is there something we should be keeping an eye on for potential problems?

echo "$output"
elif [[ $output == *"error: externally-managed-environment"* ]]; then
>&2 echo "warning: externally-managed-environment, retrying pip3 install with --break-system-packages"
pip3 install --disable-pip-version-check --user --break-system-packages "${@}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

--break-system-packages

What a great flag name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appropriately scary-sounding.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 12, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AverageMarcus

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit a1de3ba into kubernetes-sigs:main Oct 12, 2023
9 checks passed
@mboersma
Copy link
Contributor Author

Do you happen to know if the E2E environment changes were announced anywhere?

I don't know for sure. It might just have been a global update to the kubekins container image.

I did a bit of research on why this is happening and determined it was better just to adapt to it. But I'll go look at #sig-testing and #prow and see if I can find a clue.

@mboersma mboersma deleted the pip-externally-managed-environment-error branch October 12, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants