Issue: PyPy support
Author: stas
State: closed
Created: 2014-10-29 19:26:08

This is a tentative to make peewee work on PyPy.

So far most of the issues I could find are related to the database packages that are compatible on PyPy/CPython.
This is still a WIP, I didn't make time to look at the MySQL support yet. I will try to have an update on that asap.

Please let me know if there are any questions so far, or there are better ways to handle the compatibility aspects.
Thanks in advance for reviewing this.


Interesting! Fwiw peewee had fallback code in place to use pymysql, the pure python lib.


@coleifer please take a look at the latest changes. Thanks.


Looks good -- can you explain a little bit the changes in c92510a? I see 2 instances of manually closing a cursor and was just wondering about it.


Honestly I can't. It looks like this is an issue only when testing sqlite engine on pypy. My best guess is that this is related to the way gc works on pypy. If you think this is an important aspect, let me have some more time before merging this.


> If you think this is an important aspect, let me have some more time before merging this.

I'm not sure how important it is. Peewee uses cursors quite a bit and I don't believe I've ever added a call to close one, so my concern is just that there may be lurking problems.

I'd definitely like to get to the bottom of it, though. Can you share the errors that occurred when the calls to `close` weren't present?


Sure, here's the travis build without that call:
https://travis-ci.org/coleifer/peewee/jobs/39418500

Ignore the non-pypy failed builds.


Ah, interesting, ok! I wonder if there's a pattern to those errors, or if they just pop up now and then.


Well, its for sure that the failures depend on the test I patched to close the cursor, without that test, the suite passes.


> Well, its for sure that the failures depend on the test I patched to close the cursor, without that test, the suite passes.

And the failures were repeatable and occurred every time the suite ran?


Yep, I was able to reproduce the failures locally and isolate this to that single test. Weird, I know...


Hey @coleifer I'm a bit confused.
Why this was not merged? I don't see how df64a0e covers all the changes I suggested in the PR.
Also it looks like you just hand-picked some of the changes, why?


> I don't see how df64a0e covers all the changes I suggested in the PR.

What's missing?


I'm on master and sqlite tests fail for me, postgres engine migrations tests fail too.
I also suggested to include the pypy builds on travis.

I'm really curious what was wrong with this PR...


Well, I wasn't sure I wanted to include it on travis, and I also wasn't sure about the manual closing of cursors in places. I thought I'd try it out with what I thought were the minimal code changes and not worry about test behavior at first.


I'm sorry if you are upset that I didn't merge your contributions, I will definitely give you a shout-out in the release notes.


Ok, this sounds good, though I would be happier if we had the travis running those builds.
Carry on, this is really great that we can now use peewee on PyPy :tada:  


Thanks for your contribution, I really appreciate it and am glad to have things working on PyPy as well.