From 7d8d2afddabbefe43643b0b926cc75227dba5aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Tue, 25 Feb 2020 10:44:42 +0000 Subject: [PATCH] Accept python self-referencing python executables (#1664) Accept these as if they were system executables, print a info about them referencing themselves. Resolves #1632. Signed-off-by: Bernat Gabor --- .dockerignore | 1 + docs/changelog/1632.bugfix.rst | 2 ++ src/virtualenv/discovery/py_info.py | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 docs/changelog/1632.bugfix.rst diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..172bf5786 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.tox diff --git a/docs/changelog/1632.bugfix.rst b/docs/changelog/1632.bugfix.rst new file mode 100644 index 000000000..ce53419cb --- /dev/null +++ b/docs/changelog/1632.bugfix.rst @@ -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`. diff --git a/src/virtualenv/discovery/py_info.py b/src/virtualenv/discovery/py_info.py index 3ffe57e6b..64b91dca3 100644 --- a/src/virtualenv/discovery/py_info.py +++ b/src/virtualenv/discovery/py_info.py @@ -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