Python CFFI bindings for Raylib
Project description
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.
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
We distribute a statically linked binary Raylib wheel:
python3 -m pip pip3 install raylib
Problems may be caused by out of date pip:
python3 -m pip install --upgrade pip
Some platforms that should be available: 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, build from source
How to use
There are three different ways of using this binding. You only need to pick one method, but you can combine two methods in one program if you want to.
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 raylib.static.
If you prefer a slightly more Pythonistic API and don't mind it might be slightly slower
Use raylib.pyray.
If you insist on dynamic bindings and don't care that they are slower and less safe
Use raylib.dynamic.
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 permformance 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for raylib-3.7.0.post6-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76377ae06a101281a1481ba9835b297012d0ea72de4ab901d95a44f41e812bd3 |
|
MD5 | b9a729be0113d9a38096d5c52487b2c6 |
|
BLAKE2b-256 | 395fd07697106e863df29e3d66694159c62d84a4452a3a4ac6eaefe9a48cf56e |
Hashes for raylib-3.7.0.post6-pp36-pypy36_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c2be8eb75f7499373cd79bf1f8f3f9470930c5e127a798eca5a4ce26076a149 |
|
MD5 | 7ed5183e798305a5236626d8779c5907 |
|
BLAKE2b-256 | d9482cbed621bfcf2933ed8d88a0d3279c34cf9bfc9e809ccbeb40d4b9ab5e2c |
Hashes for raylib-3.7.0.post6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e070af39991686cd52e418e73f81a8cc923b9665ecc8f090d5f789357db455 |
|
MD5 | 86ffaa5c028f7a2b7c3a5484b7d9075c |
|
BLAKE2b-256 | 7ee3254ac47be1d9ad914bb3e9bd4472d445be2da3b4075b8b44f245d5b28835 |
Hashes for raylib-3.7.0.post6-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5398350fe0b178c52e24ed7c57a6ff68c724be16728e9fd712a5621b12f48211 |
|
MD5 | 4d772f76e2854d324f8686e98bbf409a |
|
BLAKE2b-256 | adf03a490992eda4520240447af0e825bb7a513942c52412aabdfcc90ed57389 |
Hashes for raylib-3.7.0.post6-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350f75d636f5a897b397b274711b6adc0c3a6fdfe2a9a93690b738dd9e639915 |
|
MD5 | 02bbdb4be28172c1139e43ffca1ed31f |
|
BLAKE2b-256 | bdde181bde85283a30d9acd2cbb4d7df82d8452d8474fece8f181d1b29176266 |
Hashes for raylib-3.7.0.post6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b14032a24f7abe9cd97e84a8bf69b2069e927be0f350bc7cee55722e1e6a3887 |
|
MD5 | 566d760fa4e70030c4305d498201f0ac |
|
BLAKE2b-256 | dd3c93640784310733f5077b45481a3f3b657369c27422ab24a4d497b2bb7f06 |
Hashes for raylib-3.7.0.post6-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bff27987ea350475023be0fa327e803a52e2706d9ff3882c14cb6b0c7923c5bf |
|
MD5 | 4cac639aa1d110ba5bcdc6e64f29d909 |
|
BLAKE2b-256 | 4b67530b2f47b019ed05874d13c2e294c27762d245814098b578eb9d5d4e37d9 |
Hashes for raylib-3.7.0.post6-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 946d03c7453852d1467c197a37ecfc78f34696f3ec944518a9d207c1663b0219 |
|
MD5 | 083b5bd5dd482700bfd458affed28cb4 |
|
BLAKE2b-256 | dd773ec6a4cd88815c0e5f2b1f881bba9d8a2b63d0bdd04b9e278f58c1492deb |
Hashes for raylib-3.7.0.post6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 009326d1c174c2b97eabc287557791e4c20d96d3c7cda12b7704194af8b0dd8a |
|
MD5 | 3dadd996bd130ce4ea95efb8e21d9273 |
|
BLAKE2b-256 | d69c4dc9e86cdb18f9293591d5ddbd4e72bd48f364b54d8a62c834f3480e45f0 |
Hashes for raylib-3.7.0.post6-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ba6b42ca51a2ca44bf237e665b00371a7cbd1d81116cf8e2135588c997f802 |
|
MD5 | b8c44d1868c9affa32d9b6dececf6f3c |
|
BLAKE2b-256 | 7658d95baebfcb87a98c5f9f0cd910325e93a321d2d176070352a0117eae5b58 |
Hashes for raylib-3.7.0.post6-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 045363ef145b451bf3f8a68f1462cd94b5458750ad66297ed16be810636c40d2 |
|
MD5 | 4958f57c3315ba5a4cd7e6e20b4ab17b |
|
BLAKE2b-256 | 790652d451be77396577f685ea2c6e50b7b7a44d826fa7b709a7e150dd6b8f35 |
Hashes for raylib-3.7.0.post6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0df2c66bef0d2b95b11d474dde2518305cc071fc5811ecdffa442430f3251b80 |
|
MD5 | dde6e30f53bb814bfea62838f4877114 |
|
BLAKE2b-256 | b425bd724f18b63727e27a3bbdaf4a1b0c61e1a97afad2203baa69601b7398e2 |
Hashes for raylib-3.7.0.post6-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20dc2f2dcb1905a24c3b22a66b143a43ec0c65d58fda6eac6cec620871c8dcd7 |
|
MD5 | da68db1dc0619419fb981cae76b55448 |
|
BLAKE2b-256 | 4d311758d0867b40903d530f7d14b2bddf354d8ee09d712f8bef61ad6f944cbd |
Hashes for raylib-3.7.0.post6-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e2b96bd9e9df8d1c864c94b6137df5ca14f734b05c01f89028bf734b3955d2e |
|
MD5 | e5c3c8b8f85e2bab18c93152ec751984 |
|
BLAKE2b-256 | f4d3e99f4e26734ff840dddff73525de74dd5258ac2fb92c039b1e76e6687e2d |
Hashes for raylib-3.7.0.post6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33133bf1841839f0f882832e00bc68c5045f1da3e9868c9b0dc6e0cf89771115 |
|
MD5 | f9c46594c2210215f74e40ea57f338ac |
|
BLAKE2b-256 | dbfea6d5b347e8eb621b9279554712c37e0e277c839f56d72641b8e4a14a7cfe |
Hashes for raylib-3.7.0.post6-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e9f73090d292060461bccf1211ad6b8212e0faa867bc69e71bb52c38a4150e |
|
MD5 | ebe0fed67a6fd8b36daaea6b2bcaa7fd |
|
BLAKE2b-256 | 15f25e553cb823d3f54b050156c864e3eaf4aabab8b300fa28436b788bfba804 |
Hashes for raylib-3.7.0.post6-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5137287ead986b261282490149559748b44ec9cdc7ba7695a0f103671f26840b |
|
MD5 | 8657f6b67291b0834eb06d3ab69d08e5 |
|
BLAKE2b-256 | 54384a02d525d08295cd168d712c78e92214544f00b6ee0ef853e83b6c251d39 |