Skip to main content

Python CFFI bindings for Raylib

Project description

Python Bindings for Raylib 4.0.0

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: 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 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.

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

This version

4.0.0

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.0.0.tar.gz (54.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.0.0-cp310-cp310-win_amd64.whl (740.5 kB view details)

Uploaded CPython 3.10Windows x86-64

raylib-4.0.0-cp310-cp310-manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10

raylib-4.0.0-cp310-cp310-macosx_10_14_x86_64.whl (922.4 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

raylib-4.0.0-cp39-cp39-win_amd64.whl (740.5 kB view details)

Uploaded CPython 3.9Windows x86-64

raylib-4.0.0-cp39-cp39-manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9

raylib-4.0.0-cp39-cp39-macosx_10_14_x86_64.whl (922.4 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

raylib-4.0.0-cp38-cp38-win_amd64.whl (740.5 kB view details)

Uploaded CPython 3.8Windows x86-64

raylib-4.0.0-cp38-cp38-manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8

raylib-4.0.0-cp38-cp38-macosx_10_14_x86_64.whl (922.4 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

raylib-4.0.0-cp37-cp37m-win_amd64.whl (740.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

raylib-4.0.0-cp37-cp37m-manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7m

raylib-4.0.0-cp37-cp37m-macosx_10_14_x86_64.whl (922.4 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

File details

Details for the file raylib-4.0.0.tar.gz.

File metadata

  • Download URL: raylib-4.0.0.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0.tar.gz
Algorithm Hash digest
SHA256 8e45b34e3ba07f6701112e5e880fe31910dde0fd23b7717379229d8f4e90cd1c
MD5 98b08a60dcb5b568d1fb971e88a96d00
BLAKE2b-256 dec434fc0a91acd1ee2d8730011e72137f85827e42415378bb259ef3071fb6c4

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-pp37-pypy37_pp73-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-pp37-pypy37_pp73-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: PyPy
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2f0428d1c4d7e409c98da44455385ba458c35279b4339a369bd966e4ba82150
MD5 6bcb05953c31f40078672fde21bdee81
BLAKE2b-256 17fba3dbc23588f2c5e01dddab67ccf8a882636158423dc0f4719d4b060a0c54

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 740.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d5ddb04f102d887a3c5add96801fc4725bca0d3ae44baabbb46a3ddadd3bbb95
MD5 2d3463e44e5272d5e4ca3cc26ab9f194
BLAKE2b-256 c70d9d5c10d787e32337f40045e581251c24b705d12a57bb66f220e938766325

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp310-cp310-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7003e2300ff7708b5e04d196ca4c8edaa690e6c7ea975dffe05fa8aabc1ece00
MD5 bb18a4ed19bcfd9076fc51e396f94a5e
BLAKE2b-256 dfd940e86ad5b5a462b73215ffa61fbf656143f66c9dbe50feac7a2bee16e870

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp310-cp310-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.4 kB
  • Tags: CPython 3.10, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a55eb11f657a29758b140aa075424a081219f5ee493ecd14cf7f0f710a424e08
MD5 0772bbc3dc97d2e34ad88f70cf15b711
BLAKE2b-256 8ede6cf85976ab89d66af1dd7879cfb2621904a7cbd85b4af7c0b32a5be943ea

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 740.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 861b8d7c1dcc2bee3ce6389e00e200dfc149b96c36fe9e1b5582ca9a0c17b029
MD5 ab3b0d07957bb1712fc1aadcafd2ad6c
BLAKE2b-256 2234752e233238aa682ff29842f75e83fdafcfd6b77c4b32b14b41a427056b33

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 535de116a90251ed8e9b6b0e216eb78b04f715936cfac2331c04580b1b72b374
MD5 f865e80b71740123eab6eb0ee8c389a0
BLAKE2b-256 ba46282a6e17968138f52669f6ba8d4e7e247dc9c44c9abeec5b58816611de02

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.4 kB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 147b244dce09ec9ca8ab07d3ff672bf5b5f9a0890429eb2dab4414da9c8859ef
MD5 b177aa53d5a9c30fe4bedd6a1706c66b
BLAKE2b-256 dfcafa5a48f157d2aa2022ffe3ef6dadd90e1744f0cb4bb4e3effba82388346a

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 740.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 80f62a7538b9b4905f38bddeeeacd269bf16eddd123bbbf3771775c182cdd652
MD5 cba54244757121e4fc1427958f00d796
BLAKE2b-256 6b3f3fb18a5453bd9ffdeffeb14854fadf5f73fc888d05326cd5db7f5315c02c

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee22f0c5af5c9fdc62e2e1d4c3cefb81b82aa19c38ce782addc1aa5bcce5eac6
MD5 3975b2ad3b4573393302197e98db1991
BLAKE2b-256 98dc9f6845d68f5f0c10c0724f2c527f1eb730b6e365a7e07e2b137162706473

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.4 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c8f954e5a8def24a657ce7d03cd2ed234133c602b58821086ad1a5522fdc272a
MD5 c72af0901a32806ae3f5e43ca0a98c7e
BLAKE2b-256 390b3d16f463f15f59b3994f2aa5a1d13bed2f46cd4ac5f3e84028b73ae04efa

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 740.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 24a9a3632c4e975b49efd7fc6b46c2a15f7ded338016430c3fd985b70ffc56b1
MD5 f4bb32de4bc365e278d617390a5906cc
BLAKE2b-256 abc10257060bbd386d3c80a996cda862aaf921867a205cfd58685261da124506

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddf347a951b9a5001e7280c1c281b0479fbe0ff1f7dfbe4aee9c0477e860c9ba
MD5 609ed9fd5d44edb2504f02e165063702
BLAKE2b-256 7c950f92a5e4ec7741dcc2d1ca1a6bbbd26ea77b05cddca6395481cd5d0ef773

See more details on using hashes here.

File details

Details for the file raylib-4.0.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.4 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for raylib-4.0.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f8550f86c9bdd993c922e1fc2e6048f0aca2e9d7e41bfefc9570222c1d23f0f3
MD5 f04318e7b88d0b590757c75157c98679
BLAKE2b-256 f31faa339cc54dd483099c46ac25f704c06875500352f47809a7e0821618e79e

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