Windows change: `python.bat` is no longer in the top depot_tools directory

173 views
Skip to first unread message

Dirk Pranke

unread,
Mar 9, 2021, 10:59:55 PM3/9/21
to chromium-dev, Josip Sokcevic
Hi all,

If you do not develop on Windows, you can ignore this note ...

As of a couple hours ago, we've modified depot_tools so that it no longer generates `python2.bat` and `python3.bat` in the top-level directory as part of its bootstrapping process.

This means that if you have depot_tools in your $PATH (and you likely do and should), you may no longer have `python` in your path. This will likely cause problems (for example, GN will expect there to be a `python` in your $PATH by default).

To get around this, you have a few options:

1) install a copy of Python2 and put it in your PATH yourself.

2) add depot_tools/python2-bin to your $PATH (which adds a `python2.bat`), and then create a wrapper `python.bat` somewhere that calls that.

3) ensure that you have at least a `python2` in your $PATH (see above), and then run `gn gen --script-executable=python2`.

Why did we make this change, and why is this so confusing?


The short answer is that including a Python wrapper in the same directory as other tools that you need (like gclient, gn, and so on) causes problems for people that need their own Python installs (particularly Python3 installs), and that Windows was always unusual in this regard. On other platforms, we made you manage your own Python.

In addition, we need to make progress on migrating everything to python3, and we'll shortly want people to have `python3` in their path (which we provide in depot_tools/python-bin; feel free to add that now as part of your changes), so we figured we might as well be disruptive now while we can. We can now consistently (across Mac/Win/Linux) tell people to (1) add `depot_tools/python2-bin` to your path if you need `python2` (2) add `depot_tools/python3-bin` to your path if you need `python3`, and (3) if you still need `python`, figure out which one you need and wrap that yourself.

I will shortly be landing a change (hopefully) to have GN use `python2` by default instead of `python`. And, hopefully soon that'll also change to `python3`.

I apologize for the disruption, there wasn't a great way to coordinate all of these things at once, but we're trying to minimize the length of the disruption as best we can.

-- Dirk

Dirk Pranke

unread,
Mar 9, 2021, 11:47:37 PM3/9/21
to chromium-dev, Josip Sokcevic
Well, never mind ... :)

We hit at least a couple of bumps, so the change has been rolled back. 

But it's coming again, Real Soon Now! :). We'll try to make sure that the next attempt will land a bit more smoothly (e.g., get GN to use `python2` or `python3` instead of `python`), but you'll still need to adjust your paths roughly as I described before.

-- Dirk
Reply all
Reply to author
Forward
0 new messages