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

Raylib example isn't working on RPi4B+ #24

Closed akamensky closed 3 years ago

akamensky commented 3 years ago

Env:

Setup:

root@raspberrypi:~# pip3 install raylib
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting raylib
  Downloading https://files.pythonhosted.org/packages/a5/c4/42b76b21a7e54f206bd0d3ec505fd63fff8338beb9847f88c97aca26d2fd/raylib-2.6.0-py3-none-any.whl (13.2MB)
    100% |████████████████████████████████| 13.2MB 34kB/s
Collecting cffi>=1.14.0 (from raylib)
  Downloading https://www.piwheels.org/simple/cffi/cffi-1.14.4-cp37-cp37m-linux_armv7l.whl (346kB)
    100% |████████████████████████████████| 348kB 670kB/s
Collecting inflection (from raylib)
  Downloading https://files.pythonhosted.org/packages/59/91/aa6bde563e0085a02a435aa99b49ef75b0a4b062635e606dab23ce18d720/inflection-0.5.1-py2.py3-none-any.whl
Collecting pycparser (from cffi>=1.14.0->raylib)
  Downloading https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl (112kB)
    100% |████████████████████████████████| 112kB 1.9MB/s
Installing collected packages: pycparser, cffi, inflection, raylib
Successfully installed cffi-1.14.4 inflection-0.5.1 pycparser-2.20 raylib-2.6.0

test.py is contents from README in this repo for raylib.static:

root@raspberrypi:~# python3 test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from raylib.static import *
  File "/usr/local/lib/python3.7/dist-packages/raylib/static/__init__.py", line 1, in <module>
    from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named 'raylib.static._raylib_cffi'
electronstudio commented 3 years ago

I have only compiled binaries for x86-64 (windows, mac and linux). If you want to run on ARM Linux you will need to compile yourself.

akamensky commented 3 years ago

@electronstudio then please do put appropriate arch tag on your builds. Otherwise it assumes it is "noarch" and allows me to install those on arm64, which it should not allow in that case.

Still a bug.

electronstudio commented 3 years ago

Feel free to submit a PR to fix it.

akamensky commented 3 years ago

I don't see anything relating to automatic builds/pypi uploads in this repo, I presume this is done elsewhere or manually.

In short -- these arch tags are defined in wheel file that is uploaded to pypi repos.

Compare yours: https://pypi.org/project/raylib/#files (filename: raylib-2.6.0-py3-none-any.whl) note any suffix which tells that this package contains NO binary deps that are platform/arch dependent. With for example CFFI: https://pypi.org/project/cffi/#files (filename: cffi-1.14.4-cp35-cp35m-manylinux1_x86_64.whl) note manylinux1_x86_64 suffix which tells that package contains files that are binary compatible with only Linux/x86_64.

electronstudio commented 3 years ago

It's been a year since I looked at this so I can't remember how it's done! Guess we should add a script to do releases, and make a release for 3.5.

electronstudio commented 3 years ago

ideally we would get pip to automatically compile a binary if one is not present but i couldnt figure out how to do that.

electronstudio commented 3 years ago

OK I can't actually do a release for Raylib 3.5 because 3.5 doesn't compile. Oh Raylib.... Guess will have to do a release from git master.

electronstudio commented 3 years ago

Updated to build with Raylib 3.5 and wrote instructions: https://github.com/electronstudio/raylib-python-cffi#build-from-source

electronstudio commented 3 years ago

In fact there is is a script included to build the wheel, invoke like this:

python3 setup.py bdist_wheel

So that's the script to edit to get the wheel to be architecture specific. I think I managed to get it to produce platform specific wheels before but the problem is we support about 20 different platforms so I just went with 'any' to get a single wheel that worked on (almost) all systems.

akamensky commented 3 years ago

I am not saying it has to provide support for all different architectures (though would be nice of course). But it should not successfully install if it is not going to work due to arch not being supported.

electronstudio commented 3 years ago

Well, I don't manually enter the file names, they are generated by setup.py so that's the file you need to fix if you want to fix this bug.

I will close this issue split it into sub tasks so it's clearer what is required if anyone wants to take it on.

https://github.com/electronstudio/raylib-python-cffi/issues/25 https://github.com/electronstudio/raylib-python-cffi/issues/26