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

upgrade to raylib 4.5 #102

Closed
ogoudron opened this issue May 22, 2023 · 27 comments
Closed

upgrade to raylib 4.5 #102

ogoudron opened this issue May 22, 2023 · 27 comments

Comments

@ogoudron
Copy link

Hello,
Do you plan to upgrade to raylib 4.5 ?

Thanks, Olivier.

@electronstudio
Copy link
Owner

Yes, but I don't know when. Why don't you try it with Raylib 4.5 now? It might work already.

@electronstudio
Copy link
Owner

seems to work but as usual raylib has made braindead API changes so examples and stuff wont work.

@electronstudio
Copy link
Owner

I've updated the code and some of the examples. Seems to work. Can't do a release to pypi because Github Actions isn't working.

@electronstudio
Copy link
Owner

OK done.

@ogoudron
Copy link
Author

Thanks,
Tested the quickstart example on macOS 11.7.6 X86_64, Python 3.11.3 and it works.
Will test on Debian 11 X86_64 and ARM64 (RPI400) later today.
Tested on macOS 13.3.1(a) mac mini M1, Python 3.11.3 and installation work but test program (the quickstart example) fail. The quickstart example failed yesterday with 4.2 too. Is it because of M1 cpu ?

ogoudron@Mac-M1 ~ % pip3 install raylib
Collecting raylib
Downloading raylib-4.5.0.0.tar.gz (69 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.8/69.8 kB 1.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.14.6 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from raylib) (1.15.1)
Requirement already satisfied: inflection in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from raylib) (0.5.1)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from cffi>=1.14.6->raylib) (2.21)
Building wheels for collected packages: raylib
Building wheel for raylib (pyproject.toml) ... done
Created wheel for raylib: filename=raylib-4.5.0.0-cp311-cp311-macosx_10_9_universal2.whl size=70243 sha256=ddd1459efd8ee32a0e90aed7b6f24f767f0b641edf014c7daeaa27d7f8d3577e
Stored in directory: /Users/ogoudron/Library/Caches/pip/wheels/aa/d5/ca/da18b3f0c355a34c4e7d003d709f748fa47b74f7e3de05b9db
Successfully built raylib
Installing collected packages: raylib
Successfully installed raylib-4.5.0.0

ogoudron@Mac-M1 dev % python3 test.py
Traceback (most recent call last):
File "/Users/ogoudron/dev/test.py", line 1, in
from pyray import *
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyray/init.py", line 15, in
from raylib import rl, ffi
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/raylib/init.py", line 15, in
from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named 'raylib._raylib_cffi'

@electronstudio
Copy link
Owner

Sort of. GitHub Actions don't have Arm64 runners so I can't build binary packages for M1 Mac. (In the past I got it working by cross compiling on the x64 runner but that suddenly stopped working). So there's no binary wheels.

However it should still work by compiling from source and it should do that automatically when you try to install on M1 Mac. Do you have Raylib itself installed and working?

@ogoudron
Copy link
Author

I have tested on Debian 11 X86_64 and Windows 10 X86_64 and it works.
On Debian 11 ARM64 (RPI400) i have the exact same problem and error message than macOS M1.
I am new to Python and i am not sure that i am right but when i read the command output from pip3 it seems that it has built raylib from source and installed it.
I will be happy to do some tests on macOS M1 and RPI400 if you tell me what to do.

@ogoudron
Copy link
Author

I have understood my mistake (confusing raylib-4.5.0.0 with the raylib library).
I have followed "Have Pip build from source" on RPI400 and it's better. The quickstart sample start but fail with a GLFW error. I will recheck the way i install Raylib on RPI400 and tell you later. For now i will do the same test on my mac M1.

@electronstudio
Copy link
Owner

Yeah it's probably failing to build because you didn't have raylib installed. But it should show an error in that case during the build step, I don't know why it didn't.

@electronstudio
Copy link
Owner

It seems that if you do pip install setuptools before pip install raylib then it will print any errors in the build step. Not sure how to enforce this other than mention it in the docs. Adding it as a dependency doesn't work.

@ogoudron
Copy link
Author

ogoudron commented May 23, 2023

On macOS M1 i have the same error than before.

