Python 2 and presubmits

14 views
Skip to first unread message

Bruce Dawson

unread,
Nov 9, 2022, 6:32:36 PM11/9/22
to Dawn Graphics
I'm trying to help move Chromium off of Python 2 and I noticed that dawn has fourPRESUBMIT.py files that are not tagged as running in Python 3. These are:

dawn\PRESUBMIT.py
dawn\infra\config\PRESUBMIT.py
dawn\src\dawn\node\PRESUBMIT.py
dawn\tools\PRESUBMIT.py

Since these scripts are run by depot_tools and also invoke functionality in depot_tools these are preventing depot_tools from being fully switched to Python 3. depot_tools should have been printing warnings for a while when presubmits are run.

I can help with the migration process - there are some non-obvious steps to moving off of Python 2, in addition to the obvious changes in syntax required.

Bruce Dawson

unread,
Nov 9, 2022, 6:32:36 PM11/9/22
to Dawn Graphics
Apologies if this is a duplicate post

I'm trying to help move Chromium off of Python 2 and I noticed that dawn has four PRESUBMIT.py files that are not tagged as running in Python 3. These are:

third_party\dawn\PRESUBMIT.py
third_party\dawn\infra\config\PRESUBMIT.py
third_party\dawn\src\dawn\node\PRESUBMIT.py
third_party\dawn\tools\PRESUBMIT.py

Since these scripts are run by depot_tools and also invoke functionality in depot_tools these are preventing depot_tools from being fully switched to Python 3. It's possible that this is not known to the team, although depot_tools should have been printing warnings for a while.

Telling depot_tools to invoke a particular PRESUBMIT.py file under Python 3 is as "simple" as adding this line, typically near the top:

USE_PYTHON3 = True

Some syntax fixes may be needed of course.

The next issue is that the PRESUBMIT.py script may be calling out to some child scripts and these scripts may be using Python 2. Unfortunately there are many ways to invoke a child script and there as many ways to control which version of Python is invoked. This bug comment covers most of them:

https://bugs.chromium.org/p/chromium/issues/detail?id=1313804#c61

I'm happy to consult/review/whatever as needed, on the Python 3 migration and any presubmit questions in general. Apologies for the messiness. Some of it was inevitable, but there were also mistakes made along the way.

Bruce Dawson

unread,
Nov 10, 2022, 1:18:33 AM11/10/22
to Dawn Graphics
After sending the message twice (sorry, I didn't see the message saying that it need to be approved before it would appear) I realized that there was a bug in my script where it wouldn't find the Python3 markers if the line had carriage-return line-feed endings. So, it looks like Dawn is in the clear. Apologies for the misinformation, and thanks for being (as far as I can tell) Python 3 only in your presubmits.

If there are any child scripts running Python 2 in your presubmits then I wouldn't be able to tell, but I have no reason to believe that is happening, and you would have seen warning messages (or would see them if running "git cl presubmit --force --all" for sure).
--
Bruce Dawson, he/him

Reply all
Reply to author
Forward
0 new messages