Skip to main content

Python CFFI bindings for Raylib

Project description

Python Bindings for Raylib 4.2

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.
  • Commercial-friendly license.
  • Docstrings and auto-completion.
  • Now includes extra libraries: raymath, raygui, rlgl and physac

Full documentation

Quickstart

pip3 install raylib

from pyray import *
init_window(800, 450, "Hello")
while not window_should_close():
    begin_drawing()
    clear_background(WHITE)
    draw_text("Hello world", 190, 200, 20, VIOLET)
    end_drawing()
close_window()

Installation

First make sure you have the latest pip installed:

python3 -m pip install --upgrade pip

Then install

python3 -m pip install raylib

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

Beta testing

You can install an alpha or beta version by specifying the exact version number like this:

python3 -m pip install raylib==4.0a6

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.

App showcase

Tanki

Alloy Bloxel Editor

Add your app here!

RLZero

A related library (that is a 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 on more platforms

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!

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.

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

raylib-4.2.0.0.dev1.tar.gz (68.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

raylib-4.2.0.0.dev1-pp39-pypy39_pp73-win_amd64.whl (735.1 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (918.5 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

raylib-4.2.0.0.dev1-pp38-pypy38_pp73-win_amd64.whl (735.1 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (918.5 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

raylib-4.2.0.0.dev1-pp37-pypy37_pp73-win_amd64.whl (735.1 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (918.4 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

raylib-4.2.0.0.dev1-cp311-cp311-win_amd64.whl (837.8 kB view details)

Uploaded CPython 3.11Windows x86-64

raylib-4.2.0.0.dev1-cp311-cp311-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11

raylib-4.2.0.0.dev1-cp311-cp311-macosx_10_15_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

raylib-4.2.0.0.dev1-cp310-cp310-win_amd64.whl (837.8 kB view details)

Uploaded CPython 3.10Windows x86-64

raylib-4.2.0.0.dev1-cp310-cp310-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10

raylib-4.2.0.0.dev1-cp310-cp310-macosx_10_15_universal2.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 10.15+ universal2 (ARM64, x86-64)

raylib-4.2.0.0.dev1-cp39-cp39-win_amd64.whl (837.8 kB view details)

Uploaded CPython 3.9Windows x86-64

raylib-4.2.0.0.dev1-cp39-cp39-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9

raylib-4.2.0.0.dev1-cp39-cp39-macosx_10_15_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

raylib-4.2.0.0.dev1-cp39-cp39-linux_armv7l.whl (2.6 MB view details)

Uploaded CPython 3.9

raylib-4.2.0.0.dev1-cp38-cp38-win_amd64.whl (837.8 kB view details)

Uploaded CPython 3.8Windows x86-64

raylib-4.2.0.0.dev1-cp38-cp38-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8

raylib-4.2.0.0.dev1-cp38-cp38-macosx_10_15_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

raylib-4.2.0.0.dev1-cp37-cp37m-win_amd64.whl (837.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

raylib-4.2.0.0.dev1-cp37-cp37m-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7m

raylib-4.2.0.0.dev1-cp37-cp37m-macosx_10_15_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

File details

Details for the file raylib-4.2.0.0.dev1.tar.gz.

File metadata

  • Download URL: raylib-4.2.0.0.dev1.tar.gz
  • Upload date:
  • Size: 68.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.5

File hashes

Hashes for raylib-4.2.0.0.dev1.tar.gz
Algorithm Hash digest
SHA256 a0247c00dc4ad3866d87e0d70d5eeeb99ccf045bb4c7957a559d6a5777c06978
MD5 e9b0742a9520eef86a29a45d5c51839b
BLAKE2b-256 72d92791eeb0cc671d1bced9c24a0279d256d9543664f2fd0973db1c1ff5934b

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 1ec37646b918e14c69766f6d328ed1f206da7f29114afbdb27871677ad7c343b
MD5 828bb53061475014679d58b3a00dc2f4
BLAKE2b-256 6b29bdbd827a0ad8b98e4584069d6cdae34fca85b873dc6e0ac766e58a063d80

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp39-pypy39_pp73-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13d66446a0dd34af1d83aeb1c9daa67a085f00ac892158eafc931f679477b694
MD5 ddda21972bb39c3bbb10787f90d59979
BLAKE2b-256 41a489c9f3eacd9f914f412810d6a10ef0528a74250367b7cac0de56be9ab742

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 60f7ff855fa77d2a82583c56b38fba634e5d05f89c365f32d41a43c96a4bf3a4
MD5 ddafcf5a81195bf2429fdddc773c987d
BLAKE2b-256 a2b1720e3fd774b46e961f508f7e6caf4796d8fad2227b9466cb76f4a1fafeb3

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp38-pypy38_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 1e1c14b42a80aebaf9efe1847caf413029c0e50cd52f3af3e97f0e74e3ac0279
MD5 1063141921fd95ca110dc2c1e91aa26c
BLAKE2b-256 fca7ae580d96ccf024a183140da0876a11c5ffe528e87bcadcb8d7e225cd12fa

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp38-pypy38_pp73-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01bddd0a1c9f5bc3f6e57ff340844e3701465d82261b98edda8f77d875d08337
MD5 e65b737bf266d1ba038bd071615eb702
BLAKE2b-256 7b098fc8a2a762043d711945b33d031d585b51328e938279968b3c44464c4a8a

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0322660345bd130cf32b56651a087fc218a7b3217bde2861a3ac8a8092e4aac2
MD5 ddf16ab99ec568d81e4f812c3b236aba
BLAKE2b-256 1039654f13732f31f1e0c17ef558c080e885044ecd11282331d60c0ac9d38084

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp37-pypy37_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp37-pypy37_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d360570b649f6772603ee0da362995ea0b158b1569684fed1a15c4ee1bf369b7
MD5 7b58295cc8c58d975bf2777d03a1f5fe
BLAKE2b-256 0b6a07a87b32471b352ac3afb2bf3cf45cfba71a13895ff2de3e190beb9fda35

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp37-pypy37_pp73-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 521f47a59af76440266b680693889902a47d0b085983eaa072bcf8ff3520e36e
MD5 3e04ac272a98bfaf4bef9ae34dddd5a4
BLAKE2b-256 ffcb5d7ca09c98de9487d37801ae736f07fed507715bbf2a65e29757252af3ca

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5688a1a72859594aa046de3153fdfe4314b2678f1b8ecd65b598c05a050efedd
MD5 e833335c62c747954a472ef1e582fab5
BLAKE2b-256 c6478e7134b5c08569a03ff4f9e2f20ede48b5ad6437b9a72512dba51dd9719c

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2f7bed5ec37a30ef58c12883d42fa9b6a7bc6350a7ecfdc922908b89ff5c9d07
MD5 f81889d33367404c7a09ded0602dc580
BLAKE2b-256 1d33f23ff03eb839aa09ebde50aa0e94f66687c0c058149281816c72a72a5026

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89fb0037857db0de194acd803267b0e8439d48f03d7f708c47942df280a67308
MD5 816ac39e2a53e5cc50fd837b7e96c597
BLAKE2b-256 1b21c379cf6178528a129ebc4eedc58b5599d4943a9f75a793913db33ff936a5

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 43e6f6e2397fc9c6656814531ee755e5ca1d570f55052c615ad914d6292d48c0
MD5 1d62817fb6ee2b935c6a5b40f993a706
BLAKE2b-256 be5607432e97b1b8ea5996f1fbc2f2be15f69bfa9ef0181e17dc31a9b5bee357

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 75f1bf2ae76e814856fd97217699b3b2adca1a5d172dfc8a2c31df0dab06270c
MD5 c53f46335a73bd56cffb79f9d5d02b48
BLAKE2b-256 fe35a02200fa2d3498e31fa215d63707ab3b7cf8a02350ba6854e036f0a7a53d

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ff5149edfa337b64d0230f4ce97d20db42b253722633f2d609f43f5c61736e6
MD5 ce8564861adfb8bddd529c0e1358f73b
BLAKE2b-256 239e75a0c0c770133b903e3f374d6152f61c51ac6d7ac761d92f5c34c1cf17df

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp310-cp310-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp310-cp310-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 7123b496dcf5c9f821a4d926b758c4333de2711cf2ae73955b28252977d9763c
MD5 7cd6a4894279724e37c9700a4415fae5
BLAKE2b-256 a962fb734702440aaa103adb6848cd617974c1dce0d732846f35001df0ff53f3

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 49c1c1e259f8b5db564dc22c6c3df2e4d68df56b038f416799075d7c67ac7b77
MD5 a980d5d33392db3b8faf1e65a2636e15
BLAKE2b-256 4ac4ee281e71aae6df5b19f48da24c177c3b485a7c24eeb1991d5c3746a42e2c

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51be668b0a8a14d314b947da5a5995a328efb88e05ab07ffecfda95fe5743f0b
MD5 9cc9eca0353c80e11d5b57dc8b14c23c
BLAKE2b-256 e6293bd47d8b11ec8c6f958ff0ac8fdb069c84f46e85f79185d403f076d7b841

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 df043476ddb997d3f3479048c269e453a03b049b3605be2b971a6b8d49dcdf30
MD5 1ca6a760ead299d722a2958507b735df
BLAKE2b-256 f2245f9006715d988486b9f8a593d2ed3e768b91fe3c6cd60fd40cd2bd4b5b96

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp39-cp39-linux_armv7l.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp39-cp39-linux_armv7l.whl
Algorithm Hash digest
SHA256 55546867d02020e155d5ef388c7a3702f1b7de56e6297488e2f3a327ffcfd2bb
MD5 63260c11fbe1bf5f9c622b56f23c6ada
BLAKE2b-256 0a1ac0e323579bc9432dc2f9ac962e1b87fb80a99289e77eed487656c0ef7086

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 053d75bb1a54c7088892583ee568a4a6c66f7e13e19b51fd11865672d9115275
MD5 4c6f13b419901d4c92c7420172b23a14
BLAKE2b-256 d47400e0d3e53dd06fd112dbdeaa3311df69809838fb4006f9507ea70060df73

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba7bb98e3c964e56e8f6473e0d4ea3c3b0be69c97a4b97996ff0eb6c1decb250
MD5 3a085500634d1d458e1092ed24554ada
BLAKE2b-256 8605298a7e8130787c154e903917f468ef5337c1cd18e97f6d2e70661f845eb1

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 83f15e0b25e831f28fefcf9269ccb047942967c939f5fd5e35352ef0fdc21796
MD5 78f4ab5e3b0272d5e0e0c69af3878249
BLAKE2b-256 74b5aa3f0ca50dc6076843a01d30bcd7e19d75c4c93d2617ad994a91900bdd90

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c8840da1342ab5a2ffc8b6a01c23a0bcb4e7d97b8f584aafe9248335bfe19f77
MD5 b892132c49328b558068320365732159
BLAKE2b-256 1a6e4bfe9b8edc1701c24d1a11256230351ba6ccbb5dd4bae48786eb7a2e0536

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2dc1cb320aaa4d7a63fe5f55f8ecac36eefafddb47d88d65efcf192ba0fe5a7
MD5 60b65b78e131b2605496dce92f6b6fad
BLAKE2b-256 cc3bcfda6a959d73332e2a11326eb7ad9c003f1ff927ddfba469b79751c39b69

See more details on using hashes here.

File details

Details for the file raylib-4.2.0.0.dev1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 367214dabf756c99666d7347135322dfc0be721b4f00f21d5ab609c2ce64ae52
MD5 aa8eac84d06799c63be3e2c49ac7999d
BLAKE2b-256 47c5a0c0e1899c215cd0c0218a9f33f23dc8f9dcb32916ad1923836147776573

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page