No description
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.
Find a file
2021-10-08 01:19:28 +01:00
.github/workflows raygui 2021-10-08 01:19:28 +01:00
docs fix docs 2021-10-04 16:04:56 +01:00
docs-src fix docs 2021-10-04 16:04:56 +01:00
dynamic fix dynamic to import exactly the same as static 2021-10-04 16:20:18 +01:00
examples raygui 2021-10-08 01:19:28 +01:00
raygui-c@bad9c8bb58 raygui 2021-10-08 01:19:28 +01:00
raylib raygui 2021-10-08 01:19:28 +01:00
raylib-c@b6c8d343dc oops 2021-06-12 21:54:09 +01:00
.gitignore fix gitignore leaving out windows pyd library! 2019-05-26 00:29:19 +01:00
.gitmodules raygui 2021-10-08 01:19:28 +01:00
build_raygui.sh raygui 2021-10-08 01:19:28 +01:00
BUILDING.rst fix docs 2021-10-04 16:04:56 +01:00
color_test.py update docs 2021-08-27 03:38:11 +01:00
create_stub_pyray.py separate static and dynamic libraries completely 2021-10-03 21:21:59 +01:00
create_stub_static.py separate static and dynamic libraries completely 2021-10-03 21:21:59 +01:00
LICENSE new license 2021-08-30 09:18:29 +01:00
make_docs.sh improve docs, make clear different APIs and static/dynamic 2021-10-03 23:34:09 +01:00
MANIFEST.in separate static and dynamic libraries completely 2021-10-03 21:21:59 +01:00
raylib_api.json update docstrings using raylib_api.json 2021-09-23 09:44:08 +01:00
README.md QOL docs, colors, version number, example imports 2021-10-04 15:56:29 +01:00
setup.py QOL docs, colors, version number, example imports 2021-10-04 15:56:29 +01:00
test_pyray.py QOL docs, colors, version number, example imports 2021-10-04 15:56:29 +01:00
test_static.py type hints for raylib.static 2021-08-28 13:35:55 +01:00
test_static_with_prefix.py improve docs, make clear different APIs and static/dynamic 2021-10-03 23:34:09 +01:00
version.py change build options to include 'all' formats 2021-10-07 23:15:29 +01:00

Python Bindings for Raylib 3.7

New CFFI API static bindings. Automatically generated to be as close as possible to original Raylib. Faster, fewer bugs and easier to maintain than ctypes.

Full documentation

License (updated)

The bindings are now under the Eclipse Public License, so you are free to statically link and use in non-free / proprietary / commercial projects!

Installation

python3 -m pip install raylib

If it doesn't work, first make sure you have latest pip installed:

python3 -m pip install --upgrade pip

On most platforms it should install a binary wheel (Windows 10 x64, MacOS 10.15 x64, Linux Ubuntu1804 x64).

If yours isn't available then pip will attempt to build from source, in which case you will need to have Raylib development libs installed, e.g. using homebrew, apt, etc.

If it doesn't work, you can build manually.

Dynamic binding version

There is now a separate dynamic version of this binding:

python3 -m pip install raylib_dynamic

Read this before using raylib_dynamic

How to use

There are two APIs, you can use either or both:

If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API

Use the C API.

If you prefer a slightly more Pythonistic API and don't mind it might be slightly slower

Use the Python API.

RLZero

Work in progress:

A simplified API for Raylib for use in education and to enable beginners to create 3d games

Help wanted

  • converting more examples from C to python
  • testing and building on more platforms

Performance

For fastest performance use Pypy rather than standard python.

Every call to C is costly, so it's slightly faster if you use Python data structures and functions when calculating in your update loop and then only convert them to C data structures when you have to call the C functions for drawing.

Bunnymark

Library Implementation Bunnies (60 FPS) Percentage
Raylib 3.7 C 168100 100%
Raylib Python CFFI 3.7 Pypy 3.7 33800 20%
Raylib Python CFFI 3.7 Python 3.9 7700 4.5%
Raylib Python CFFI 3.7 Python 3.9 Nuitka 8600 5.1%
Raylib Python CFFI 3.7 Dynamic Python 3.9 6300 3.7%

Packaging your app

You can create a standalone binary using the Nuitka compiler. For example, here is how to package Bunnymark:

pip3 install nuitka
cd examples/textures
python3 -m nuitka --onefile --linux-onefile-icon resources/wabbit_alpha.png textures_bunnymark.py

Advert

RetroWar: 8-bit Party Battle is out now. Defeat up to 15 of your friends in a tournament of 80s-inspired retro mini games.

Coding Games With Pygame Zero & Python is a book for Python beginners.