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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions images/capi/hack/ensure-ansible-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore

if ! command -v ansible-lint >/dev/null 2>&1; then
ensure_py3
pip3 install --user "ansible-lint==${_version}"
pip3_install "ansible-lint==${_version}"
ensure_py3_bin ansible-lint
fi
3 changes: 1 addition & 2 deletions images/capi/hack/ensure-ansible-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore

if pip3 show pywinrm >/dev/null 2>&1; then exit 0; fi

ensure_py3
pip3 install --user "pywinrm==${_version}"
pip3_install "pywinrm==${_version}"
if ! pip3 show pywinrm ; then exit 1; fi
3 changes: 1 addition & 2 deletions images/capi/hack/ensure-ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore

if ! command -v ansible >/dev/null 2>&1; then
ensure_py3
pip3 install --user "ansible-core==${_version}"
pip3_install "ansible-core==${_version}"
ensure_py3_bin ansible
ensure_py3_bin ansible-playbook
fi
Expand Down
3 changes: 1 addition & 2 deletions images/capi/hack/ensure-azure-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ if command -v az >/dev/null 2>&1; then exit 0; fi
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore

ensure_py3
pip install -U pip setuptools
pip3 install --user azure-cli
pip3_install azure-cli
ensure_py3_bin az azure-cli
13 changes: 13 additions & 0 deletions images/capi/hack/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ ensure_py3() {
fi
}

pip3_install() {
ensure_py3
if output=$(pip3 install --disable-pip-version-check --user "${@}" 2>&1); then
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.

else
>&2 echo "$output"
exit 1
fi
}

hostarch_without_darwin_arm64() {
if [ "${HOSTOS}" == "darwin" ] && [ "${HOSTARCH}" == "arm64" ]; then
echo "amd64"
Expand Down