-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Status of Python 3 (3.4+) support? #646
Comments
I am extremely interested in merging PRs to fully support Python 3. I commented on #166 that I am interested in merging it, but @tseaver said he didn't have time to update it. I wasn't sure the status of your PR #66. As @tamird mentioned we no longer need to support Python 2.5, and I'm interested in making a cleaner code-base that drops 2.5 support. Here is what I am especially interested in:
I have been working on (2) but my progress is slow since I am not an expert in the Python tool ecosystem. I would greatly appreciate any help with this. |
To run tests under multiple versions one would just set up virtualenv for each version and run tests under them. What kind of build process are you looking for? How are you going to run it? |
@Kentzo |
I want a |
Ideally the |
At the very least, the documentation should be updated (changelog for v2.6.0) to remove claims that Python 3 is supported. This is misleading at best. |
@Kentzo I would be more than happy to assist you with this. If you don't plan on working on this yourself, could you list out the steps we could take to get to 2.7/3.x support? I'm not a python expert, but I've been somewhat successful improving protobuf's python support. |
I've taken the work @tseaver started and merged in the latest code from upstream here: https://github.com/dano/protobuf/tree/py2_py3_straddle. tox runs just fine, but a bunch of new tests that have been added are now failing on Python 3, along with a couple of regressions on Python 2.7. If I get some more free time I'll start trying to fix the issues, but it at least gets us closer... |
@dano Thanks for rescuing that work! |
Ok, I've fixed a couple of long/int compatibility issues on the Python 2 side. There are two Python 2 tests that still fail, but the reason for the regression is a symptom of a fairly large problem on the Python 3 side.
So, there's a whole bunch of work here to fix every single call to |
@haberman You mention a desire to support Python 2.6 - it looks like the current master branch doesn't support 2.6 in its current state, lots of tests use 2.7+ only assertions, and |
@dano Thanks so much for this work! I am very eager to merge it. I've been working on other things, but I will get to your detailed comments as soon as I can. Re: Python 2.6, that is a good question. I think we might have to do a cost-benefit weighing. I'm told that some relevant versions of RedHat still support only 2.6. How much uglier does it make the code to support 2.6? |
@haberman The quickest and easiest way to get Python 2.6 working would be to require that the backports of |
@dano Could we require the backports only for Python 2.6? Python 2.7+ users shouldn't need them right? |
@haberman Right, we can make sure setup.py only installs the backports if we detect Python 2.6 is installed, and that we'll always favor the Python 2.7 versions of the modules in the code. |
Sounds great to me! |
@haberman Ok, I've got all tests passing Python 2.6 and 2.7. The string/bytes issues goes even deeper than I originally thought, though; there's some non-standard encoding required in |
It also appears that the cpp implementation is broken on Python 3, because of http://bugs.python.org/issue22079. I hit |
That is super unfortunate, that this restriction on inheriting static types from dynamic types was added to Python. Without that, it will be much more difficult (if it's possible at all) to use the abstract base collections to make our maps implement all the methods that Python users expect from To work around that we'll probably have to re-implement the built-in |
Could it be altered to inherit from |
That wouldn't work -- dict provides its own storage, and it's important that |
Just ran into this problem myself :( |
Ok, we should get your work merged ASAP. Let's disable the specific tests that fail for now (with some explanatory comments about what is broken). Then we can iterate on fixes for what is broken. @dano, want to send a PR with your work on this? Thanks! |
Just to expand on my previous comments slightly: we need to make sure that the Travis build continues to pass. So if we have to disable the Python 3 tests for now to keep Travis passing, let's do that, but then iterate on fixes until it's possible re-enable the broken tests. |
I agree about making PR. At the very least all remaining issues with syntax will be addressed. |
@haberman Sounds good. For now I've got all Python 3 tests disabled via tox.ini, so only Python 2.6/2.7 will run. Running I'll try to get the pull request submitted tonight; I'm at a conference this week so my time during the day is a bit limited. |
Thanks @dano! I'll look forward to the PR. By the way, I should mention one other thing I've been trying to get working that is related to your work. We have a set of conformance tests in https://github.com/google/protobuf/tree/master/conformance that are designed to be tested against all implementations. They currently run against C++, Java, Ruby, and C#. I'd really like to get them running against Python also, but ran into trouble getting this to work. It would probably make the most sense to run these as a part of the tox run, so we get the same version testing matrix (ie. 2.6, 2.7, 3.3, 3.4) as we do for the regular Python tests. I did wrote the actual code to implement this for Python: master...haberman:python-conformance2 I got this to work for the pure-Python implementation, but was not successful getting it to work with the C++ implementation. I couldn't figure out how to run it in such a way that it would find the .so correctly. If this would be relatively easy to add to your work, that would be awesome. Or even if you just had tips for how to get this working. |
I've created the pull request here: #722 @haberman I'm having some laptop issues making it hard to test the conformance test stuff, but when I tried running it, the pure Python stuff passed, while a few of the CPP tests failed with errors like this (this is not the complete output):
It sounds like this isn't what you were seeing? |
@dano Those results are perfect and as expected! The C++ parser has a few bugs in it, which is why you're seeing conformance problems there that don't show up with pure-Python. For each language we have a "failure list": the list of tests that are known to be broken. Here is the one for C++ -- I would expect Python/C++ to have the same list: https://github.com/google/protobuf/blob/master/conformance/failure_list_cpp.txt |
I didn't get to see this myself because I wasn't able to get it working with Python/C++. Maybe it could be a follow-up PR, but I would really love to get these tests going for Python! |
@haberman Interesting - I basically took the code you provided, applied it to the py3 compatibility branch, and ran it with almost no modifications. I was expecting to hit whatever failure you were seeing when I ran it. Anyway, when I get a chance I'll get what I tried checked in and submit a PR (or maybe just update the one I already opened, depending on where that stands). |
@dano I had run into issues with LD_LIBRARY_PATH/PYTHONPATH, especially since the location of the built .so file was hard to predict (as it varies based on the Python version and such). Also prior to your change we were running 2to3, and I was having trouble getting it the output of 2to3 instead of the original source files. If your PR solves all of these problems then awesome! Maybe let's have the conformance tests be a follow-up PR, to avoid growing the current one too much. |
Hi Guys, Is this a known issue for python 3.4 with protobuf 3(I just simply import module compile via protoc in syntax "proto3")? Traceback (most recent call last): % protoc --version % python -V |
@caxton Yes, there are issues with text handling in Python 3, and they'll still be there, even after my pull request gets merged. It looks like there's a decent amount of work to get the text handling to a place where it does the right thing for all versions of Python. |
Ok, I've now got both python and cpp tests passing on Python 3.3, and the pure python tests passing on 3.4 (with very minimal changes, as it turns out). I have to admit, though, even though all the tests are passing, the way text handling works still feels wrong. The way I got things working is to have Once #722 is merged, I'll open a new PR for these changes so other folks can review. edit: Just opened the PR - #728 |
@haberman I've got the Python 3.4 cpp implementation working now, too. As suggested in http://bugs.python.org/issue22079, I use |
Could anyone update what's the current? :) |
@Kentzo It's been quite a while since I looked, but after that last PR from 8/27 was merged, everything should have been working on from Python 2.6-3.4. |
Cool. Can you think of a tag / raw sha which has stable proto 2.6 and solid python 3? Best Regards
|
Python 3 support should already be available from the last release (3.0.0b2). |
There is a number of open PR regarding adding support for Python 3 (including my own). None of them are merged.
What's the current status? Which of PR's has most chances to be merged anytime soon? I would like to invest some time into this, but really don't want to waste doing work noone will merge.
The text was updated successfully, but these errors were encountered: