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

Python code generator option to generate relative imports #90

Closed
virtuald opened this issue Nov 19, 2014 · 2 comments
Closed

Python code generator option to generate relative imports #90

virtuald opened this issue Nov 19, 2014 · 2 comments

Comments

@virtuald
Copy link

Using protoc 2.6.0 installed on OSX via brew, other _pb2.py files are imported like so:

import file_pb2

The project I'm working on sticks the protobuf generated files as a subpackage of its main python package, which seems like a pretty reasonable thing to do. Because those packages use relative imports, I'd like a protobuf option that generates this instead:

from . import file_pb2

This may be related to #7 (or solved there), as I'm using python 3 and I believe that is when python starts being picky about absolute/relative imports.

@jleclanche
Copy link

Confirming the issue. Using relative imports solves it and should work fine on 2.7.

@acozzette
Copy link
Member

Let me close this issue since it appears that it duplicates #1491 and most of the discussion is happening on that issue.

TeBoring pushed a commit to TeBoring/protobuf that referenced this issue Jan 19, 2019
Added new encoder/decoder that operates on upb_msglayout.
bithium pushed a commit to bithium/protobuf that referenced this issue Sep 4, 2023
Added new encoder/decoder that operates on upb_msglayout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants