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

pypy compatibility #311

Closed
atomizer opened this issue Mar 13, 2019 · 14 comments
Closed

pypy compatibility #311

atomizer opened this issue Mar 13, 2019 · 14 comments

Comments

@atomizer
Copy link

Pypy is an alternative Python implementation with JIT.

Curretnly moderngl doesn't compile due to non-existence of following in pypy C API:

  • 5.5.0:
    • PyException_HEAD macro
    • PyUnicode_Append
  • next:
    • ob_base inside PyObject
@szabolcsdombi
Copy link
Member

Thank you for the issue.
Most of the ob_base are used to access values that can be accessed with macros
I will replace those so next will be compatible with pypy

@szabolcsdombi
Copy link
Member

I don't know a quick solution to get rid of PyException_HEAD for the 5.x compatibility

@szabolcsdombi
Copy link
Member

szabolcsdombi commented Mar 13, 2019

please build moderngl 5.5 from the master
I have removed PyException_HEAD and PyUnicode_Append
I hope it works. I have not tested it yet.

540567f

@szabolcsdombi
Copy link
Member

I am not able to build with pypy:

 error: Microsoft Visual C++ 14.1 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Can you please test:

./pypy3.exe -m pip install https://github.com/moderngl/moderngl/archive/master.zip

@atomizer
Copy link
Author

In GLMethods.cpp there's one mention of PyUnicde_Append left in (now unused) AddToLog. Removing the function makes it compile and work (tests pass).

@szabolcsdombi
Copy link
Member

Super!

@atomizer
Copy link
Author

I'm building it manually with setup.py build_ext --inplace since next still fails.

@szabolcsdombi
Copy link
Member

szabolcsdombi commented Mar 14, 2019

I will fix next too. It will take more time due to a lot of ob_bases I guess

@szabolcsdombi
Copy link
Member

I think it is done. Can you please check if both 5.x and next are building.

@szabolcsdombi
Copy link
Member

@einarf
Copy link
Member

einarf commented Mar 15, 2019

Awesome stuff. This opens up for a lot of interesting experimentation. I wonder myself what kind of performance boost can be gained in some of my projects.

@atomizer
Copy link
Author

Yes, it compiles. Creating a context using next causes instant crash. I'm not an expert on either engine's internals, but I think your direct object memory access/manipulation tricks (memsets, SLOT macro etc.) are CPython-only. It's really difficult (for me at least?) to find concrete info on what those differences are exactly, so I'm not quite sure how to debug this.

@szabolcsdombi
Copy link
Member

I was not able to run pypy locally at all. I cannot get the msvc compiler installed for pypy. Probably the SLOT macro needs to be changes into something that supports PyObject_SetAttrString internally when needed.

@szabolcsdombi
Copy link
Member

I will probably try to run pypy on Ubuntu soon.

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

No branches or pull requests

3 participants