Page MenuHomePhabricator

Puppet: forbid new Python2 code
Open, Needs TriagePublic


Going towards the end of life of Python2 (18 months from now), we should start having CI vote -1/-2 if there is any new python2 files pushed in the repository.

Of course this is pretty easy to be done just checking the shebang, while might be impossible for scripts that don't have a shebang

Event Timeline

Volans created this task.Jun 20 2018, 3:07 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 20 2018, 3:07 PM
Vvjjkkii renamed this task from Puppet: forbid new Python2 code to rkaaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from rkaaaaaaaa to Puppet: forbid new Python2 code.Jul 2 2018, 8:52 AM
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.

Almost certainly impossible to catch all Python 2 code that doesn't have a shebang and is compatible with Python 3 syntax. Hopefully that's a pretty small set of things.
Should probably audit everything ending in .py without a python3 shebang and check what we're running it under (if python 2, port it)

Just in puppet checking shebangs:

alex@alex-laptop:~/Development/Wikimedia/Operations-Puppet (production)$ find -iname '*.py' | xargs grep -E "^#!" | wc -l
alex@alex-laptop:~/Development/Wikimedia/Operations-Puppet (production)$ find -iname '*.py' | xargs grep -E "^#!" | grep -v python3 -c

Another option might be to create a job that executes the python3 compiler against the script. Caveat: I am not sure what potential for abuse this brings to the table.

find -iname '*.py' | xargs -n1 python3 -m py_compile
Bstorm added a subscriber: Bstorm.Nov 8 2018, 7:09 PM
GTirloni removed a subscriber: GTirloni.Dec 19 2018, 3:55 PM
Krenair added a comment.EditedMar 15 2019, 7:56 PM

(People interested in this task may also be interested in T197803: Python2: track Py2 softwares)

Xqt added a subscriber: Xqt.Jul 24 2019, 8:36 AM