On Fri, Aug 08, 2025 at 10:39:12PM -0700,
fatty.merc...@aceecat.org wrote:
...
> #! /bin/sh
> exec /usr/local/bin/python3 "$@"
Thanks for the discussion, it has been very useful and clarifying.
First, why not /usr/bin/env and PATH: this has to do with the reliance
in the python world for "virtual environments" (don't blame me for the
poor term!). Roughly, you can have all kinds of pythons slithering
about and showing up in your PATH, and you don't want *those* to run
generic scripts, you want the system python to do so.
This is discussed for example here:
https://utcc.utoronto.ca/~cks/space/blog/unix/UsingEnvRarelyUseful
So then there is the option of a direct symlink instead of a shim
script. In fact, that's what I do for bash and perl, so why not for
python? And the "because" was the same as above: I wasn't sure *how*
python detects it's in one of the so called virtual environments
(venvs), and I was afraid it might be confused by a symlink into
feeling it's in one. If you look inside a venv you see that the python
executable there is in fact a symlink to the system python.
But as it turns out, python must be using some other information to
make this decision. I suspect it is the presence (and perhaps format)
of the file bin/../pyvenv.cfg , but so far I haven't been able to find
a definitive confirmation of this; I'll be grateful if anyone provides
a confirmation. Maybe it's only clear from python source code.
Anyway, a symlink from /opt/compat/python3 to the system python seems
to work, so thanks.
--
Ian