Skip to main content

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. Commercial-friendly license. Docstrings and auto-completion.

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 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.0a3

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

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.0a4.tar.gz (109.3 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.0a4-cp310-cp310-win_amd64.whl (764.8 kB view details)

Uploaded CPython 3.10Windows x86-64

raylib-4.0a4-cp310-cp310-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10

raylib-4.0a4-cp310-cp310-macosx_10_14_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

raylib-4.0a4-cp39-cp39-win_amd64.whl (764.8 kB view details)

Uploaded CPython 3.9Windows x86-64

raylib-4.0a4-cp39-cp39-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9

raylib-4.0a4-cp39-cp39-macosx_10_14_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

raylib-4.0a4-cp38-cp38-win_amd64.whl (764.8 kB view details)

Uploaded CPython 3.8Windows x86-64

raylib-4.0a4-cp38-cp38-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8

raylib-4.0a4-cp38-cp38-macosx_10_14_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

raylib-4.0a4-cp37-cp37m-win_amd64.whl (764.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

raylib-4.0a4-cp37-cp37m-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m

raylib-4.0a4-cp37-cp37m-macosx_10_14_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

raylib-4.0a4-cp36-cp36m-win_amd64.whl (764.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

raylib-4.0a4-cp36-cp36m-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6m

raylib-4.0a4-cp36-cp36m-macosx_10_14_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file raylib-4.0a4.tar.gz.

File metadata

  • Download URL: raylib-4.0a4.tar.gz
  • Upload date:
  • Size: 109.3 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.0a4.tar.gz
Algorithm Hash digest
SHA256 73c9ae4289dc59657136cb010428e08c355933bb007ac6bf3e81f63b1e5b86f8
MD5 c15eb922c76b1eacc580f0df1573fcd9
BLAKE2b-256 961629d24a372cb32d2560ad7276dce5b6c95e6cedc25e849a890e8550901103

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-pp37-pypy37_pp73-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-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.0a4-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd73513c30c2127049d1facae32d3dc3ac9545a1a39c49c2c27eb82f8122e491
MD5 4723a70675174a41a95daddcf995cd4b
BLAKE2b-256 844221e4efa26e2e588fe10e3ab51d6974dea6e1b98f1dffa67a4cd94c64463e

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-pp36-pypy36_pp73-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-pp36-pypy36_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.0a4-pp36-pypy36_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de39f5bc43217f16431bfac30d95d17f0e0465713c175bfa7d886579ea49cd13
MD5 c42cc31980d7941a26772ada10e21503
BLAKE2b-256 2c820a41e940c153e3b439ebd2aadedb77d5013eccb62b7a4cd86fb40695dbce

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 764.8 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.0a4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e7be93a9ad50d9bdf53a5ad73a12450882180a3276a742cc2a9959a72d50ad16
MD5 8f8190a926c093145c788f88e27a86aa
BLAKE2b-256 6bc1cc0ac9e64ea79de0bb40d4b867fa768ff8761d9fcb8556327e38873101ea

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp310-cp310-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a4-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 407e40e8b8c9c93620ae1f5420d3a9d1c8e1c4d91938005037bc68814c9e732a
MD5 68f1af3c26aab4109b00b1404b4a6a67
BLAKE2b-256 dc7a69da0616cede5a7041262e875c243bc861c7c9604903dd4ac36480d548f3

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp310-cp310-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 955.9 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.0a4-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 31f65898b964823814b7e8429f4fd498d04d076defbf52db56c808ff8b6245d9
MD5 a7ed8509d4770c9d8c85a177f229de3e
BLAKE2b-256 9adb4211e0d79c3f09a215c5d2549839f109b17cb39a3dcf39c6414d249a3cbd

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 764.8 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.0a4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8d4519991028ef2be015a261dd44638da5fed4a3295de459325d8ec2ba41902b
MD5 ef4406475b2285d7869f850f32a6617c
BLAKE2b-256 8601ad4cecbab11fc2989fe32dc1d6fb09b3c565f9e5df632cf5aafd3b9d6a20

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ae66ea2a2b04bece691967f5990fabb4bbbfad9a8602dc8a8da6f0f1a5a7e42
MD5 6fe06b961c8114fc7231187c815db637
BLAKE2b-256 b1db72662bf9f55653d98628bcc4f0cd5ba302e844e461fe5a0f0fa18b744cea

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 955.9 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.0a4-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 92ed6e504e348b4d9c3027e4ddb7c169a08e93dffe87d1823370ac96c25ebb86
MD5 01c847dfc7020df570265ab6a1e8c810
BLAKE2b-256 7d27e02331db86f6b64b64fd406a04ae7cdead9dbacc05831feaa951f62180d9

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 764.8 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.0a4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 7046438ec5305d84fce5449903878527792625dfea76da75c2deeb3a3d890a1a
MD5 67058a3668bb478fe7e2e384e199f0de
BLAKE2b-256 675ccd45cbcb7cd1ccb7b2778254dd8680a03f51ced37db0b95fecb20a0c8ab7

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b5be3e227aa99b7f9f4460be7f90e6c950884e9ef9ff5fcaeb1fd8361b866e1
MD5 7e492ea833efa0aa1fcd4a66463720bf
BLAKE2b-256 6423205b6da243ce4c01b9910a77791a73bfc7773575186ba039fe8e797c3043

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 955.9 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.0a4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 48b5bd7d5a94f4b8c2318bea875fb06f0bbc7412cf9ce788c50e219f1922027b
MD5 28db725bfec8659b324ca0a315385d45
BLAKE2b-256 a3c4ab2e3d336d0ac5f3b337b8097ff2a1c10a283aad8f86793f28ff98ed0784

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 764.7 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.0a4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6298440f0a90f84589c7eb054973f22b38967a9d18e19d757e33fd643b89789e
MD5 3e14df56c6b89d4a9280cee078b7b379
BLAKE2b-256 7c1e70ab6738e9e39ce81f57308f50b2af122500f730c521f838011f51241366

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b90837e58465c04f7095b682b878fdeb7b0ccfe0d44280e6419e38fa74f691b4
MD5 32a90c800841c2d874efba421afb33c5
BLAKE2b-256 17410946dea77211d4d63bc7babcad16721c92e1c4def96257f3b5784a6a976c

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 955.9 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.0a4-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ce0b8b9625bc43257f4dad852afee13a3c065eff7dccf81e880936286346ac06
MD5 06fe2e2550571e15cbbe550baa3d05e1
BLAKE2b-256 859291cc257064d2edac0bdf06a112c0277e99f84121535cd5213c746adc401e

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 764.7 kB
  • Tags: CPython 3.6m, 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.0a4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f23a0bd6e0b2ac862510191b944bbd40c993bd90bc59da5ef4f04eff97d1842c
MD5 b1ec8a6b196c20cfe5546fa011efe87c
BLAKE2b-256 3400ed1546c27d52aac089b6032b391b0d508f39e629be7b34726ca8f4cdd534

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.6m
  • 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.0a4-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c29b9cc21c8dff45bc53eda48775622e2095a4e3d230659b6b13f05df5995e44
MD5 411920b1b2803435f18aa0155b8a0bdd
BLAKE2b-256 1470419ec8d9f7ea271b4cd52612165a857f636baf1829135da7dc96f3aa34ef

See more details on using hashes here.

File details

Details for the file raylib-4.0a4-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: raylib-4.0a4-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 955.9 kB
  • Tags: CPython 3.6m, 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.0a4-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 bd93144d0995a63fad3f0f387a44d7a8115c59a8dee1d011ff4c420bb5515797
MD5 0c3b622a6dc8ec947dee686241ba782c
BLAKE2b-256 6e052486f21ebc5c88e20ffd1add4ddbf7921426902ec533708de1594042ad10

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