Skip to content

Commit

Permalink
Accept python self-referencing python executables (pypa#1664)
Browse files Browse the repository at this point in the history
Accept these as if they were system executables, print a info about
them referencing themselves.

Resolves pypa#1632.

Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat authored Feb 25, 2020
1 parent c794bc2 commit 7d8d2af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.tox
2 changes: 2 additions & 0 deletions docs/changelog/1632.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix circular prefix reference with single elements (accept these as if they were system executables, print a info about
them referencing themselves) - by :user:`gaborbernat`.
6 changes: 5 additions & 1 deletion src/virtualenv/discovery/py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,17 @@ def _resolve_to_system(cls, target):
while target.system_executable is None:
prefix = target.real_prefix or target.base_prefix or target.prefix
if prefix in prefixes:
if len(prefixes) == 1:
# if we're linking back to ourselves accept ourselves with a WARNING
logging.info("%r links back to itself via prefixes", target)
target.system_executable = target.executable
break
for at, (p, t) in enumerate(prefixes.items(), start=1):
logging.error("%d: prefix=%s, info=%r", at, p, t)
logging.error("%d: prefix=%s, info=%r", len(prefixes) + 1, prefix, target)
raise RuntimeError("prefixes are causing a circle {}".format("|".join(prefixes.keys())))
prefixes[prefix] = target
target = target.discover_exe(prefix=prefix, exact=False)

if target.executable != target.system_executable:
target = cls.from_exe(target.system_executable)
target.executable = start_executable
Expand Down

0 comments on commit 7d8d2af

Please sign in to comment.