Skip to content

Commit

Permalink
During seeding remove dist-info for present versions of the wheels
Browse files Browse the repository at this point in the history
An existing dist-info may contain entrypoints that may interfere with
normal functioning of the redeployed seeded wheel if there is a version
mismatch

fixes pypa#2185
  • Loading branch information
arcivanov committed Sep 16, 2021
1 parent d810ce1 commit 7191497
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/virtualenv/seed/embed/via_app_data/pip_install/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ def _sync(self, src, dst):

def install(self, version_info):
self._extracted = True
# cleanup existing version's .dist-info if exists
# TODO: This still could leave extra packages hanging around but those should be inert
dist_name = self._dist_info.stem[: self._dist_info.stem.index("-")]
for filename in self._creator.purelib.iterdir():
if filename.name.startswith(dist_name) and filename.suffix == ".dist-info" and filename.is_dir():
logging.debug(
"removing %s of the present version of %s from %s", filename.name, dist_name, self._creator.purelib
)
safe_delete(filename)
break
# sync image
for filename in self._image_dir.iterdir():
into = self._creator.purelib / filename.name
Expand Down

0 comments on commit 7191497

Please sign in to comment.