[go: nahoru, domu]

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

PyPy3 support #2146

Merged
merged 15 commits into from
Jul 7, 2020
Merged

PyPy3 support #2146

merged 15 commits into from
Jul 7, 2020

Conversation

isuruf
Copy link
Contributor
@isuruf isuruf commented Mar 26, 2020
  1. Enable dynamic attribute support for PyPy >=6 from Enable dynamic attribute support for Pypy >= 6 #1494 and added a test
  2. Disabled eval_file as in [WIP] Test PyPy 3.6 on travis #1720 (comment)
  3. Workaround for __qualname__ on PyPy3
  4. Disabled numpy, scipy testing on PyPy as they fail to install.

TODO:

cc @mattip, @ax3l

@isuruf isuruf force-pushed the pypy3 branch 2 times, most recently from 6e62cc2 to 6ae2c87 Compare March 26, 2020 01:11
@isuruf isuruf force-pushed the pypy3 branch 2 times, most recently from 30c4e6b to ecc2863 Compare March 26, 2020 02:13
@isuruf isuruf force-pushed the pypy3 branch 3 times, most recently from 6d4d308 to 501059a Compare March 26, 2020 03:16
@isuruf
Copy link
Contributor Author
isuruf commented Mar 26, 2020

test_stl_caster_vs_stl_bind issue is because sq_item is not being set even though __getitem__ is set for the type VectorInt.

@isuruf
Copy link
Contributor Author
isuruf commented Mar 26, 2020

Maybe defining __getitem__ doesn't automatically set the value sq_item in PyPy.

@mattip
Copy link
mattip commented Mar 26, 2020

Maybe defining __getitem__ doesn't automatically set the value sq_item in PyPy

It should, as long as __getitem__ is set before calling PyType_Ready

@isuruf
Copy link
Contributor Author
isuruf commented Mar 26, 2020

It should, as long as getitem is set before calling PyType_Ready

Ah, thanks. I think __getitem__ gets defined after PyType_Ready is called.

PyType_Ready is called by make_new_python_type which is called by generic_type::initialize method which is called by class_ constructor and the __getitem__ method is added by class_::def method.

Somebody more familiar with pybind11 internals should confirm though.

@inducer
Copy link
Contributor
inducer commented Mar 28, 2020

Slightly off-topic: @isuruf, could you please keep this branch around for a bit? I'm using it here.

@ax3l
Copy link
Collaborator
ax3l commented Mar 31, 2020

cc @wjakob @jagerman this PR is needs some feedback on its way to add PyPy3.6 support, please.

@isuruf
Copy link
Contributor Author
isuruf commented Apr 9, 2020

ping

@wjakob
Copy link
Member
wjakob commented Apr 9, 2020

Ok, so what kind of feedback do you require? It's been ages since I looked at PyPy internals, so I don't think I could help much with that. The patch looks reasonable to me, but I suppose it does not fully work yet?

@isuruf
Copy link
Contributor Author
isuruf commented Apr 27, 2020

Thanks @mattip. One more issue to fix #2146 (comment). I'm afraid, you might be the best person to fix that as well.

@isuruf
Copy link
Contributor Author
isuruf commented Jun 18, 2020

If I use the suggestion by @mattip in https://bitbucket.org/pypy/pypy/issues/2482/cpyext-tp_basicsize-only-considers-first, I can get the test to pass, but it segfaults other tests.

https://bitbucket.org/pypy/pypy/commits/8175c5e20480 mentions that

but perhaps we should support PyBaseObject_Type too?

@wjakob
Copy link
Member
wjakob commented Jun 30, 2020

I'd like to briefly check in about the status of the PR -- are we stalled on landing improvements to PyPy? There are already some good improvements, so one option would be to merge part of the changes and leave the rest pending.

@isuruf
Copy link
Contributor Author
isuruf commented Jun 30, 2020

Yes. I've marked a couple of tests (related to multiple inheritance) as bug_in_pypy until we can fix it in PyPy. (I'm not entirely sure it's a bug in PyPy, but it looks like it and @mattip can confirm)

CI is passing (with two expected failures), so we can merge right now to avoid any regressions in the future and work on fixing the multiple inheritance issue.

@wjakob
Copy link
Member
wjakob commented Jun 30, 2020

Ok, will do as soon as the PR is merge-able (conflicts).

@isuruf
Copy link
Contributor Author
isuruf commented Jul 4, 2020

This is ready now

@wjakob
Copy link
Member
wjakob commented Jul 7, 2020

Merged, let's track future improvements in a separate PR.

@wjakob wjakob merged commit 0d70f0e into pybind:master Jul 7, 2020
@bstaletic bstaletic mentioned this pull request Jul 7, 2020
@YannickJadoul
Copy link
Collaborator

Tests are failing on master, for some reason.

@bstaletic
Copy link
Collaborator
>       assert msg(exc_info.value) == "m.class_.Pet.__init__() must be called when overriding __init__"
E       assert --- actual / +++ expected
E         - Pet.__init__() must be called when overriding __init__
E         + m.class_.Pet.__init__() must be called when overriding __init__
E         ? +++++++++

So the raised exception looks different than on CPython...

@YannickJadoul
Copy link
Collaborator

Something something __qualname__?

@bstaletic
Copy link
Collaborator

Should we mess with __qualname__ or instead do something like this:

assert msg(exec_info.value) in [ cpython_error_string, pypy_error_string ]

@YannickJadoul
Copy link
Collaborator

Should we mess with __qualname__ or instead do something like this:

assert msg(exec_info.value) in [ cpython_error_string, pypy_error_string ]

Depends a bit on whether this is a PyPy thing, or whether it's a failure of pybind11 to not set tp_name correctly?

@bstaletic
Copy link
Collaborator

If I'm reading this right, pybind11, since python 3.3 doesn't touch __qualname__.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants