[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ✘python shebang, yet again

From: Gary E. Miller
Subject: Re: ✘python shebang, yet again
Date: Thu, 24 Sep 2020 16:42:32 -0700

Yo Greg!

On Thu, 24 Sep 2020 18:56:16 -0400
Greg Troxel <> wrote:

> "Gary E. Miller" <> writes:
> > One way to build gpsd for a python that is not the current python
> > is to use target_python.  So if you default Python is 2.7, and you
> > want to build for Python 3, do this:
> >
> > scons config=force target_python=python3
> >
> > But that leaves the python shebang in the gpsd python clients to be
> > the PEP 394 default:
> >
> >     #!/usr/bin/env python  
> Indeed, PEP 394 appears to exist in an alternate universe from people
> that actually make packaging systems work!

Not all of them.  Some distros have no trouble with PEP 394.

> > You fix that by using the pyshebang option:
> >
> > scons config=force target_python=python3
> > python_shebang="/usr/bin/env python3"  
> Agreed this is how it is now; pkgsrc does:
>   # Use the python chosen by pkgsrc, not "/usr/bin/env python"
>   SCONS_ARGS+=    python_shebang=${PYTHONBIN}
>   SCONS_ARGS+=    target_python=${PYTHONBIN}
> (which makes the shebang not have env).

Which can fail because the shebang MUST be a full path.  So, not
a completely valid answer.  target_python=python3 is very common and
will fail.

> > scons config=force target_python=/usr/bin/python3
> >
> > The python shebang would be:
> >
> > #!/usr/bin/env /usr/bin/python3  
> That makes sense to me, except that the target python should be a full
> path,

Uh, why?  I never, ever, type a full path to any python.

> and there is no need to use env.  The shebang would then be
> #!/usr/bin/python3

Which, as above, fails for the most common case where target_python is
noa full path.

> > scons config=force target_python=python3
> > python_shebang="/usr/bin/env python"  
> That's a bad idea, but good that people that want that can do it
> without patching.

Uh, lost me.  That is PEP 394 compliant and is preferred on Gentoo.

> > Comments?  Suggestions?  
> I know I'm an outlier, but I think that a particular python version --
> which means a fully-qualified path to an actual version, not pyhon,
> not python2, not python3, but something like /usr/pkg/bin/python3.7,
> or /usr/bin/python3.8 -- should be found at configure time and
> substituted in.

Rishard Laager tried that for weeks on NTPsec, never got it to work for
all distros.  Much of the world is not like your distro.

> So I think that what you describe is a big step in
> the right direction, arguably 90% of the right step in that packaging
> systems putting in scons args is painless compared to having to patch.

You miss the point.  scons already uses scons args, the point is to remove
one of them, by default.

> I think that python_shebang needs to be usable to force the shebang to
> not use env, even if that isn't the default.

That is how python_shebang works now.  So no problem there.

> But I don't see anything
> in your proposal that changes that; you are only proposing an
> incrementally more sensible default.

Agreed.  But not like your default.

I could live with removing /usr/bin/env IFF target_python is a full
path.  Otherwise keep the /usr/bin/env

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpO9xtiuTg8w.pgp
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]