Skip to content

Fix transitive dependencies skipped from project environments - #6700

Merged
matteius merged 2 commits into
mainfrom
fix/locked-transitive-install
Aug 4, 2026
Merged

Fix transitive dependencies skipped from project environments#6700
matteius merged 2 commits into
mainfrom
fix/locked-transitive-install

Conversation

@matteius

@matteius matteius commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • stop imported vendored pipdeptree code from adding Pipenv host paths to the target interpreter
  • retain the path bootstrap when pipdeptree is executed for pipenv graph
  • cover both the import isolation boundary and a locked transitive packaging install
  • persist the fix in the vendoring patch

The pipdeptree 3.1.0 update made its package initializer import __main__. Pipenv’s vendoring patch added host paths unconditionally in that module, so bundled pip could see distributions installed alongside Pipenv and incorrectly report them as already satisfied in a fresh project virtualenv.

Validation

  • focused unit/integration suite: 11 passed
  • built and installed a wheel into a separate host environment containing packaging==26.2
  • installed pytest into a fresh project environment and verified project-local packaging
  • verified bundled pip lists only project distributions
  • verified pipenv graph still succeeds
  • verified the vendoring patch reverses cleanly against generated files

Fixes #6698.
Fixes #6699.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression where Pipenv’s vendored pipdeptree initialization could leak Pipenv host paths into bundled pip subprocesses, causing pipenv install/sync to incorrectly skip locked transitive dependencies (e.g., packaging) in fresh project virtualenvs.

Changes:

  • Guard vendored pipdeptree/__main__.py path bootstrapping behind if __name__ == "__main__" to prevent sys.path pollution on import while preserving pipenv graph behavior.
  • Add/adjust unit + integration coverage to ensure import isolation and that a locked transitive dependency is installed into the project environment.
  • Persist the fix in the vendoring patch and add a news fragment documenting the bugfix.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/test_vendor.py Adds a regression test to ensure importing vendored pipdeptree does not extend sys.path.
tests/integration/test_install_basic.py Updates an integration test to validate transitive packaging is present in the lock and importable in the venv.
tasks/vendoring/patches/vendor/pipdeptree-update-import.patch Updates the vendoring patch so regenerated vendored sources keep the import-isolation fix (and related vendoring adjustments).
pipenv/vendor/pipdeptree/main.py Applies the runtime fix by only extending sys.path when executed as __main__.
news/6698.bugfix.rst Adds release-note entry describing the dependency-skipping regression and fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/test_vendor.py
Comment on lines +18 to +32
main_path = Path(pipenv.__file__).parent / "vendor" / "pipdeptree" / "__main__.py"
vendor_root = main_path.parents[1]
pipenv_install_root = vendor_root.parents[1]
paths = [str(vendor_root), str(pipenv_install_root)]
code = f"""
import json
import runpy
import sys

paths = {json.dumps(paths)}
before = {{path: sys.path.count(path) for path in paths}}
runpy.run_path({str(main_path)!r}, run_name="pipdeptree_import_test")
after = {{path: sys.path.count(path) for path in paths}}
print(json.dumps({{"before": before, "after": after}}))
"""
@matteius
matteius merged commit bf2e7d6 into main Aug 4, 2026
26 checks passed
@matteius
matteius deleted the fix/locked-transitive-install branch August 4, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants