This is an archive of the discontinued LLVM Phabricator instance.

clang-format: Explicitly use python3
AbandonedPublic

Authored by arsenm on Jun 29 2020, 6:51 AM.

Details

Summary

On Ubuntu 20.04, /usr/bin/env python always fails and requires
explicitly choosing python2 or python3.

Grep shows there are a lot of other places still relying on the old,
sensible behavior but these are the annoying ones I keep running into.

Diff Detail

Event Timeline

arsenm created this revision.Jun 29 2020, 6:51 AM

While I really like this idea of migrating the scripts to python3, I believe that the current plan is to allow until December for users to migrate, so this might be a bit premature :-(.

While I really like this idea of migrating the scripts to python3, I believe that the current plan is to allow until December for users to migrate, so this might be a bit premature :-(.

Is this documented somewhere? I think that every script being broken by default on all new distributions is a big problem. It's been 12 years, and python 2 has been EOL since January. I don't see why downstream projects would still be holding on dropping python 2

MyDeveloperDay added a project: Restricted Project.Jul 6 2020, 6:09 AM
MyDeveloperDay added a subscriber: MyDeveloperDay.

We may not be consistent across all of LLVM

$ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c
      6 #! /usr/bin/env python
      2 #! /usr/bin/env python3
      2 #! /usr/bin/python
      1 #!/bin/env python
    133 #!/usr/bin/env python
     13 #!/usr/bin/env python3
     49 #!/usr/bin/python
compnerd added a subscriber: arsen.Jul 6 2020, 2:58 PM

Thinking a bit more about this, using /usr/bin/env python ensures that we actually honour the python version that the user specifies because that allows the user control over the python symlink pointing to either python2 or python3. @arsen what do you think of just unifying on /usr/bin/env python across all the scripts?

We may not be consistent across all of LLVM

$ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c
      6 #! /usr/bin/env python
      2 #! /usr/bin/env python3
      2 #! /usr/bin/python
      1 #!/bin/env python
    133 #!/usr/bin/env python
     13 #!/usr/bin/env python3
     49 #!/usr/bin/python

My understanding is that explicitly requiring python3 may make sense if the script is not backward-compatible with python2, while requiring python means the version is not important.
At the end-of-year, we should be able to harmonize shebangs to #!/usr/bin/env python3 or #!/usr/bin/env python

We may not be consistent across all of LLVM

$ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c
      6 #! /usr/bin/env python
      2 #! /usr/bin/env python3
      2 #! /usr/bin/python
      1 #!/bin/env python
    133 #!/usr/bin/env python
     13 #!/usr/bin/env python3
     49 #!/usr/bin/python

My understanding is that explicitly requiring python3 may make sense if the script is not backward-compatible with python2, while requiring python means the version is not important.
At the end-of-year, we should be able to harmonize shebangs to #!/usr/bin/env python3 or #!/usr/bin/env python

Fixing this to be consistent would be an improvement

My understanding is that explicitly requiring python3 may make sense if the script is not backward-compatible with python2, while requiring python means the version is not important.
At the end-of-year, we should be able to harmonize shebangs to #!/usr/bin/env python3 or #!/usr/bin/env python

Fixing this to be consistent would be an improvement

Change proposed in https://reviews.llvm.org/D83857

arsenm abandoned this revision.Jul 15 2020, 7:49 AM