I have compiled and installed Raylib following your instructions in "Have Pip build from source".
This is the end of the installation log (sudo make install) and it seems to be OK :

Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libraylib.a
-- Up-to-date: /usr/local/include/raylib.h
-- Up-to-date: /usr/local/include/rlgl.h
-- Up-to-date: /usr/local/include/raymath.h
-- Installing: /usr/local/lib/pkgconfig/raylib.pc
-- Installing: /usr/local/lib/cmake/raylib/raylib-config-version.cmake
-- Up-to-date: /usr/local/lib/cmake/raylib/raylib-config.cmake

Then the pip install part (following our instruction in "Have Pip build from source") :

ogoudron@Mac-M1 build % pip3 install --no-binary raylib --upgrade --force-reinstall raylib
Collecting raylib
Using cached raylib-4.5.0.0-cp311-cp311-macosx_10_9_universal2.whl
Collecting cffi>=1.14.6 (from raylib)
Using cached cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl (174 kB)
Collecting inflection (from raylib)
Using cached inflection-0.5.1-py2.py3-none-any.whl (9.5 kB)
Collecting pycparser (from cffi>=1.14.6->raylib)
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: pycparser, inflection, cffi, raylib
Attempting uninstall: pycparser
Found existing installation: pycparser 2.21
Uninstalling pycparser-2.21:
Successfully uninstalled pycparser-2.21
Attempting uninstall: inflection
Found existing installation: inflection 0.5.1
Uninstalling inflection-0.5.1:
Successfully uninstalled inflection-0.5.1
Attempting uninstall: cffi
Found existing installation: cffi 1.15.1
Uninstalling cffi-1.15.1:
Successfully uninstalled cffi-1.15.1
Attempting uninstall: raylib
Found existing installation: raylib 4.5.0.0
Uninstalling raylib-4.5.0.0:
Successfully uninstalled raylib-4.5.0.0
Successfully installed cffi-1.15.1 inflection-0.5.1 pycparser-2.21 raylib-4.5.0.0)

And finally the error when running the QuickStart example :

ogoudron@Mac-M1 dev % python3 test.py
Traceback (most recent call last):
File "/Users/ogoudron/dev/test.py", line 1, in
from pyray import *
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyray/init.py", line 15, in
from raylib import rl, ffi
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/raylib/init.py", line 15, in
from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named 'raylib._raylib_cffi'

I have no idea what is happening.
I have tested that the Raylib is working compiling a test C program and it worked :
I have copied "/usr/local/lib/libraylib.a" in a working folder and compiled a test program in C with this command "clang -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL libraylib.a test.c -o test" and the resulting program is compiling well and working.

@electronstudio
Copy link
Owner

I have compiled binary wheels for M1 macs using cirrus ci. They are attached in this zip file. Please install the appropriate one and let me know if it works. I'll put them on pypi if it does.
dist.zip

@ogoudron
Copy link
Author

ogoudron commented May 23, 2023

Can you tell me where ?

@electronstudio
Copy link
Owner

Download the file I posted above. Assuming you are on Macos 13 the the file you want is raylib-4.5.0.0-cp311-cp311-macosx_13_0_arm64.whl. So unzip that file, and then:
python3.11 -m pip install raylib-4.5.0.0-cp311-cp311-macosx_13_0_arm64.whl

@ogoudron
Copy link
Author

It works :-)
Thanks for all.

@ogoudron
Copy link
Author

Tell me when it will be done because i will test it on a fresh new Mac mini M2.

@electronstudio
Copy link
Owner

I have put them on pypi now.

@ogoudron
Copy link
Author

It works on the first try on a fresh macOS M2.
I will test on RPI400 later this week.

Thanks for your help again.

@ogoudron
Copy link
Author

ogoudron commented May 26, 2023

I have done some tests on RPI400 and theses are what i suppose to have understood :

  1. Compiling Raylib with MAKE following Raylib documentation (make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_21) work with a C test program but fail when installing Python binding with pip command. It fail without error message when issuing pip command as a simple user and fail with asking to install Raylib with CMAKE when running the same command with sudo.

  2. Compiling Raylib with CMAKE following your documentation (cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release ..) seemed to work but i have an error message with GLFW initialization when trying a C test program. The pip command fail too but i suppose that's because the Raylib installation is not working.

  3. i tried to compile Raylib with mixing our CMAKE example and Raylib documented flags for RPI and it doesn't work. Maybe i am wrong with the way to pass flags to CMAKE. This is what i tried : "cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_21 .."
    The resulting Raylib is unable to work with my C test program.

