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

Fix dynamic raylib loading on Windows #50

Closed pkulev closed 2 years ago

pkulev commented 2 years ago

Library name on Windows is different. I could rename library, but name.dll on windows is more appropriate that libname.dll, I guess, so I've fixed expected library name in init module.

Some fragments of debugging:

➜ tanki git:(main) python
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import raylib
cannot load library 'C:\Users\most\proj\tanki\.venv\lib\site-packages\raylib\libraylib.dll': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\most\\proj\\tanki\\.venv\\lib\\site-packages\\raylib\\libraylib.dll'
>>> exit()

➜ tanki git:(main) mv C:\Users\most\proj\tanki\.venv\lib\site-packages\raylib\raylib.dll C:\Users\most\proj\tanki\.venv\lib\site-packages\raylib\libraylib.dll

➜ tanki git:(main) python
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import raylib
LOADED DYNAMICALLY SHARED LIB 3.7.0.post10 C:\Users\most\proj\tanki\.venv\lib\site-packages\raylib\libraylib.dll
>>>
electronstudio commented 2 years ago

Thanks. I think at one point Raylib used to ship a DLL named 'libraylib.dll', but the current one is indeed 'raylib.dll', so I guess that shows that no-one has attempted to use the dynamic binding on Wndows for years. Any reason you're using it rather than the static binding?

pkulev commented 2 years ago

It's just simpler, no need to compile lib and works well (now) for windows, linux and macos. But there's issue with pyinstaller, it sees all those libs and confuses, thinks it run on windows. I must delete unrelated libraries on CI before building.