Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'builder' from 'google.protobuf.internal' #824

Open
weiweihuanghuang opened this issue Feb 7, 2024 · 6 comments

Comments

@weiweihuanghuang
Copy link

I updated the googlefonts-project-template for my Fragment Mono repo and now when I try to make build locally, I get the follwoing error:

▶ make build
rm -rf fonts
(for config in sources/config*.yaml; do . venv/bin/activate; gftools builder $config; done)  && touch build.stamp
Traceback (most recent call last):
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/bin/gftools", line 8, in <module>
    sys.exit(main())
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/scripts/__init__.py", line 90, in main
    mod = import_module(f".{module}", package)
  File "/usr/local/Cellar/[email protected]/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/builder/__init__.py", line 122, in <module>
    from gftools.builder.schema import schema
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/builder/schema.py", line 16, in <module>
    from gftools.packager import CATEGORIES
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/packager.py", line 43, in <module>
    from gftools.util import google_fonts as fonts
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/util/google_fonts.py", line 40, in <module>
    import gftools.fonts_public_pb2 as fonts_pb2
  File "/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/gftools/fonts_public_pb2.py", line 5, in <module>
    from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/Users/weihuang/type-build-projects/fragment-mono/venv/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)
make: *** [build.stamp] Error 1
@weiweihuanghuang
Copy link
Author

(I rolled back my repo so I could work on it but it happenned after I ran make update-project-template today)

@simoncozens
Copy link
Contributor

Looks like the protobuf API changed, and we either need to regenerate the _public_pb2.py files, or pin the protobuf version, or preferably both. Probably a gftools issue rather than a template one.

@simoncozens simoncozens transferred this issue from googlefonts/googlefonts-project-template Feb 7, 2024
@m4rc1e
Copy link
Collaborator

m4rc1e commented Feb 7, 2024

Protobuf is already pinned, https://github.com/googlefonts/gftools/blob/main/pyproject.toml#L41. I'll take a look in a min.

@simoncozens
Copy link
Contributor

fd495cf regenerated the _pb2.py file; I don't know what version of the compiler it used (the protobuf team closed my PR which adds the compiler version number to the generated files, grr.) but now it uses google.protobuf.internal.builder whereas it didn't before. So yeah, we either have to recompile or move to a new protobuf dependency.

@weiweihuanghuang
Copy link
Author

Just checking if this is fixed, i.e. can I update my gf-project-template?

@m4rc1e
Copy link
Collaborator

m4rc1e commented May 21, 2024

@weiweihuanghuang would you mind checking again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants