<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr">Yes, py.exe sniffs shebangs and dispatches accordingly.</div><div dir="ltr"><br></div><div dir="ltr">In the context of build systems, shebangs should never come into play because the build system should invoke the script with the Python interpreter detected at configure time. E.g. “$PYTHON3 my_script”. (I don’t know if this is the case with LLVM.)</div><div dir="ltr"><br></div><div dir="ltr">For what’s under source control, it is best to default to “#!/usr/bin/env python2.7” and “#!/usr/bin/env python3[.x]” (.x to target a specific release, but that’s generally not necessary/wanted, as it precludes using newer versions).</div><div dir="ltr"><br></div><div dir="ltr">It is true some environments don’t have the python2[.x] or python3[.x] aliases or the “python” alias violates PEP desired behavior (I think Homebrew falls in this boat). You can leave it up to downstream packagers to deal with this mess. But this being an established project with a real build system, you’ll probably want to teach the installer to rewrite shebangs using an optional value provided to the configuration step.</div><div dir="ltr"><br><blockquote type="cite">On Apr 22, 2021, at 03:32, Sam McCall via cfe-dev <cfe-dev@lists.llvm.org> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Sounds like the python windows launcher, which the original spec says *does* have py3 support<div><a href="https://www.python.org/dev/peps/pep-0397/#python-script-launching">https://www.python.org/dev/peps/pep-0397/#python-script-launching</a><br></div><div>(But I don't have direct experience)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021 at 12:21 PM Valeriy Savchenko <<a href="mailto:vsavchenko@apple.com">vsavchenko@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><blockquote type="cite"><div dir="ltr"><div>Any idea where this hack lives? Would be nice to check if it's updated.</div></div></blockquote>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.<div>But again, I can be very wrong here.</div><div><br></div><div>-Valeriy<br><div><br><blockquote type="cite"><div>On 22 Apr 2021, at 13:16, Sam McCall <<a href="mailto:sammccall@google.com" target="_blank">sammccall@google.com</a>> wrote:</div><br><div><div dir="ltr">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.<div><br></div><div>Relevant is <a href="https://www.python.org/dev/peps/pep-0394/" target="_blank">https://www.python.org/dev/peps/pep-0394/</a>, 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 :-(</div><div><br></div><div>Agree that for tools used by LLVM devs #!/usr/bin/env python3 seems like a good change.</div><div>For user-facing tools it seems we have 3 "easy" options for the checked-in scripts:</div><div>A) use python2 and break on some new systems</div><div>B) use python3 and break on some old systems</div><div>C) use python and break on systems that don't provide the alias</div><div>None of these seem nice.</div><div><br></div><div>> As far as I remember, it’s trickier on Windows where there is a special hack for shebang to python specifically.</div><br><div>Any idea where this hack lives? Would be nice to check if it's updated.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021 at 11:30 AM Haojian Wu <<a href="mailto:hokein@google.com" target="_blank">hokein@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello folks,<div><br></div><div>We have a mixture of python(2) vs python3 shebang usage in llvm codebase.</div><div><br></div><div>As python2 upstream support has ended, what's the LLVM policy here? Shall we change the shebang to python3 for all scripts? </div><div><br></div><div>- For llvm-developer-only python scripts (e.g. clang-tidy/add_new_check.py), it is safe to do this change, as <a href="https://llvm.org/docs/GettingStarted.html#software" target="_blank">LLVM development</a> requires python >= 3.6 </div><div>- 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.</div><div><br></div><div>I have some patches (<a href="https://reviews.llvm.org/D101038" target="_blank">https://reviews.llvm.org/D101038</a>, <a href="https://reviews.llvm.org/D101037" target="_blank">https://reviews.llvm.org/D101037</a>). What do people think?</div><div><br></div><div><br></div><div>Thanks,</div><div>Haojian</div></div>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>
<span>_______________________________________________</span><br><span>cfe-dev mailing list</span><br><span>cfe-dev@lists.llvm.org</span><br><span>https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</span><br></div></blockquote></body></html>