Skip to content

Commit 0576746

Browse files
authored
Use pip install --isolated when bootstrapping pip/Pipenv/Poetry (#1915)
So that any invalid global pip config set by earlier buildpacks (either via `PIP_*` env vars or global pip config files in the HOME directory) don't affect/break the bootstrapping of the package managers. (Such config is still loaded during the later `pip install` used to install the app's own dependencies; this change only affects the internal buildpack bootstrapping stage.) This will help resolve issues seen via Honeycomb such as the bootstrapping step attempting to use custom package index URLs configured via third-party buildpacks like: https://github.com/meetalbert/albert-public-codeartifact-buildpack (which succeeds eventually, but only after delays from timeouts/retries) See: - https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated - https://pip.pypa.io/en/stable/topics/configuration/ GUS-W-19770470.
1 parent 136c3a1 commit 0576746

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Changed the `pip install` command used to install the pip, Pipenv and Poetry package managers to now use `--isolated` mode. ([#1915](https://github.com/heroku/heroku-buildpack-python/pull/1915))
56
- Added more Python project related file and directory names to the list recognised by buildpack detection. ([#1914](https://github.com/heroku/heroku-buildpack-python/pull/1914))
67

78
## [v310] - 2025-09-23

lib/pip.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ function pip::install_pip_setuptools_wheel() {
4646
# app's requirements.txt in the last build). The install will be a no-op if the versions match.
4747
output::step "Installing ${packages_display_text}"
4848

49+
# `--isolated`: Prevents any custom pip configuration added by third party buildpacks (via env
50+
# vars or global config files) from breaking package manager bootstrapping.
4951
# shellcheck disable=SC2310 # This function is invoked in an 'if' condition so set -e will be disabled.
5052
if ! {
5153
python "${bundled_pip_module_path}" \
5254
install \
5355
--disable-pip-version-check \
56+
--isolated \
5457
--no-cache-dir \
5558
--no-input \
5659
--quiet \

lib/pipenv.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ function pipenv::install_pipenv() {
6060
# We must call the venv Python directly here, rather than relying on pip's `--python`
6161
# option, since `--python` was only added in pip v22.3, so isn't supported by the older
6262
# pip versions bundled with Python 3.9/3.10.
63+
# `--isolated`: Prevents any custom pip configuration added by third party buildpacks (via env
64+
# vars or global config files) from breaking package manager bootstrapping.
6365
# shellcheck disable=SC2310 # This function is invoked in an 'if' condition so set -e will be disabled.
6466
if ! {
6567
"${pipenv_venv_dir}/bin/python" "${bundled_pip_module_path}" \
6668
install \
6769
--disable-pip-version-check \
70+
--isolated \
6871
--no-cache-dir \
6972
--no-input \
7073
--quiet \

lib/poetry.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ function poetry::install_poetry() {
6666
# We must call the venv Python directly here, rather than relying on pip's `--python`
6767
# option, since `--python` was only added in pip v22.3, so isn't supported by the older
6868
# pip versions bundled with Python 3.9/3.10.
69+
# `--isolated`: Prevents any custom pip configuration added by third party buildpacks (via env
70+
# vars or global config files) from breaking package manager bootstrapping.
6971
# shellcheck disable=SC2310 # This function is invoked in an 'if' condition so set -e will be disabled.
7072
if ! {
7173
"${poetry_venv_dir}/bin/python" "${bundled_pip_module_path}" \
7274
install \
7375
--disable-pip-version-check \
76+
--isolated \
7477
--no-cache-dir \
7578
--no-input \
7679
--quiet \

0 commit comments

Comments
 (0)