This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dsmaccy
Recipients docs@python, dsmaccy, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-06-13.02:06:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623550009.05.0.642341298843.issue44406@roundup.psfhosted.org>
In-reply-to
Content
Confirmed on 3.6 and 3.9.  The issue can be found in venv\__init__.py where the sys.prefix is used to determine the parent path of the python executable (near the bottom of the symlink_or_copy method at about line 190).  On the venv documentation page (https://docs.python.org/3/library/venv.html), it is noted that:

====
When a virtual environment is active (i.e., the virtual environment’s Python interpreter is running), the attributes sys.prefix and sys.exec_prefix point to the base directory of the virtual environment, whereas sys.base_prefix and sys.base_exec_prefix point to the non-virtual environment Python installation which was used to create the virtual environment. If a virtual environment is not active, then sys.prefix is the same as sys.base_prefix and sys.exec_prefix is the same as sys.base_exec_prefix (they all point to a non-virtual environment Python installation).
====

This code is called by lib\site-packages\build\env.py (venv.EnvBuilder...) which fails erroneously due to the divergent behavior of the sys.prefix as described in the documentation snippet above.

Recommended fix:  I'm not sure why that behavior diverges in the first place.  Ideally, either the build lib\venv\__init__.py should be updated to not rely on sys.prefix, or the sys.prefix behavior should be changed.

Additional Notes:
- I am seeing this issue on Windows 10
- The venv instance is within an Anaconda directory.
- The python -m build command I am running is from within a virtual environment
- I've listed file paths in relation to the library path within the same directory as the python executable for convenience.  Let me clarify, however, that there are multiple instances of the python lib folder: 1 global and 1 local copy.  The venv path is located in the global instance within the Anaconda path whereas the build script is using the virtual environment instance of python.
History
Date User Action Args
2021-06-13 02:06:49dsmaccysetrecipients: + dsmaccy, paul.moore, tim.golden, docs@python, zach.ware, steve.dower
2021-06-13 02:06:49dsmaccysetmessageid: <1623550009.05.0.642341298843.issue44406@roundup.psfhosted.org>
2021-06-13 02:06:49dsmaccylinkissue44406 messages
2021-06-13 02:06:47dsmaccycreate