This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
raylib-python-cffi/dynamic
Cameron Clough 8d5d810925
Switch to logging in __init__.py, set load message to debug (#171)
* Switch to logging in `__init__.py`, set load message to debug

- Replace print statements with logger.error() and logger.warning() calls.
- Follow best practices by using a module-specific logger via
  getLogger(__name__).
- Use parameterized log messages to avoid unnecessary string formatting.
- Change the "RAYLIB STATIC x.x.x LOADED" message from direct stderr
  output to logger warning level.

Motivation:
In [commaai/openpilot#35076][openpilot-issue], we experienced noisy test
outputs because the RAYLIB STATIC message is printed unnecessarily,
cluttering stderr. This change allows library consumers to control the
visibility of this message.

[openpilot-issue]: https://github.com/commaai/openpilot/issues/35076

* use warning rather than debug logging

---------

Co-authored-by: Richard Smith <github@electronstudio.co.uk>
2025-06-04 15:55:41 +01:00
..
raylib Switch to logging in __init__.py, set load message to debug (#171) 2025-06-04 15:55:41 +01:00
examples intellij doesnt want to commit this 2021-10-08 05:07:54 +01:00
MANIFEST.in include py.typed in MANIFEST rather than setup 2024-11-17 01:24:57 +00:00
pyray intellij doesnt want to commit this 2021-10-08 05:07:54 +01:00
README.rst update docs 2022-06-30 09:52:27 +01:00
setup.py refactor pyray into separate module 2021-10-08 04:47:58 +01:00
test_dynamic.py update raylib to 4.5 2023-05-22 17:01:19 +01:00
test_pyray.py Sdl backend (#140) 2024-11-19 12:05:28 +00:00
version.py QOL docs, colors, version number, example imports 2021-10-04 15:56:29 +01:00

Dynamic Bindings
================

CFFI ABI dynamic bindings avoid the need to compile a C extension module.  They now been moved to a separate module::

   python3 -m pip install raylib_dynamic

.. warning::

   There have been some weird failures with dynamic bindings and ctypes bindings before and often the
   failures are silent
   so you don't even know something has gone wrong and you don't get proper stacktraces.  Also the static bindings are faster.
   Therefore I personally recommend the static ones.
   But the dynamic bindings have the advantage that you don't need to compile anything to install.  You just need a Raylib DLL.

The API is exactly the same as the static one documented here.  (Therefore you can't have both modules installed at once.)  The only difference is you can't do::

    from raylib import *

Instead you have to do::

    from raylib import rl

Then you access the functions with ``rl.`` prefix.

See https://github.com/electronstudio/raylib-python-cffi/blob/master/dynamic/test_dynamic.py for an example.

If you use the ``rl.`` prefix then code will work on both static and dynamic bindings.

.. tip::

   If you access functions via ``import pyray`` then there is no difference at all, but be warned this hasn't been tested much.

.. note::

   Standard Raylib DLLs do not include additional libraries like Raygui, Physac, etc.  So these functions won't work.

.. important::

   If your system already has the Raylib library installed, you can set the environment variable ``USE_EXTERNAL_RAYLIB`` and it will
   always be used instead of the bundled DLLs.