Commit Graph

9507 Commits

Author SHA1 Message Date
Matt Davis c5bb36dfd2 Correction to benchmark test 2026-03-28 00:53:48 -04:00
Matt Davis 1bbcb40e1b fix: use target Python filtering instead of ignore_requires_python=True (#6603)
* fix: use target Python filtering instead of ignore_requires_python=True

Previously the resolver set ignore_requires_python=True which disabled
all Requires-Python filtering in both the PackageFinder (link evaluator)
and the resolver factory. This caused the resolver to consider every
published version of every package — including ancient Python 2.x-era
releases — massively inflating the search space and triggering
ResolutionTooDeepError on large dependency trees (e.g. 101 Sentry
requirements).

Instead, extract the target Python version from the Pipfile's
python_version/python_full_version and pass it as py_version_info to
both the PackageFinder (for link filtering) and make_resolver (for
RequiresPythonRequirement constraint creation). This lets the resolver
properly prune incompatible candidates while still supporting
cross-version locking (e.g. locking for Python 3.12 while running 3.11).

* fix benchmark

* Improve resolver conflict prioritization and hash warnings

* check pt

* Check pt
2026-03-28 00:52:11 -04:00
Matt Davis 0a81389d50 Merge pull request #6604 from pypa/fix/triage-old-issues-4398-4085
Add --exclude-index flag to requirements command and fix --where exit code
2026-03-28 00:13:42 -04:00
Matt Davis 59720f5bc2 Add --exclude-index flag to requirements command and fix --where exit code
Fixes #4398: Add --exclude-index flag to 'pipenv requirements' to allow
users to exclude index URLs (-i and --extra-index-url) from the output.

Fixes #4085: 'pipenv --where' now exits with code 1 when no Pipfile is
found, making it suitable for scripting and CI pipelines.
2026-03-27 23:57:34 -04:00
Matt Davis b154d3895d Merge pull request #6601 from pypa/fix/fish-completion-run-file-paths
fix: enable fish shell file path completion for `pipenv run` args
2026-03-27 23:23:56 -04:00
Matt Davis b3f1064bcc Merge pull request #6600 from pypa/fix/benchmark-resolution-too-deep
Fix ResolutionTooDeepError caused by wrong python_full_version in marker evaluation
2026-03-27 23:16:30 -04:00
Matt Davis 877647499d Merge pull request #6602 from pypa/docs/address-open-documentation-issues
docs: address 8 open documentation issues
2026-03-27 23:16:09 -04:00
Matt Davis 39d93287f6 docs: address 8 open documentation issues in a single PR
Closes #4053 - Added a dedicated 'Installing on Windows' section to
docs/installation.md with the recommended pipx-based approach and
PATH setup instructions.

Closes #4577 - Added an 'Upgrading the Python Version' workflow to
docs/workflows.md with step-by-step instructions for migrating a
project to a new Python interpreter.

Closes #4636 - Documented that python_version in [requires] only
accepts an exact version string (e.g. '3.10'), not range specifiers
like '>= 3.6', and added a warning with the misleading error message.

Closes #5129 - Enhanced the 'Moving or Renaming Projects' section in
docs/virtualenv.md with a recovery workflow for users who already
moved their project without running 'pipenv --rm', plus a tip about
PIPENV_VENV_IN_PROJECT.

Closes #5130 - Added a 'Multi-Platform Considerations' section to
docs/locking.md explaining that Pipfile.lock is platform-specific,
with workarounds for cross-platform teams (Docker locking, CI, etc.).

Closes #5324 - Added a 'News Fragments' section to
docs/dev/contributing.md covering all towncrier fragment types and
explaining why 'trivial' entries are intentionally omitted from the
CHANGELOG.

Closes #5528 - Documented the behavior when a package pinned in
[dev-packages] conflicts with the version resolved through [packages]
dependencies, and how to enforce a specific version.

Closes #6028 - Added a 'Platform Markers and Locking' note to
docs/specifiers.md explaining that pip resolves all packages at lock
time regardless of sys_platform markers, and providing workarounds.
2026-03-27 23:12:24 -04:00
Matt Davis ecfe588b2e fix: enable fish shell file path completion for pipenv run args
When using fish shell and typing `pipenv run <command> <tab>`, file
path completion was not working because:

1. The fish completion script uses --no-files globally, preventing
   fallback file completion from the shell.
2. The `args` argument (nargs=-1) in the `run` command uses click's
   STRING type, whose shell_complete method returns [] (no completions).

Fix by adding a _complete_run_args shell completion callback to the
`args` argument of the `run` command that returns CompletionItem
with type='file'. The fish completion script already handles 'file'
type items via __fish_complete_path, which triggers proper file path
completion in fish.

Fixes: https://github.com/pypa/pipenv/issues/3478
2026-03-27 23:05:49 -04:00
Matt Davis 0523bd15dd Fix ResolutionTooDeepError caused by wrong python_full_version in marker evaluation
When the Pipfile specifies only python_version (e.g. '3.11') without an
explicit python_full_version, _get_pipfile_python_override() was hardcoding
python_full_version to '{major}.{minor}.0' (e.g. '3.11.0'). This caused
markers like 'python_full_version >= "3.11.4"' to evaluate incorrectly
during resolution, excluding necessary dependencies and triggering excessive
backtracking that hit the 200,000 round limit (ResolutionTooDeepError).

Now uses the running interpreter's actual patch version when it matches the
Pipfile's major.minor, falling back to .0 only when they differ.

Also fixes a Rich markup bug in do_create_virtualenv where an unclosed
[green] tag and missing space caused the Python path and version to render
concatenated (e.g. 'python3.11.15' instead of 'python3.11 3.11.15').
2026-03-27 22:55:58 -04:00
Matt Davis 990114b473 fix ruff 2026-03-27 22:49:49 -04:00
Matt Davis 01599ad018 Merge pull request #6599 from pypa/fix/system-flag-improvements
Improve --system flag support across commands
2026-03-27 22:47:44 -04:00
Matt Davis 95c85ffd5e Add [build-system] requires support in Pipfile
- Add pipfile_build_requires property to Project
- Add install_build_system_packages() to install build deps before resolving
- Add build-system to NON_CATEGORY_SECTIONS
- Update lock routine to include build-system in lockfile
- Add unit tests for build-system functionality
2026-03-27 22:47:16 -04:00
Matt Davis 0945a12e7a Improve --system flag support across commands
- Add --system flag to 'pipenv update' command (was hardcoded to False)
- Add PIPENV_BREAK_SYSTEM_PACKAGES env var for PEP 668 environments
- Fix ensure_virtualenv aborting when --system is used with existing venv
- Pass PIP_IGNORE_INSTALLED and PIP_USER through to pip with --system
- Support --system --python to target specific Python site-packages

Fixes #3593, #4453, #5052, #5584, #5631, #5660
Related: #5086, #5089, #5115
2026-03-27 22:45:16 -04:00
Matt Davis 947f63d062 Fix _create_builtin_venv_cmd prepending drive letter to Unix paths on Windows
Path(python).absolute() on Windows prepends the current drive letter
(e.g. D:) to Unix-style absolute paths, corrupting the interpreter
path. Use the python string directly since it is already provided as
an absolute path by the caller.
2026-03-27 22:36:17 -04:00
Matt Davis be1ecfe40d Merge pull request #6597 from pypa/feature/pipenv-pyenv-only
Add PIPENV_PYENV_ONLY environment variable to restrict Python discovery to pyenv
2026-03-27 22:35:36 -04:00
Matt Davis bfb8200ce8 Merge pull request #6598 from pypa/fix/shell-suspend-job-control
Fix pipenv shell not suspending properly with Ctrl+Z
2026-03-27 22:34:59 -04:00
Matt Davis 9e6ae4fb9f Fix marker evaluation with major-only python_version in Pipfile
When Pipfile specifies python_version = '3' (major-only), the override
produced python_full_version = '3.0' and python_version = '3'. This
caused markers like 'python_version < "3.10"' to evaluate as True
(since '3' < '3.10' in PEP 440), activating stale dependency
constraints and causing resolver conflicts (e.g. urllib3>=2 vs
urllib3<1.27 from botocore).

Now major-only versions are skipped — the running interpreter's actual
version is used for marker evaluation instead.
2026-03-27 22:33:40 -04:00
Matt Davis b355a925cf Show full error output in benchmark results instead of truncating to 5 lines
This helps diagnose resolver failures by showing the complete error
output from failed benchmark commands.
2026-03-27 22:15:04 -04:00
Matt Davis 80b39d583c Fix pipenv shell not suspending properly with Ctrl+Z
Install SIGTSTP and SIGCONT handlers around pexpect's interact() loop
so that when the child shell is suspended, the pipenv process stops
itself too, and resumes the child when continued. Without this, the
pexpect loop keeps pipenv in the foreground and the parent shell
never regains control.

Closes #5359
2026-03-27 22:11:13 -04:00
Matt Davis 8350a9c9df Add PIPENV_PYENV_ONLY environment variable to restrict Python discovery to pyenv
When PIPENV_PYENV_ONLY=1 is set, pipenv will only search for Python
interpreters installed via pyenv, ignoring system, Homebrew, asdf,
and other Python installations.

Closes #3855
2026-03-27 22:06:18 -04:00
Matt Davis 0d1ca311a3 Increase proper_case PyPI lookup timeout from 0.3s to 3s
The 300ms timeout was too aggressive, causing ReadTimeoutError failures
when resolving large requirements files (e.g. pipenv install -r with 100+
packages). Each package triggers a sequential HTTP request to pypi.org for
proper casing, and under load or from CI the requests frequently exceeded
the timeout, leading to silent failures and 'Locking Failed' errors.
2026-03-27 21:58:35 -04:00
Matt Davis d46b1577a2 Merge pull request #6596 from pypa/fix/shell-startup-interactive-prompt
Fix `pipenv shell` not activating virtualenv when shell startup has interactive prompts
2026-03-27 21:46:05 -04:00
Matt Davis fbfcbeffc3 Fix pipenv shell not activating when shell startup has interactive prompts (#3615)
pipenv shell uses pexpect to spawn a subshell and send the virtualenv
activate script.  Previously, the activate command was sent immediately
after spawning, before the shell had finished its startup.  If an
interactive prompt appeared during startup (e.g. oh-my-zsh asking to
update), the activate command was consumed by that prompt instead of
being executed as a shell command.

Fix: send a startup sentinel (echo __PIPENV_STARTUP_READY__) and wait
for it to appear before sending the activate script.  This ensures the
shell has fully initialised and any interactive prompts have been
resolved by the user.  The timeout is set to 30 seconds to give ample
time for user interaction.
2026-03-27 21:43:49 -04:00
Matt Davis 4897fa2458 Merge pull request #6595 from pypa/fix/sys-platform-shorthand-markers
Fix sys_platform shorthand not propagating markers to pip resolver
2026-03-27 21:40:44 -04:00
Matt Davis af9db1c6cc Fix sys_platform shorthand not being included in pip requirement lines (#5884)
Shorthand marker keys in Pipfile entries (e.g. sys_platform, platform_machine)
were not translated to PEP 508 markers when building the pip requirement line.
This caused pip to resolve and download sub-dependencies on all platforms,
even though the top-level package was platform-restricted.

Call translate_markers() in dependency_as_pip_install_line() so shorthand
keys are folded into the canonical 'markers' key before the pip line is
assembled.
2026-03-27 21:38:46 -04:00
Matt Davis 522ec9c7e2 Merge pull request #6594 from pypa/feature/keyring-provider-support
Add PIPENV_KEYRING_PROVIDER for Windows Credential Manager support
2026-03-27 21:14:52 -04:00
Matt Davis 6f4ba726b3 Add PIPENV_KEYRING_PROVIDER for Windows Credential Manager support
Add a new PIPENV_KEYRING_PROVIDER environment variable that allows users
to explicitly configure the keyring provider used for credential lookup
during both dependency resolution and package installation.

By default, pipenv disables pip's interactive input (no_input=True), which
causes pip to skip keyring-based credential lookup when the provider is
set to 'auto'. This means system credential managers like Windows
Credential Manager are never consulted, even though they don't require
user interaction.

Setting PIPENV_KEYRING_PROVIDER to 'import' or 'subprocess' overrides
this behavior, enabling non-interactive keyring credential lookup.

Changes:
- Add PIPENV_KEYRING_PROVIDER setting in environments.py
- Pass keyring_provider through to pip_options in the resolver
- Pass PIP_KEYRING_PROVIDER to the resolver subprocess environment
- Pass PIP_KEYRING_PROVIDER to the pip install subprocess environment
- Pass keyring_provider in environment.py's get_finder session
- Update docs: configuration.md, credentials.md, indexes.md
- Fix mock _Settings in test_install_error_context.py

Fixes #5715
2026-03-27 21:10:49 -04:00
Matt Davis e0f3bf9929 Merge pull request #6593 from pypa/fix/5627-pipenv-version-envvar
Ignore PIPENV_VERSION env var for --version flag
2026-03-27 21:00:31 -04:00
Matt Davis 9520f572e0 Merge branch 'main' into fix/5627-pipenv-version-envvar 2026-03-27 21:00:01 -04:00
Matt Davis 6b7ad70ab2 Fix ruff: add trailing newline to test_cli.py 2026-03-27 20:59:56 -04:00
Matt Davis d0b069f563 Merge pull request #6592 from pypa/fix/5578-all-categories-update-upgrade
Fix --all flag for update and upgrade commands
2026-03-27 20:59:42 -04:00
Matt Davis 9745ea0091 fix tests 2026-03-27 20:58:59 -04:00
Matt Davis 7d64c02124 Ignore PIPENV_VERSION env var for --version flag (#5627)
Click's auto_envvar_prefix='PIPENV' automatically maps --version to the
PIPENV_VERSION environment variable. When users set PIPENV_VERSION for
other purposes (e.g., CI parametrization), Click tries to parse it as a
boolean and fails with a confusing error message.

Fix by setting allow_from_autoenv=False on the version_option decorator,
which prevents Click from reading PIPENV_VERSION as a value for --version.
2026-03-27 20:53:31 -04:00
Matt Davis aad7bb50fb Fix --all flag for update and upgrade commands (#5578)
The --all flag was already defined and working for sync and install commands
but update and upgrade commands did not check state.installstate.all_categories,
so the flag was silently ignored.

- Fix update command to check all_categories before falling back to default
- Fix upgrade command to check all_categories before falling back to default
- Document --all flag for sync, update, and upgrade in CLI docs
- Add integration tests for --all flag on update and upgrade
2026-03-27 20:50:35 -04:00
Matt Davis fc4066f092 Merge pull request #6591 from pypa/add-pip-patch-files
Add patch files for pip customizations applied during vendoring
2026-03-27 20:44:42 -04:00
Matt Davis 7654648503 Add patch files for pip customizations applied during vendoring
Capture direct pip modifications as proper _post patch files so they
survive re-vendoring. These patches are applied after import rewriting.

- _post-pip_distutils_fallback.patch: Handle missing distutils on
  Python 3.12+ by falling back to sysconfig (fixes #5674)
- _post-pip_editable_extras.patch: Fix extras handling in editable
  VCS requirements
- _post-pip_wheel_name_casing.patch: Preserve wheel dist name casing
  for headers install directory (fixes #5717)
- _post-pip_resolution_log_level.patch: Use logger.critical for
  dependency resolution conflict messages
2026-03-27 20:43:02 -04:00
Matt Davis 235ad67ae5 Merge pull request #6590 from pypa/fix/5782-dev-packages-private-index-transitive-deps
Fix #5782: populate index_lookup from all Pipfile sections when locking non-default categories
2026-03-27 20:24:28 -04:00
Matt Davis 4e5f193956 Correction to last merge 2026-03-27 20:23:58 -04:00
Matt Davis b571bb4ee3 Merge pull request #6589 from pypa/fix/5893-py-launcher-full-version-matching
fix: Windows py-launcher full-version matching for python_full_version in Pipfile
2026-03-27 20:18:59 -04:00
Matt Davis 84746fe345 Revendoring 2026-03-27 20:18:36 -04:00
Matt Davis 819c8e951b prep the vendoring bump 2026-03-27 20:15:45 -04:00
Matt Davis 0d42aa417d Fix #5782: populate index_lookup from all Pipfile sections when locking non-default categories
When locking a non-default package category (e.g. [dev-packages] or a
custom group), Resolver.create() only built index_lookup from the packages
explicitly listed in that category.  With index_restricted=True in pip's
SearchScope, any package *not* in index_lookup was looked up exclusively on
the first configured index (typically PyPI).

This caused resolution to fail when:
  - [packages] declares  private_lib = {version="*", index="private"}
  - [dev-packages] declares dev_tool = {version="*", index="private"}
  - dev_tool has private_lib as a transitive dependency

pip could not find private_lib during the [dev-packages] resolution pass
because private_lib was absent from index_lookup, so pip only searched PyPI.

Fix: after building index_lookup from the current category, inject index
entries from all *other* Pipfile sections for packages not already present.
Entries set by the current category are never overridden, preserving the
existing behaviour for packages that appear in multiple sections with
different indexes.

Fixes: https://github.com/pypa/pipenv/issues/5782
2026-03-27 20:10:05 -04:00
Matt Davis dad1ceaa41 Merge pull request #6588 from pypa/fix/pipfile-whitespace-and-category-corruption-v2
fix: preserve Pipfile whitespace and prevent cross-category corruption on upgrade (#5914)
2026-03-27 20:01:39 -04:00
Matt Davis 4960c7e1a5 fix: Windows py-launcher full-version matching for python_full_version in Pipfile
Two bugs caused `pipenv install` (from a Pipfile with python_full_version)
and `pipenv --python 3.11.9` to fail on Windows even when the requested
Python version was installed and discoverable via `py --list-paths`:

1. find_python_from_py_launcher() required split(None, 2) to produce three
   tokens per line, but non-default py-launcher entries (those without the
   `*` marker) only produce two tokens.  Non-default versions were therefore
   silently skipped.  Fix: require len(parts) >= 2 and take parts[-1] as the
   path in all cases.

2. PyLauncherFinder stored only the major.minor version that `py --list-paths`
   reports (e.g. "3.11"), leaving patch=None.  Searches requiring a specific
   patch level (patch=9) therefore never matched.  Fix: query each discovered
   executable for its real version string (e.g. "3.11.9") via get_python_version()
   so that full-version lookups succeed.

Fixes #5893
2026-03-27 19:54:33 -04:00
Matt Davis 9fee9bf9b9 Merge pull request #6587 from pypa/fix/venv-fallback-alternative-interpreters
fix: fall back to built-in venv when virtualenv fails for alternative interpreters
2026-03-27 19:47:14 -04:00
Matt Davis c16aa7f08f fix: preserve Pipfile whitespace and prevent cross-category corruption on upgrade
Fixes two remaining issues from #5914:

1. Pipfile whitespace / blank-line stripping
   - cleanup_toml() previously removed ALL empty lines then re-added a
     single blank line between section headers only.  This destroyed any
     blank lines the user placed within a [packages] / [dev-packages]
     section for visual grouping.
   - New behaviour: consecutive blank lines are collapsed to one (so
     accidental duplication is still normalised), but a single blank line
     within a section is preserved.
   - convert_tomlkit_table() now passes through tomlkit whitespace items
     (key=None) instead of silently dropping them, so tomlkit's own
     whitespace-preservation round-trips cleanly through write_toml().

2. Cross-category Pipfile corruption (missing --dev flag)
   - When a user runs `pipenv upgrade mypy==1.5.1` without --dev,
     _find_additional_categories() correctly detects that mypy lives in
     [dev-packages] and ensures the lockfile is updated in both sections.
     However, _process_package_args() was also writing the updated entry
     to [packages] (the category derived from the absent --dev flag),
     resulting in mypy appearing in both Pipfile sections.
   - Fix: before calling add_pipfile_entry_to_pipfile(), check whether the
     package already exists in a *different* Pipfile category.  If so,
     skip the Pipfile write for the current category and emit a helpful
     warning pointing the user at --dev / --categories.

Tests added:
   - test_cleanup_toml_preserves_single_blank_lines_within_sections
   - test_cleanup_toml_collapses_multiple_blank_lines
   - test_cleanup_toml_adds_blank_line_before_section_header
   - test_process_package_args_does_not_cross_contaminate_categories
   - test_process_package_args_writes_to_pipfile_when_package_in_correct_category
2026-03-27 19:43:11 -04:00
Matt Davis 15bb0f1bae fix: sort imports in test_utils.py to satisfy ruff I001 2026-03-27 19:33:52 -04:00
Matt Davis 2777f1ee00 Merge pull request #6586 from pypa/fix/pip-conf-extra-index-hash-mismatch
fix: suppress pip.conf index configuration at install time (security hardening)
2026-03-27 19:33:29 -04:00
Matt Davis 55e46ec919 fix: fall back to built-in venv when virtualenv fails for alternative interpreters
When 'python -m virtualenv --python=<interp>' exits non-zero and the user
has not explicitly set PIPENV_VIRTUALENV_CREATOR, pipenv now automatically
retries using the target interpreter's own built-in venv module
('python -m venv').  This gives alternative Python implementations such as
RustPython, GraalPy, and Jython a real chance to work, because those
interpreters are more likely to ship a functional venv module than to
support all the C-extension hooks that virtualenv probes for.

If the venv fallback also fails, both error messages are surfaced so the
user has full context.  When PIPENV_VIRTUALENV_CREATOR is set explicitly
the fallback is skipped, respecting the user's intent.

A new helper, _create_builtin_venv_cmd(), builds the 'python -m venv'
command using the *target* interpreter (not sys.executable), which is the
key difference from the primary virtualenv invocation.

Closes #5601
2026-03-27 19:30:23 -04:00