Skip to content

Conversation

@CorentinDurand
Copy link

Summary

When multiple injected packages share a dependency in the same pipx venv,
pipx uninject could uninstall that shared dependency, even if it is still
required by other injected packages. This could break the remaining packages.

This PR makes uninject more conservative when cleaning up dependencies.

Changes

  • In uninject_dep, after uninstalling the injected package, we still compute
    the set of packages that became "not required" using
    venv.list_installed_packages(not_required=True), but before uninstalling
    them we:

    • Build a set of dependencies still required by:
      • the main package of the venv, and
      • all other injected packages (excluding the one being uninjected).
    • Only uninstall dependencies that are not in this "protected" set.
  • The user-facing behaviour is unchanged when there are no shared dependencies,
    but shared dependencies used by other packages in the venv are now preserved.

  • Added a regression test test_uninject_keeps_shared_dependencies to ensure
    that uninjection of one injected package does not remove another injected
    package from the same venv.

  • Added a changelog fragment describing the bugfix.

Testing

Local (Windows 11):

  • python -m nox -s tests-3.10 -- -k "uninject"

Result:

  • All uninject-related tests pass:
    • 4 passed, 1 skipped (the global test skipped on Windows).
  • The cover nox session fails locally because only a subset of tests is run
    (global coverage 56% < fail-under=70). I expect full coverage to be validated
    by the CI when running the complete test suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant