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 17, 2021
1 parent d810ce1 commit 820e737
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/changelog/2185.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a bug where while creating a venv on top of an existing one, without cleaning, when seeded
wheel version mismatch occurred, multiple ``.dist-info`` directories may be present, confounding entrypoint
discovery - by :user:`arcivanov`
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 820e737

Please sign in to comment.