electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
142 stars 29 forks source link

dynamic libs #35

Closed electronstudio closed 2 years ago

electronstudio commented 3 years ago

I didn't think anyone was using the dynamic libs, but apparently @adamlwgriffiths is, so I have created a wheel that includes them.

To create the wheel:

 python3 setup_dynamic.py bdist_wheel

This produces dist/raylib_dynamic-3.7.0.post1-py3-none-any.whl which includes only raylib.dynamic but should work on win/mac/linux any version of python with no compilation required.

I have attached the wheel here: raylib_dyamic_wheel.zip

Should we put this on pypi?

adamlwgriffiths commented 3 years ago

I wasn't aware python could utilise static libraries.

Generally libs are built as dynamic for the system, but static for a project. With Nix, each package is isolated into it's own directory. There's some symlink magic, but often libs need patching. The bundled libs don't have access to xlib and others out of the box, hence I use my system installed versions. I don't have a static one built however.

What's the advantage you get with static over dynamic?

electronstudio commented 3 years ago

I don't know if it's inherent to their nature or just a quirk of how CFFI works, but I found:

electronstudio commented 3 years ago

Also I think I recall it was not possible to do the reflection required for the helper functions in https://github.com/electronstudio/raylib-python-cffi/blob/master/raylib/pyray.py with the dynamic version.

adamlwgriffiths commented 3 years ago

I think you're right when you said theres 2 different projects here. Having to do from raylib.dynamic import ... and ditto for static is a bit strange. I'd expect import raylib as rl to 'just work'. Alternatively you could chain import raylib to attempt to import static and failing that import dynamic to avoid the extra layer of imports.

I'm sure the issues of reflection with the dynamic library can probably be solved but it might be a bit more involved. I found Cython worked quite well when I was binding GLFW.

electronstudio commented 3 years ago

Agreed, I probably will make the static import the default one and split the dynamic version out into a separate project.

However I'm not currently using the Raylib binding for any projects of my own, and until you started using it I wasn't aware of anyone else using it either. So improving the dynamic version with reflection or re-writing the whole binding in Cython are probably things I won't get around to doing myself unless I find a reason to use Raylib myself again.

adamlwgriffiths commented 3 years ago

Understood, I don't expect you to go out of your way to make these changes. For the time being I'm able to use raylib-py with some changes I made to it, so I'm not fussed.

electronstudio commented 2 years ago

Dynamic library has been split into a separate module. They have (almost) identical APIs so you can use either with no code changes. https://electronstudio.github.io/raylib-python-cffi/dynamic.html