Export to GitHub

couchdb-python - issue #231

python 3 support


Posted on Nov 12, 2013 by Swift Rabbit

What steps will reproduce the problem? Python3 setup.py install

What is the expected output? What do you see instead? Install fails because of Python2 syntax.

What version of the product are you using? On what operating system? CouchDB-0.9

Please provide any additional information below. Just wondering if a version that supports Python 3 can be expected.

Comment #1

Posted on Nov 12, 2013 by Quick Rhino

I have an MQ where this is mostly working. If someone is serious about helping drive it forward, I can probably publish it somewhere.

Comment #2

Posted on Nov 12, 2013 by Swift Rabbit

I would be happy to lend a hand.

Comment #3

Posted on Nov 26, 2013 by Swift Bird

I'd like this to work as well. I had started doing something with six so it works on both Python 2 and Python 3, but in the end I had no time and ended using microfiber.

I'd be happy to help as well to get this package to work on Python 3.

Comment #4

Posted on Nov 26, 2013 by Quick Rhino

I've pushed my MQ state to a Bitbucket repository:

https://bitbucket.org/djc/couchdb-python-py3-mq

You can apply this by enabling the MQ extension for hg and then cloning that repo to .hg/patches in your couchdb-python repository. Then, you can use hg qpush -a to apply all the patch and see the current state of the test suite. I hope someone can step up to help push this forward!

Comment #5

Posted on Nov 26, 2013 by Happy Dog

I'd like to help but I'm not familiar with bitbucket. Can I use git to fork your repo?

Comment #6

Posted on Nov 27, 2013 by Quick Rhino

That probably doesn't really help you. Maybe this is a good chance to give Mercurial a chance?

Comment #7

Posted on Nov 30, 2013 by Swift Rabbit

I installed Mercurial and enabled MQ. I'm not sure what it means to clone your repo to ".hg/patches in your couchdb-python repository." Can you explain?

I tried this: hg clone https://bitbucket.org/djc/couchdb-python-py3-mq but I don't see any python files.

Comment #8

Posted on Jan 5, 2014 by Grumpy Camel

This is a duplicate of #150.

Comment #9

Posted on Jan 5, 2014 by Quick Rhino

Issue 150 has been merged into this issue.

Comment #10

Posted on Jan 17, 2014 by Swift Bird

Here's a patch that add Python3 compatibility while preserving Python2 compatibility, using six and the awesome series of patches by Dirkjan Ochtman (djc).

All the test pass except for the doctests (because Unicode strings are u"abc" in py2 and "abc" in py3). However I haven't tested that in a real-world app yet :)

There are lots of changes wrt strings and unicode strings, so I'm not sure it won't break compatibility with other versions of the library.

Tested with Python 2.7.6 and 3.3.3. Should work with 2.6 as well, but not tested. Won't work with <2.5 and <3.3.

Attachments

Comment #11

Posted on Jan 17, 2014 by Quick Rhino

Thomas: awesome work, man!

Would it be possible to keep this split into smaller patches? The larger patch is pretty hard to review... It would be great if you could give me patches that would apply on top of what I already had, that way we could land it quickly.

Comment #12

Posted on Jan 27, 2014 by Swift Rabbit

I applied the py3.patch on a github mirror of Revision 961ac99baa29, in case someone without mercurial installed needs the python 3 version urgently: https://github.com/miebach/couchdb-python/tree/python3 (download zip button on the right side)

Comment #13

Posted on Mar 13, 2014 by Happy Dog

We're starting a new python based project and we intend to use Python3 for that. Most of our dependencies are already available (numpy, pandas, cherrypy, and so on), but couchdb-python wasn't, so I was happy to find this issue and the patch. Thanks a lot.

I hope it can be integrated by the time we would want to deploy. Does anyone have any information on the intent? This ticket has been dormant for almost 2 months now.

I've used the github version as I'm more familiar with git, is that the latest? is there an updated version somewhere else?

Thanks in advance.

Comment #14

Posted on Mar 13, 2014 by Swift Rabbit

I've used the github version as I'm more familiar with git, is that the latest? is there an updated version somewhere else?

The github version is based on

Rev 961ac99baa29 Allow overriding wrapper in ViewDefinition.call(). Aug 18, 2013 Ryan Olson

You can verify this in the network view:

https://github.com/miebach/couchdb-python/network

And 961ac99baa29 is still the latest here on googlecode, so it seems the gothub code is recent:

https://code.google.com/p/couchdb-python/source/list

Comment #15

Posted on Mar 13, 2014 by Quick Rhino

The big patch, while great, should IMO be split up before landing into our repository. The separate patches from my MQ should be a good guideline for how to do that. If someone wants to do some work to make a patch separating the stuff in the big patch that's not in my queue out, that would probably help me move faster on this.

The big patch also seems to introduce a six dependency relative to my MQ; we should check if that really makes sense for this case.

Sorry, my round tuits have been a little scarce lately, but I do still want to take care of this issue.

Comment #16

Posted on Mar 30, 2014 by Quick Rhino

I've just pushed my changes to the repository (rdb566517e8af and ancestors). With my approach, the current tip passes all tests on 2.7 and almost all tests on 3.3 (except a few doctests), so it should be fairly usable in Python 3-ready codebases.

I'd very much like for someone to take a look at the remaining doctests failures and see if there's a strategy to fix them (or rewrite them so the problems go away, without loss of useful documentation).

Python 3 also has new ResourceWarnings that are triggered by some of the tests, these should probably be investigated as well.

This is a fairly bottom-up port, so I'm not sure the unicode/bytes design makes sense. Review/criticism is most welcome.

Comment #17

Posted on May 26, 2014 by Helpful Wombat

It seams to work well here with current master. Could you please make a release of CouchDB 0.10 so that we can integrate it and raise bugs if there are?

Comment #18

Posted on May 26, 2014 by Quick Rhino

I'd really prefer to get the doctests fixed somehow, but I haven't come up with a strategy for doing so. I guess getting the doctests to skip under Python 3 only would be acceptable.

Comment #19

Posted on Jul 6, 2014 by Quick Rhino

With r402aac0b09ad, I consider this to be complete. Please test, and report new issues for anything you might run into. I'd like to release this soon.

Comment #20

Posted on Jul 6, 2014 by Happy Dog

My tests of r402aac0b09ad all passed. I look forward to the release. Thanks!

Comment #21

Posted on Jul 6, 2014 by Quick Rhino

Thanks for testing!

Status: Fixed

Labels:
Type-Defect Priority-Medium