Re: Fwd: Re: Use of "python" shebang an installation error?

David Mathog <[email protected]> Wed, 22 Jul 2020 11:30:32 -0700
Newsgroups gmane.comp.python.distutils.devel
Message-ID <CAG5stg28gezCJX2YaEjAQmeta93KHt=C2G0a8A7TQL32CVVaVg@mail.gmail.com>
On Wed, Jul 22, 2020 at 3:41 AM Thomas Kluyver <[email protected]> wrote:
>
> On Tue, 21 Jul 2020, at 21:50, David Mathog wrote:
> > ./lib/python3.6/site-packages/pip/_vendor/appdirs.py:#!/usr/bin/env python
>
> Python packaging tools like pip generally differentiate between *scripts*, which are installed to be run from the command line, and *modules*, which are imported from other Python code. Files under site-packages are modules. Any special handling for shebangs, execute bits, or Windows .exe wrappers is usually done only for scripts.
>
> It's not unusual to see a shebang in modules - I think some editors put it in whenever you create a new Python file. But it doesn't usually do anything. If you want to run a module directly, the normal way now is with "python -m", which doesn't use the shebang.

So in summary:

1.  Invalid shebangs for modules in site-packages "should" be harmless - ignore
them and hope for the best.

2.  Shebangs for scripts "should" be correct.  (They are while still
inside a venv,
but that shebang has to be corrected when the installation is moved to a normal
environment, which my code is doing now.)

Scripts usually end up in a "bin" directory on linux.  Is that part of
the installation standard or could a package put them in an arbitrary
path (other than under "site-packages") under the venv's root, for
instance in a directory named "scripts"?   Fixing the shebangs by
processing only "bin" is easy, traversing the entire tree is a bit
messier.  It would be good not to have to do so if that will never
find an invalid shebang.

Thanks,

David Mathog


Thanks,
>
> Thomas
> --
> Distutils-SIG mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/distutils-sig.python.org/
> Message archived at https://mail.python.org/archives/list/[email protected]/message/HPTRB3S55WNAOUEHLQTWD2QDG5BL3HM6/
--
Distutils-SIG mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/distutils-sig.python.org/
Message archived at https://mail.python.org/archives/list/[email protected]/message/UL3LLIEDEG34ZNAUAXWI5KJHKU2NS3O6/