Harry Terkelsen db8a64f90d
Verify old version of Python has the lib2to3 import available (#170187)
The `yapf.sh` script checks for specific "known-to-work-with-YAPF"
versions of Python to run YAPF with. On my machine, I have `python3.11`
and `python3.12` (`python3` is a symlink to `python3.12`). However, the
`python3.11` release doesn't have `lib2to3` so the YAPF script fails
with:

```
Checking Python formatting...
To fix, run `et format` or:                                                                                   

git apply <<DONE
  /usr/local/google/home/het/Projects/flutter/engine/src/flutter/tools/gn
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/google/home/het/Projects/flutter/engine/src/flutter/third_party/yapf/yapf/__main__.py", line 16, in <module>
    import yapf
  File "/usr/local/google/home/het/Projects/flutter/engine/src/flutter/third_party/yapf/yapf/__init__.py", line 35, in <module>
    from yapf.yapflib import errors
  File "/usr/local/google/home/het/Projects/flutter/engine/src/flutter/third_party/yapf/yapf/yapflib/errors.py", line 16, in <module>
    from lib2to3.pgen2 import tokenize
ModuleNotFoundError: No module named 'lib2to3'

DONE
```

On my Ubuntu machine I cannot install `lib2to3` through normal APT
packages; `apt install python3.11-lib2to3` fails since that package has
been obsoleted. I've been able to work around this by manually editing
the `yapf.sh` script to check if `lib2to3` can be imported before using
that version of Python.

See https://github.com/flutter/flutter/issues/158384

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2025-06-10 22:51:57 +00:00
..

Flutter Engine

Setting up the Engine development environment

See here

gclient bootstrap

Flutter engine uses gclient to manage dependencies.

If you've already cloned the flutter repository:

  1. Copy one of the engine/scripts/*.gclient to the root folder as .gclient:
    1. Googlers: copy rbe.gclient to enable faster builds with RBE
    2. Everyone else: copy standard.gclient
  2. run gclient sync from the root folder