fix: don't uninstall PyPI files that a conda package now owns - #6920
Draft
baszalmstra wants to merge 1 commit into
Draft
fix: don't uninstall PyPI files that a conda package now owns#6920baszalmstra wants to merge 1 commit into
baszalmstra wants to merge 1 commit into
Conversation
baszalmstra
force-pushed
the
fix/6902-conda-owned-pypi-files
branch
from
August 28, 2026 10:25
5b6753e to
fe42e45
Compare
When the last PyPI dependency of an environment moves to the conda side, the PyPI updater sees an empty set of records and cleans out site-packages. The leftover `.dist-info` of the old PyPI package is still there, and its RECORD lists exactly the paths the new conda package just wrote, so uninstalling by that stale RECORD deletes the freshly installed conda files and leaves a half-empty package behind. Before removing an installed distribution we now look up its RECORD entries in the conda paths registry. If a conda package owns any of them, only the stale `.dist-info` directory is removed and the files are left alone. Fixes prefix-dev#6902
baszalmstra
force-pushed
the
fix/6902-conda-owned-pypi-files
branch
from
August 28, 2026 10:35
fe42e45 to
e9893c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Moving a PyPI dependency to the conda side leaves the package half-deleted: the
.pyfiles are gone but some data files survive.When that was the last PyPI dependency of the environment,
on_python_interpreter_changesees an empty set of PyPI records and cleans out site-packages. The old PyPI.dist-infois still sitting there, and its RECORD lists exactly the paths the conda package just wrote, so we uninstall the freshly installed conda files. Only the files that differ between the two versions survive, which matches the symptoms in the issue.Before uninstalling a distribution we now look up its RECORD entries in the conda paths registry we already build for the clobber warnings. If a conda package owns any of them, only the stale
.dist-infois removed and the files are left alone. The registry is built after we know there is something to uninstall, so the common "environment has no PyPI dependencies" path does not pay for it on every run (~15 ms on a 109-package env).Entries of an installed distribution need slightly different handling than a wheel RECORD: they are relative to the directory holding the
.dist-infoand the PEP 427.data/<scheme>/...entries have already been spread out by the installer. Hencefrom_installed_recordnext tofrom_wheel_record.Fixes #6902
How Has This Been Tested?
cargo test -p pixi_install_pypi, with three new unit tests for mapping installed-RECORD entries onto conda's prefix-relative form: a plain entry, a../../../bin/<script>console script that escapes site-packages but stays inside the prefix, and entries that escape the prefix or are absolute.I did not manage to build an integration test for the full move-to-conda flow, so that path is reasoned about rather than verified. Please check it closely.
AI Disclosure
Tools: Claude
Checklist: