Python 2 versus 3

91 views
Skip to first unread message

Dave Mielke

unread,
Mar 28, 2021, 8:35:51 PM3/28/21
to Chromium Browser Development
When I run: autoninja -C "${chromeReleaseSubdirectory}" chrome

with Python 3(.9) it fails and tells me that Python 2.6 or 2.7 is required. When I run it with Python 2(.7) I'm told that "unicode" isn't defined:

File "src/third_party/dom_distiller_js/dist/python/plugin_pb2.py",
line 39, in <module> 11174
has_default_value=False, default_value=unicode("", "utf-8"),

So which version of Python should I be using, and, even in that case, how can the problem that version is reporting be resolved?

--
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Da...@Mielke.cc | Ottawa, Ontario | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada K2A 1H7 |

Bruce Dawson

unread,
Mar 29, 2021, 5:46:33 AM3/29/21
to Chromium-dev, dave.a...@gmail.com
Autoninja itself will run fine with Python 2 (used by default on Linux) or 3 (used always on Windows). However autoninja then runs ninja which then runs all of Chromium's build steps. Some of these work with Python 3, but many do not.

We are working on transitioning to Python 3 but this is a slow process. There have been several attempts to switch to using Python 3 for most of the build steps, but so far each attempt has found more issues. Progress is being made. When we do switch then Python 3 will be the default but Python 2 will still be needed for many build steps until we have time to update all of them. The steps that require Python 2 are tagged as such so that ninja will properly run them under Python 2.

Some extra information that you can give so that we can help you:
1) What Chromium hash are you synced to? You may be synced to the tree at a point where we are in the middle of an experimental change of Python versions. Syncing to latest may fix things.
2) What was the full error message when you ran autoninja using python3?
3) How are you changing what version of python is invoked? Chromium's build expects (I think) that python refers to python2, and that python3 refers to python3, so having python refer to python3 is likely to cause issues (I think).

It's all a bit messy due to the complexity of the situation, but we are making progress.

Dave Mielke

unread,
Mar 29, 2021, 6:17:23 AM3/29/21
to Bruce Dawson, Chromium-dev
[quoted lines by Bruce Dawson on 2021/03/29 at 02:46 -0700]

>Autoninja itself will run fine with Python 2 (used by default on Linux)

That was before, but now, on modern systems, there either isn't /usr/bin/python at all or it symlinks to python3. The move is on for things to say what they want, e.g. explicitly say python2 or python3. Perhaps you could change all your python references to python2. That would've helped and, except maybe for very old systems, shouldn't break anything.

>We are working on transitioning to Python 3 but this is a slow process.

No doubt. :-(

>The steps that require Python 2 are tagged as such so that
>ninja will properly run them under Python 2.

I guess not all of them yet. My /usr/bin/ has all three, i.e. python, python2, and python3. It was only when changing the python symlink to point to python2 (instead of python3) that things started to work. Now, of course, who knows what else on the system I've broken.

>1) What Chromium hash are you synced to? You may be synced to the tree at a
>point where we are in the middle of an experimental change of Python
>versions. Syncing to latest may fix things.

I'm new at this so I'm not sure how to get you the answer or how to sync to something else. Is it just running gclient sync? If so, I did that about a week ago.

>2) What was the full error message when you ran autoninja using python3?

It was: Could not run pkg-config.

As I now know, this message is misleading. What it really was looking for is pkg-config with a cross-build prefix even though it's a native build, i.e. it was looking for x86_64-pc-gnu-linux-pkg-config. It turns out that this actually does exist on Debian but not on Fedora. I personally think it's a Python 3 bug.

>3) How are you changing what version of python is invoked? Chromium's build
>expects (I think) that python refers to python2, and that python3 refers to
>python3, so having python refer to python3 is likely to cause issues (I
>think).

Yes, I finally changed the symlink and all became well. As sugested above, perhaps there are more things that still need to be chagned from python to python2.

Well, all became almost well. There's a required package - python2-setuptools - that isn't listed in the Fedora section of the document. The error of course didn't say that. It was complaining that pkg_resources wasn't defined.

>It's all a bit messy due to the complexity of the situation, but we are
>making progress.

Thanks for answering and explaining.

Bruce Dawson

unread,
Mar 29, 2021, 2:33:34 PM3/29/21
to Da...@mielke.cc, Chromium-dev
To get the current Chromium hash run "git log -1 --oneline". That will tell us what version of the code you are using (it changes hundreds of times a day).

If you pull to latest then don't forget to run gclient sync afterwards in order to keep all of the dependencies synchronized.
--
Bruce Dawson

Dave Mielke

unread,
Mar 29, 2021, 2:41:27 PM3/29/21
to Bruce Dawson, Chromium-dev
[quoted lines by Bruce Dawson on 2021/03/29 at 08:31 -1000]

>To get the current Chromium hash run "git log -1 --oneline". That will tell
>us what version of the code you are using (it changes hundreds of times a
>day).

Oh, okay. That's what you meant. It's: 66abb47a9e45f809d9631ca8a5da9c6e4ef86fe5

It's from March 4, so it's somewhat older than I'd thought.

Would you guys like the shell script (bash) that I wrote to install all of the required Fedora packages? The one you have uses apt, so it'll only work on Debian systems - Fedora uses dnf. Also, the package names aren't all the same anyway.

>If you pull to latest then don't forget to run gclient sync afterwards in
>order to keep all of the dependencies synchronized.

Okay, so this is just git + gclient sync. Plenty easy enough! Thanks.
Reply all
Reply to author
Forward
0 new messages