On 21Jul2019 09:31, Chris Angelico <ros...@gmail.com> wrote:
On Sun, Jul 21, 2019 at 9:15 AM Cameron Simpson <c...@cskk.id.au> wrote:
So.... you mean that a tool that depends on running on a consistent
environment, it should use a shebang of "/usr/bin/python3.6" instead
of "/usr/bin/env python3"?

Jeez. No. That is the _opposite_ of what I'm saying.

Because, wow, that would be exactly what is
already happening on my system. Why use /usr/bin/env and then wrap
something around it to force the environment, when you could just set
a correct shebang so it properly defines its execution environment?

Because the shebang is hardwired and inflexible.

Because it means hand patching (even scripted) a bazillion scripts to that they know their physical install.

Because it presumes detailed hardwired knowledge of the target system in a script which should work anywhere.

Instead a tiny _common_ shell script resembling this:

 #!/bin/sh
 # Run command in the official environment.
 exec env - PATH=/path/to/3.6venv/bin:/usr/sbin:/bin exec ${1+"$@"}

arranges things. The "env -" is aimed at "clean" daemon or install environments. You can do subtler or less intrusive things in other settings.

There are any number of variations available here that don't hardwire the environment into the various _scripts_, but into the invocation setting. Or just start an environment (eg a shell) with the desired environment.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to