[cfe-dev] python vs python3 shebang

Sam McCall via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 22 03:32:23 PDT 2021


Sounds like the python windows launcher, which the original spec says
*does* have py3 support
https://www.python.org/dev/peps/pep-0397/#python-script-launching
(But I don't have direct experience)

On Thu, Apr 22, 2021 at 12:21 PM Valeriy Savchenko <vsavchenko at apple.com>
wrote:

> Any idea where this hack lives? Would be nice to check if it's updated.
>
> It’s not a hack in the LLVM codebase (that would be easier). What I
> remember from previous discussions about Python, is that it finds
> #!/usr/bin/env python and uses installed Python2 interpreter or something,
> but doesn’t have the same trick for python3 or smth.
> But again, I can be very wrong here.
>
> -Valeriy
>
> On 22 Apr 2021, at 13:16, Sam McCall <sammccall at google.com> wrote:
>
> This is coming up now in part because debian testing has removed
> /usr/bin/python, so #!/usr/bin/env python no longer works on such systems.
>
> Relevant is https://www.python.org/dev/peps/pep-0394/, which I think
> basically says if we want to maintain scripts that work both on py2-only
> systems and py3-only systems there's no real answer other than adding an
> installer that rewrites the shebang lines :-(
>
> Agree that for tools used by LLVM devs #!/usr/bin/env python3 seems like a
> good change.
> For user-facing tools it seems we have 3 "easy" options for the checked-in
> scripts:
> A) use python2 and break on some new systems
> B) use python3 and break on some old systems
> C) use python and break on systems that don't provide the alias
> None of these seem nice.
>
> > As far as I remember, it’s trickier on Windows where there is a special
> hack for shebang to python specifically.
>
> Any idea where this hack lives? Would be nice to check if it's updated.
>
> On Thu, Apr 22, 2021 at 11:30 AM Haojian Wu <hokein at google.com> wrote:
>
>> Hello folks,
>>
>> We have a mixture of python(2) vs python3 shebang usage in llvm codebase.
>>
>> As python2 upstream support has ended, what's the LLVM policy here? Shall
>> we change the shebang to python3 for all scripts?
>>
>> - For llvm-developer-only python scripts (e.g.
>> clang-tidy/add_new_check.py), it is safe to do this change, as LLVM
>> development <https://llvm.org/docs/GettingStarted.html#software>
>> requires python >= 3.6
>> - For python scripts being interacted with people's workflow (e.g.
>> clang-format-diff.py), it seems unclear to me, changing the shebang would
>> break people's workflow on python2 machines.
>>
>> I have some patches (https://reviews.llvm.org/D101038,
>> https://reviews.llvm.org/D101037). What do people think?
>>
>>
>> Thanks,
>> Haojian
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210422/31f79170/attachment.html>


More information about the cfe-dev mailing list