diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c9891cc..2960a8c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Updated Pipenv from 2025.0.4 to 2026.0.3. ([#2000](https://github.com/heroku/heroku-buildpack-python/pull/2000)) ## [v328] - 2026-01-07 diff --git a/lib/pipenv.sh b/lib/pipenv.sh index 84b00ad4b..1a87d4f49 100644 --- a/lib/pipenv.sh +++ b/lib/pipenv.sh @@ -81,29 +81,17 @@ function pipenv::install_pipenv() { export PATH="${pipenv_bin_dir}:${PATH}" # Force Pipenv to manage the system Python site-packages instead of using venvs. export PIPENV_SYSTEM="1" - # Hide Pipenv's notice about finding/using an existing virtual environment. - export PIPENV_VERBOSITY="-1" - # Work around a Pipenv bug when using `--system`, whereby it doesn't correctly install - # dependencies that happen to also be a dependency of Pipenv (such as `certifi`). - # In general Pipenv's support for its `--system` mode seems very buggy. Longer term we - # should explore moving to venvs, however, that will need to be coordinated across all - # package managers and also change paths for Python which could break other use cases. - export VIRTUAL_ENV="${python_home}" # Set the same env vars in the environment used by later buildpacks. cat >>"${export_file}" <<-EOF export PATH="${pipenv_bin_dir}:\${PATH}" export PIPENV_SYSTEM="1" - export PIPENV_VERBOSITY="-1" - export VIRTUAL_ENV="${python_home}" EOF # And the environment used at app run-time. cat >>"${profile_d_file}" <<-EOF export PATH="${pipenv_bin_dir}:\${PATH}" export PIPENV_SYSTEM="1" - export PIPENV_VERBOSITY="-1" - export VIRTUAL_ENV="${python_home}" EOF } diff --git a/requirements/pipenv.txt b/requirements/pipenv.txt index b239da87f..faed680ba 100644 --- a/requirements/pipenv.txt +++ b/requirements/pipenv.txt @@ -1 +1 @@ -pipenv==2025.0.4 +pipenv==2026.0.3 diff --git a/spec/hatchet/ci_spec.rb b/spec/hatchet/ci_spec.rb index 2cc0b9acc..e44effbf0 100644 --- a/spec/hatchet/ci_spec.rb +++ b/spec/hatchet/ci_spec.rb @@ -123,10 +123,8 @@ LIBRARY_PATH=/app/.heroku/python/lib PATH=/app/.heroku/python/pipenv/bin:/app/.heroku/python/bin:/usr/local/bin:/usr/bin:/bin:/app/.sprettur/bin/ PIPENV_SYSTEM=1 - PIPENV_VERBOSITY=-1 PKG_CONFIG_PATH=/app/.heroku/python/lib/pkg-config PYTHONUNBUFFERED=1 - VIRTUAL_ENV=/app/.heroku/python -----> Saving cache ! Note: We recently added support for the package manager uv: @@ -145,11 +143,9 @@ LIBRARY_PATH=/app/.heroku/python/lib PATH=/app/.heroku/python/bin:/app/.heroku/python/pipenv/bin:/usr/local/bin:/usr/bin:/bin:/app/.sprettur/bin/ PIPENV_SYSTEM=1 - PIPENV_VERBOSITY=-1 PYTHONHOME=/app/.heroku/python PYTHONPATH=/app PYTHONUNBUFFERED=true - VIRTUAL_ENV=/app/.heroku/python -----> No test-setup command provided. Skipping. -----> Running test command `./bin/print-env-vars.sh && pytest --version`... CI=true @@ -161,11 +157,9 @@ LIBRARY_PATH=/app/.heroku/python/lib PATH=/app/.heroku/python/bin:/app/.heroku/python/pipenv/bin:/usr/local/bin:/usr/bin:/bin:/app/.sprettur/bin/:/app/.sprettur/bin/ PIPENV_SYSTEM=1 - PIPENV_VERBOSITY=-1 PYTHONHOME=/app/.heroku/python PYTHONPATH=/app PYTHONUNBUFFERED=true - VIRTUAL_ENV=/app/.heroku/python WEB_CONCURRENCY=5 pytest .+ -----> test command `./bin/print-env-vars.sh && pytest --version` completed successfully diff --git a/spec/hatchet/pipenv_spec.rb b/spec/hatchet/pipenv_spec.rb index f0bc4c5f3..d922f136b 100644 --- a/spec/hatchet/pipenv_spec.rb +++ b/spec/hatchet/pipenv_spec.rb @@ -27,10 +27,8 @@ remote: LIBRARY_PATH=/app/.heroku/python/lib remote: PATH=/app/.heroku/python/pipenv/bin:/app/.heroku/python/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin remote: PIPENV_SYSTEM=1 - remote: PIPENV_VERBOSITY=-1 remote: PKG_CONFIG_PATH=/app/.heroku/python/lib/pkg-config remote: PYTHONUNBUFFERED=1 - remote: VIRTUAL_ENV=/app/.heroku/python remote: -----> Saving cache remote: remote: ! Note: We recently added support for the package manager uv: @@ -49,11 +47,9 @@ remote: LIBRARY_PATH=/app/.heroku/python/lib remote: PATH=/app/.heroku/python/bin:/app/.heroku/python/pipenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin remote: PIPENV_SYSTEM=1 - remote: PIPENV_VERBOSITY=-1 remote: PYTHONHOME=/app/.heroku/python remote: PYTHONPATH=/app remote: PYTHONUNBUFFERED=true - remote: VIRTUAL_ENV=/app/.heroku/python remote: remote: \\['', remote: '/app', @@ -119,11 +115,9 @@ LIBRARY_PATH=/app/.heroku/python/lib PATH=/app/.heroku/python/bin:/app/.heroku/python/pipenv/bin:/usr/local/bin:/usr/bin:/bin PIPENV_SYSTEM=1 - PIPENV_VERBOSITY=-1 PYTHONHOME=/app/.heroku/python PYTHONPATH=/app PYTHONUNBUFFERED=true - VIRTUAL_ENV=/app/.heroku/python WEB_CONCURRENCY=2 pipenv, version #{PIPENV_VERSION} OUTPUT @@ -455,8 +449,7 @@ end end - # TODO: Rename this test description back this when the Pipenv version next changes. - context 'when the Python version has changed since the last build' do + context 'when the Pipenv and Python versions have changed since the last build' do let(:buildpacks) { ['https://github.com/heroku/heroku-buildpack-python#v313'] } let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_basic', buildpacks:) } @@ -471,6 +464,7 @@ remote: -----> Using Python 3.14 specified in Pipfile.lock remote: -----> Discarding cache since: remote: - The Python version has changed from 3.14.0 to #{LATEST_PYTHON_3_14} + remote: - The Pipenv version has changed from 2025.0.4 to #{PIPENV_VERSION} remote: -----> Installing Python #{LATEST_PYTHON_3_14} remote: -----> Installing Pipenv #{PIPENV_VERSION} remote: -----> Installing dependencies using 'pipenv install --deploy' @@ -560,21 +554,28 @@ end end - # This is disabled since it's currently broken upstream: https://github.com/pypa/pipenv/issues/6403 # This tests that Pipenv doesn't fall back to system Python if the Python version in # pyproject.toml doesn't match that in Pipfile / Pipfile.lock. - # context 'when requires-python in pyproject.toml is incompatible with .python-version' do - # let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_mismatched_python_version', allow_failure: true) } - # - # it 'fails the build' do - # app.deploy do |app| - # expect(clean_output(app.output)).to include(<<~OUTPUT) - # remote: -----> Installing dependencies using 'pipenv install --deploy' - # remote: - # OUTPUT - # end - # end - # end + context 'when requires-python in pyproject.toml is incompatible with .python-version' do + let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_mismatched_python_version', allow_failure: true) } + + it 'fails the build' do + app.deploy do |app| + expect(clean_output(app.output)).to include(<<~OUTPUT) + remote: -----> Installing dependencies using 'pipenv install --deploy' + remote: Warning: Your Pipfile requires "python_version" 3.12, but you are using #{LATEST_PYTHON_3_13} + remote: from //app/./python/bin/python3. + remote: Usage: pipenv install [OPTIONS] [PACKAGES]... + remote: + remote: ERROR:: Aborting deploy + remote: + remote: ! Error: Unable to install dependencies using Pipenv. + remote: ! + remote: ! See the log output above for more information. + OUTPUT + end + end + end # This tests not only our handling of failing dependency installation, but also that we're running # Pipenv in such a way that it errors if the lockfile is out of sync, rather than simply updating it.