Skip to content

Commit 3334b2b

Browse files
committed
fix: allow pyvenv.cfg to omit home key
1 parent 59963e8 commit 3334b2b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Modules/getpath.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def search_up(prefix, *landmarks, test=isfile):
364364
venv_prefix = None
365365
pyvenvcfg = []
366366

367-
# Search for the 'home' key in pyvenv.cfg. Currently, we don't consider the
368-
# presence of a pyvenv.cfg file without a 'home' key to signify the
369-
# existence of a virtual environment — we quietly ignore them.
370-
# XXX: If we don't find a 'home' key, we don't look for another pyvenv.cfg!
367+
# Search for the 'home' key in pyvenv.cfg. If a home key isn't found,
368+
# then it means a venv is active and home is based on the venv's
369+
# executable (if its a symlink, home is where the symlink points).
371370
for line in pyvenvcfg:
372371
key, had_equ, value = line.partition('=')
373372
if had_equ and key.strip().lower() == 'home':
@@ -412,10 +411,8 @@ def search_up(prefix, *landmarks, test=isfile):
412411
if isfile(candidate):
413412
base_executable = candidate
414413
break
414+
# home key found; stop iterating over lines
415415
break
416-
else:
417-
# We didn't find a 'home' key in pyvenv.cfg (no break), reset venv_prefix.
418-
venv_prefix = None
419416

420417

421418
# ******************************************************************************

0 commit comments

Comments
 (0)