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

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.0.0.3.tar.gz (54.5 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.3-cp310-cp310-win_amd64.whl (739.1 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10

raylib-4.0.0.3-cp310-cp310-macosx_10_14_x86_64.whl (922.7 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

raylib-4.0.0.3-cp39-cp39-win_amd64.whl (739.1 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9

raylib-4.0.0.3-cp39-cp39-macosx_10_14_x86_64.whl (922.7 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

raylib-4.0.0.3-cp38-cp38-win_amd64.whl (739.1 kB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

raylib-4.0.0.3-cp38-cp38-macosx_10_14_x86_64.whl (922.7 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

raylib-4.0.0.3-cp37-cp37m-win_amd64.whl (739.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

raylib-4.0.0.3-cp37-cp37m-macosx_10_14_x86_64.whl (922.7 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: raylib-4.0.0.3.tar.gz
  • Upload date:
  • Size: 54.5 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.3.tar.gz
Algorithm Hash digest
SHA256 0c114bfb8d108ffe4aea08c2433060c05fb56782095a139698b00e9a899a3e99
MD5 b7013f6fa7c3ecdacb9c7dc038fbd781
BLAKE2b-256 f68cd9f3b0bcbd260c109b36fa70b882ea1bf92d1eb83a335cf64a5033aeb525

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-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.3-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 02534166dc338aac525ec545a3032c5c10d0e91267c6587c279dde27833295e4
MD5 336c0d92805d9389142fe19cb0e636da
BLAKE2b-256 429627df3f7e719dc03a605fe5533c99c879fbb5f6ab1603e77398e12e0ebda7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.1 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1e911f58b4c507318a2d55b673877563c657984d0b37bc9119e7638c1792a33c
MD5 6bfa474def4a96c7efb521828e56a46f
BLAKE2b-256 a856e8d7ac400fd2b53a6d91b39d574b0f90bb2d094b9f2ec79c55fb740e33b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-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.3-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a697774d1e26772708c1287bc862c7fe825826835d44a1d35125421b546d2675
MD5 75ae45a996da895cac4b3ace1f18d94c
BLAKE2b-256 00c1c5eb6ec2371c7889384fd73e0e4718c483aae5389a7750b0fdb6302c8cad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp310-cp310-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.7 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.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 07a1fe682e25907271adbb30a7c005a7de88a37dab364f0653f8bd1c1afc9da3
MD5 5a9e83d6c66e4cfd92052a6e80a22c50
BLAKE2b-256 f8a4a28fc50b0ba59490be240a8d6381229de17ebf3335d82ede33297b25e0d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 739.1 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e10b193353c5f7a692d23c922212bd1c47b28c7ea081d7a8b66a76b47d1941e7
MD5 75640ade58596313815bc3717af57c11
BLAKE2b-256 ef1989517afe518af43414151de2cdbe6fdea972f764bb99b674ac8baf5838b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-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.3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 731086777ee9af96cb55f802fe2ddf694d95faedbf617ca3290759ce899d3f19
MD5 9cb5da0472f4dc34c93e68abd9ff6f9a
BLAKE2b-256 79ae279106bea8e5c80447ceb220b546ce38dfb798fde2eee37743d0e7549a4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.7 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.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9db60c0953988971ce795bc226460afcf8fe37d5d6c0e61970d4751daabbc0e2
MD5 9fec3b867cc4ec94dc0e0aba3cb62c29
BLAKE2b-256 e56b04936316bfb6b357658a8ba0718efbb8c172060a5aac5ed53534846411ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 739.1 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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e56fa823d30b1d5dcd7c487f71c97dd96ad8787a35ed86d39835aeebb74de3af
MD5 e957da6d165c4faa34e9b1799a1c637c
BLAKE2b-256 3fe501b8441796737f64cf0d2951be475a272a06f80fe8916f9cfa7faa0e945f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-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.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b13eaf7405fa1610f14bdf6ab600f457eb7b23187a2c8d19fd1617b5e5727fab
MD5 1e6350f80d69b520c03ab38e167d4f76
BLAKE2b-256 823bae6b8bbb338da1265ee489025ae6f8262521a25d4ab2c22c3468f7fedb50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.7 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.3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 83417ad832cfab88c0f52758053dae2b2d17c466029481eead58b83c9c235a61
MD5 76e1508a24155926d3810a2238722f6c
BLAKE2b-256 2f2e7c2402a469df318e34728325711419091dc862e2ba944a5b9a277fa28a91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 739.0 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.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2a4daab11c33997dd12a6dcc2eb9cd6fc6339dfd1a6554796301b1b64779d6d1
MD5 f6b4fc9971621b3bfb8a5d385a1a7a18
BLAKE2b-256 e1cba3fa79d038e6a112bf09adde6edbf68d8e29f1ec188076fb5b8537b182e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-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.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ce6c54f6240ccf01721bf03700047b5f70112660017139a5096ff87a9599f5b
MD5 b4bdb868460db2564d25e0e9826971d2
BLAKE2b-256 c5e425a9bd5ef3363c029933a8f748d0be7caf38f69d5caa401e6d489b94388c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raylib-4.0.0.3-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 922.7 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.3-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 320dacfb92da98dab5387a6cf568867391432f5773fee60549515193c7cad74c
MD5 2010e0b00516c44f32b74e45e1f2b552
BLAKE2b-256 e902ac7268e4fdd7e272624566fa427c41ef2499b389d4690902fe2c296bce05

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