So, i suppose i am wrong with the way to force CMAKE to use "GRAPHICS_API_OPENGL_21".
Or i am totally wrong :-)

@electronstudio
Copy link
Owner

raylib's cmake build is buggy and they've never cared about fixing it. i did fix it couple of times for them in the past but then they would break it again so i gave up. so it might be you're requesting the right thing and it's just not doing it.

@electronstudio
Copy link
Owner

try
cmake -DPLATFORM="Desktop" -DOPENGL_VERSION="2.1" -DGRAPHICS="GRAPHICS_API_OPENGL_21" -DINCLUDE_EVERYTHING=on -DSUPPORT_FILEFORMAT_JPG=on -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release ..

@electronstudio
Copy link
Owner

could also try
cmake -DPLATFORM="Desktop" -DOPENGL_VERSION="ES 2.0" -DGRAPHICS="GRAPHICS_API_OPENGL_ES2" -DINCLUDE_EVERYTHING=on -DSUPPORT_FILEFORMAT_JPG=on -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release ..

@ogoudron
Copy link
Author

Following your advise, i was able to successfully compile Raylib with CMAKE and my test C program works now.

When i try to install the Python binding following your instructions in "Have Pip build from source" i have the same error than before (with macOS and RPI400).

pi@raspberrypi:~ $ pip3 install --no-binary raylib --upgrade --force-reinstall raylib
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting raylib
Using cached raylib-4.5.0.0-cp39-cp39-linux_aarch64.whl
Collecting cffi>=1.14.6 (from raylib)
Using cached cffi-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (448 kB)
Collecting inflection (from raylib)
Using cached https://www.piwheels.org/simple/inflection/inflection-0.5.1-py2.py3-none-any.whl (9.5 kB)
Collecting pycparser (from cffi>=1.14.6->raylib)
Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.21-py2.py3-none-any.whl (119 kB)
Installing collected packages: pycparser, inflection, cffi, raylib
Attempting uninstall: pycparser
Found existing installation: pycparser 2.21
Uninstalling pycparser-2.21:
Successfully uninstalled pycparser-2.21
Attempting uninstall: inflection
Found existing installation: inflection 0.5.1
Uninstalling inflection-0.5.1:
Successfully uninstalled inflection-0.5.1
Attempting uninstall: cffi
Found existing installation: cffi 1.15.1
Uninstalling cffi-1.15.1:
Successfully uninstalled cffi-1.15.1
Attempting uninstall: raylib
Found existing installation: raylib 4.5.0.0
Uninstalling raylib-4.5.0.0:
Successfully uninstalled raylib-4.5.0.0
Successfully installed cffi-1.15.1 inflection-0.5.1 pycparser-2.21 raylib-4.5.0.0
pi@raspberrypi:~ $ python3 test.py
Traceback (most recent call last):
File "/home/pi/test.py", line 1, in
from pyray import *
File "/home/pi/.local/lib/python3.9/site-packages/pyray/init.py", line 15, in
from raylib import rl, ffi
File "/home/pi/.local/lib/python3.9/site-packages/raylib/init.py", line 15, in
from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named 'raylib._raylib_cffi'

Trying the same command with sudo take more time (seems to do more things) but fail with the same error when trying to run the Python test program.

@electronstudio
Copy link
Owner

It's using a cached version of the wheel rather than creating a new one, try:

pip3 install setuptools
pip3 install --no-cache-dir --no-binary raylib --upgrade --force-reinstall raylib==4.5.0.0

That should either work, or give you an error saying why it doesn't work. If it doesn't work and doesn't say why then we'll have to do a manual build.

@ogoudron
Copy link
Author

ogoudron commented May 30, 2023

Thanks, it works.
Maybe you could update this in your documentation (https://electronstudio.github.io/raylib-python-cffi/BUILDING.html)

@electronstudio
Copy link
Owner

will do. would be nice if we could build Pi wheels and put them on pypi.

@ogoudron
Copy link
Author

ogoudron commented May 30, 2023

I am just starting learning Python and i don't know how theses things works.
Just tell how to build "wheels" and/or where to find the resulting files and i will send them to you.

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

2 participants