Skip to content

google-cloud-compute fails to import on Python 3.14 — protobuf<5 pins incompatible protobuf 4.x (TypeError: Metaclasses with custom tp_new are not supported) #18127

Description

@liucy1983

Determine this is the right repository

  • I determined this is the correct repository in which to report this bug.

Summary of the issue

Context
I upgraded our project to Python 3.14 (CPython 3.14.7, via mise/uv). google-cloud-compute is a direct dependency (currently ==1.15.0). Its metadata declares protobuf>=3.19.5,<5.0.0dev, so the resolver installs the newest allowed protobuf on the 4.x line.

Expected Behavior:
import google.cloud.compute works on Python 3.14, the same way it works on 3.11–3.13.

Actual Behavior:
Importing the package (or any package that pulls in protobuf, e.g. temporalio) immediately raises TypeError: Metaclasses with custom tp_new are not supported. on Python 3.14. protobuf 4.x ships a C extension whose metaclass uses a custom tp_new, which CPython 3.14 now rejects. The protobuf<5 upper bound blocks the only line (protobuf 6.x) whose C extension is fixed for 3.14.

API client name and version

google-cloud-compute==1.15.0

Reproduction steps: code

file: main.py

importgoogle.cloud.compute# raises TypeError on Python 3.14print("ok")
### Reproduction steps: supporting filesNoextradatafilesarerequired. Theonlyrelevantconstraintistheversionpinresolvedfromthedependency:
file: requirements.txt (minimal)
google-cloud-compute==1.15.0### Reproduction steps: actual results
$ python3-c"import google.cloud.compute"Traceback (mostrecentcalllast):
File"<string>", line1, in<module>File".../site-packages/google/cloud/compute/__init__.py", line18, in<module>
...
File".../site-packages/google/protobuf/internal/api_implementation.py", line51, in<module>if_CanImport('google._upb._message'):
File".../site-packages/google/protobuf/internal/api_implementation.py", line41, in_CanImportmod=importlib.import_module(mod_name)
File".../lib/python3.14/importlib/__init__.py", line88, inimport_modulereturn_bootstrap._gcd_import(name, level)
TypeError: Metaclasseswithcustomtp_newarenotsupported.
SettingPROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=pythondoesNOThelp: protobufprobesgoogle._upb._messagefirstandtheprobeitselfraisesTypeError (notImportError), sothepure-Pythonfallbackneverengages.
### Reproduction steps: expected results
$ python3-c"import google.cloud.compute"ok### OS & version + platformmacOS27 (GoldenGate), AppleSilicon (arm64) ### Python environmentPython3.14.7### Python dependenciespiplist|grep-iE"protobuf|google-cloud-compute|google-api-core|proto-plus"google-api-core2.27.0google-cloud-compute1.15.0proto-plus1.26.1protobuf4.25.9# forced by google-cloud-compute <5.0.0dev### Additional contextRootcausegoogle-cloud-computepins`protobuf>=3.19.5,<5.0.0dev`. OnPython3.14:
-protobuf4.25.9 (highestallowed) ->Cextensionfailswith`TypeError: Metaclasses with custom tp_new are not supported.`
(CPython3.14forbidscustom-tp_newmetaclasses).
-protobuf6.x (Cextensionfixedfor3.14) ->blockedbythe<5upperbound.
Thisisaharddeadlockforanyonerunninggoogle-cloud-computeonPython3.14.
Evidencethat6.xworksatruntimeWeforcedprotobuf6.33.6 (uv`override-dependencies = ["protobuf>=6.31.0,<7"]`)
andverifiedonPython3.14.7:
-importgoogle.cloud.compute->OK-importtemporalio (alsoprotobuf-dependent) ->OK-protobufmessageserializationround-trips->OK-temporaliogenerated*_pb2round-trips->OKSothe<5upperboundisoverlyconservative; theclientrunsfineonprotobuf6.x.
SuggestedfixLoosentheprotobufupperboundingoogle-cloud-compute, e.g. to<8.0.0
(consistentwiththeothergoogle-cloud-*clients) oratleast<7.0.0, andaddaPython3.14CIjobsothisregressioniscaughtearlier.
Workaround (foraffectedusers)
-Withuv: override-dependencies= ["protobuf>=6.31.0,<7"] in [tool.uv].
-Withpip: pipinstall--no-deps"google-cloud-compute==1.15.0""protobuf>=6.31.0"thenresolvetherestnormally.
Related: temporalioalreadyallowsprotobuf>=3.20,<8.0.0, confirming6.xistheintendedtargetline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions