[issue42013] venv on Windows with symlinks is broken if invoked with -I

Eryk Sun report at bugs.python.org
Mon Oct 12 18:39:02 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

> So I'm +1 on fixing this by calling realpath.

In POSIX, calculate_path() in Modules/getpath.c calls calculate_argv0_path() before it calls calculate_read_pyenv(), and calculate_argv0_path() in turn calls resolve_symlinks(&calculate->argv0_path). Thus "pyvenv.cfg" isn't found and isn't used to find the standard library in POSIX when a virtual environment uses symlinks. Later on, "pyvenv.cfg" gets read by the site module, if importing the latter isn't skipped via -S. The site module sets sys._home to the `home` value, but sys._home only appears to be used by sysconfig when running from the build directory.

In Windows, calculate_path() in PC/getpathp.c could get the final (real) path for argv0_path before calling calculate_pyvenv_file(). Then, just like in POSIX, the environment's "pyvenv.cfg" file won't be found and won't be used to find the standard library when a virtual environment uses symlinks.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42013>
_______________________________________


More information about the Python-bugs-list mailing list