[issue42312] sys.prefix is set incorrectly on Mac OS X

Michael Ferguson report at bugs.python.org
Thu Nov 12 09:53:54 EST 2020


Michael Ferguson <michael.ferguson at hpe.com> added the comment:

> The way sys.prefix is calculated on macOS ensures that the correct sys.prefix is calculated even if you copy the binary to a different location. That's functionality I don't want to drop.

I agree with you that it's important for the Python interpreter to find the libraries it is installed with even if the framework launcher is copied to a different location.

However I think it's possible to support finding the installation while fixing the issue I am bringing up. Finding the installation amounts to getting the correct `sys.base_prefix` (no matter where the launcher is copied). It seems to me that if the launcher is copied to a different directory, `sys.prefix` should change in some cases. That already happens when making a `venv` with copies instead of links. Could the framework launcher consider `argv[0]` without causing problems in this use case?

I think this is a bug and not a feature tradeoff because a platform-specific wrapper should be as transparent as possible and as a result should keep the `argv[0]` behavior that occurs without the wrapper.


In any case, do you think that there is a way to get the behavior I am looking for (basically, invoke a Python interpreter that has sys.prefix set to the venv but without a symbolic link)?

----------

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


More information about the Python-bugs-list mailing list