-
Notifications
You must be signed in to change notification settings - Fork 48
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
python3 support? #17
Comments
I just tried python 3 and it doesn't work for me either, so you're not missing anything :). We run with python 2.7 in all our environments. @hkrishna? I updated the readme to only say that python 2.6 and 2.7 are supported for now. Is the move to the protobuf 3 alpha required to support python 3? Some searching suggests that the metaclass syntax is problematic in older versions, but maybe it's possible to hack it to make it work? I would feel a little nervous moving to an alpha version of a new major release. |
Sounds like: protocolbuffers/protobuf#166 (comment)
I understand that, but in the same time it's an alpha3, so not the first round, and if you have unittests covering the use cases of MVT this can be quite safe to handle the upgrade. And BTW, that may be an alpha version here too, or just a branch that can be used, and then tested by people using python 3. :) |
Yea, a separate python 3 supported branch that tracks the protobuf alpha in the interim sounds fine to me. |
@rmarianski yes, we run python 2.7 in all our environments (as of few weeks ago) @yohanboniface a python3 branch sounds good.. we should probably add a line about the branch to the README as well |
Does that means that this package has worked in python 3 at some point in history? I can give a hand in porting the python part with pleasure, but honestly the protobuf API is Chinese for me. |
My guess is that it didn't work with python3 and the note in the readme was aspirational, but I could be completely wrong about that :) I myself haven't tried python3 before now. @hkrishna?
That sounds good. We probably won't get to move this forward on our end much, but I'd be happy to try and provide any support to help. Instead of bumping to protobuf 3 alpha, maybe what we could try instead is to just edit the generated generated files to work in either python 2 or 3 [1]. This might be end up being a shorter step in the interim. Btw, I haven't tried this, even with a simple example, so not sure if that's all it would take. [1] http://stackoverflow.com/questions/25036487/protocol-buffers-in-python-3-notimplementederror |
The "solution" linked seems like a python 3 only, I can make a POC in this direction, but will definitely profit some help when on the protobuf side. |
Yea, you're right. I was thinking of doing something like checking |
Not sure it will even parse, actually :/ |
So, if I do a quick and dirty python 3 compat on MVT side (see #18), I hit this:
so I'm not sure protobuf is really ready for python 3, actually :/ |
I think you'll have to regenerate the pbf wrappers when changing the protobuf version, and then account for whatever the api changes are. I tried a simple example with conditionally defining the classes, and you're right, it didn't parse. I think this strategy might still work by conditionally importing the classes from separate files. A proof of concept seemed to work for me, but I didn't get a chance to try it on the actual pbf wrappers. ie something like this: if sys.version_info.major == 2:
from metaclasses2 import Foo
elif sys.version_info.major == 3:
from metaclasses3 import Foo Where the metaclasses2 file has the python 2 syntax for defining metaclasses, and similarly for python 3. |
This trick may worth a try too:
Do you remember from the top of your head how would I do that? |
https://developers.google.com/protocol-buffers/docs/pythontutorial#compiling-your-protocol-buffers I suspect that you might need to use the version of |
Made a quick shot, seems that the
Extension seems to be now replace by Any, but at the moment I don't get my head around it. |
Actually, it's possible to keep proto2 syntax while using protoc 3.0.0: https://github.com/mapzen/mapbox-vector-tile/pull/18/files#diff-aa5a952047d7e07608d4371eccace6eeR3 |
Merged in the relevant pull request: #18 |
Just made a quick try, doesn't seem to work:
README says it's compatible. Do you have a hidden branch with the fixes or it's me missing something? :)
The text was updated successfully, but these errors were encountered: