diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bb96fe..0a6f277 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- pip is now only available during the build, and is longer included in the final app image. ([#264](https://github.com/heroku/buildpacks-python/pull/264)) + ## [0.17.1] - 2024-09-07 ### Changed diff --git a/src/layers/pip.rs b/src/layers/pip.rs index a828621..347adfa 100644 --- a/src/layers/pip.rs +++ b/src/layers/pip.rs @@ -31,7 +31,7 @@ pub(crate) fn install_pip( layer_name!("pip"), CachedLayerDefinition { build: true, - launch: true, + launch: false, invalid_metadata_action: &|_| InvalidMetadataAction::DeleteLayer, restored_layer_action: &|cached_metadata: &PipLayerMetadata, _| { let cached_pip_version = cached_metadata.pip_version.clone(); @@ -49,7 +49,7 @@ pub(crate) fn install_pip( // reduce build log spam and prevent users from thinking they need to manually upgrade. // https://pip.pypa.io/en/stable/cli/pip/#cmdoption-disable-pip-version-check .chainable_insert( - Scope::All, + Scope::Build, ModificationBehavior::Override, "PIP_DISABLE_PIP_VERSION_CHECK", "1", @@ -57,7 +57,7 @@ pub(crate) fn install_pip( // Move the Python user base directory to this layer instead of under HOME: // https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUSERBASE .chainable_insert( - Scope::All, + Scope::Build, ModificationBehavior::Override, "PYTHONUSERBASE", layer.path(), diff --git a/tests/pip_test.rs b/tests/pip_test.rs index f29d313..c9ebf7a 100644 --- a/tests/pip_test.rs +++ b/tests/pip_test.rs @@ -5,7 +5,6 @@ use libcnb_test::{assert_contains, assert_empty, BuildpackReference, PackResult, #[test] #[ignore = "integration test"] -#[allow(clippy::too_many_lines)] fn pip_basic_install_and_cache_reuse() { let mut config = default_build_config("tests/fixtures/pip_basic"); config.buildpacks(vec![ @@ -69,14 +68,13 @@ fn pip_basic_install_and_cache_reuse() { // Check that at run-time: // - The correct env vars are set. - // - pip is available (rather than just during the build). - // - Both pip and Python can find the typing-extensions package. + // - pip isn't available. + // - Python can find the typing-extensions package. let command_output = context.run_shell_command( indoc! {" set -euo pipefail printenv | sort | grep -vE '^(_|HOME|HOSTNAME|OLDPWD|PWD|SHLVL)=' - echo - pip list + ! command -v pip > /dev/null || { echo 'pip unexpectedly found!' && exit 1; } python -c 'import typing_extensions' "} ); @@ -85,18 +83,12 @@ fn pip_basic_install_and_cache_reuse() { command_output.stdout, formatdoc! {" LANG=C.UTF-8 - LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/pip/lib - PATH=/layers/heroku_python/venv/bin:/layers/heroku_python/python/bin:/layers/heroku_python/pip/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - PIP_DISABLE_PIP_VERSION_CHECK=1 + LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib + PATH=/layers/heroku_python/venv/bin:/layers/heroku_python/python/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PIP_PYTHON=/layers/heroku_python/venv PYTHONHOME=/layers/heroku_python/python PYTHONUNBUFFERED=1 - PYTHONUSERBASE=/layers/heroku_python/pip VIRTUAL_ENV=/layers/heroku_python/venv - - Package Version - ----------------- ------- - typing_extensions 4.12.2 "} );