google-cloud-python
google-cloud-python copied to clipboard
Failed to import viewport by wrong import path
Determine this is the right repository
- [X] I determined this is the correct repository in which to report this bug.
Summary of the issue
Context
I tried to build a message with viewport.
Expected Behavior:
Run as normally without exception.
Actual Behavior:
Failde with ImportError: cannot import name 'viewport_pb2' from 'google.geo.type'
API client name and version
google-geo-type v0.3.10
Reproduction steps: code
file: sample.proto
syntax = "proto3";
import "google/geo/type/viewport.proto";
import "google/protobuf/timestamp.proto";
message ImageItem {
string path = 1;
google.protobuf.Timestamp timestamp = 2;
google.geo.type.Viewport viewport = 3;
}
file: sample_pb2
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: sample.proto
# Protobuf Python Version: 5.28.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
28,
2,
'',
'sample.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from google.geo.type import viewport_pb2 as google_dot_geo_dot_type_dot_viewport__pb2
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0csample.proto\x1a\x1egoogle/geo/type/viewport.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"u\n\tImageItem\x12\x0c\n\x04path\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x08viewport\x18\x03 \x01(\x0b\x32\x19.google.geo.type.Viewportb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'sample_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_IMAGEITEM']._serialized_start=81
_globals['_IMAGEITEM']._serialized_end=198
# @@protoc_insertion_point(module_scope)
Reproduction steps: supporting files
https://github.com/ringsaturn/proto-debug
Reproduction steps: actual results
file: sample_pb2
python sample_pb2.py
Traceback (most recent call last):
File "~/proto-debug/sample_pb2.py", line 26, in <module>
from google.geo.type import viewport_pb2 as google_dot_geo_dot_type_dot_viewport__pb2
ImportError: cannot import name 'viewport_pb2' from 'google.geo.type' (~/proto-debug/.venv/lib/python3.12/site-packages/google/geo/type/__init__.py)
Reproduction steps: expected results
file: sample_pb2
OS & version + platform
macoS
Python environment
3.12
Python dependencies
Package Version
------------------------ ---------
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.4.0
google-api-core 2.21.0
google-auth 2.35.0
google-geo-type 0.3.10
googleapis-common-protos 1.65.0
grpcio 1.67.0
grpcio-status 1.67.0
idna 3.10
proto-plus 1.25.0
protobuf 5.28.3
pyasn1 0.6.1
pyasn1-modules 0.4.1
requests 2.32.3
rsa 4.9
urllib3 2.2.3
Additional context
A repo for debug: https://github.com/ringsaturn/proto-debug
Thanks for filing this issue! We'll investigate.