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.dev2.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.dev2-pp39-pypy39_pp73-win_amd64.whl (735.2 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev2-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.dev2-pp38-pypy38_pp73-win_amd64.whl (735.2 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev2-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.dev2-pp37-pypy37_pp73-win_amd64.whl (735.2 kB view details)

Uploaded PyPyWindows x86-64

raylib-4.2.0.0.dev2-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (918.5 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

raylib-4.2.0.0.dev2-cp311-cp311-win_amd64.whl (837.9 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11

raylib-4.2.0.0.dev2-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.dev2-cp310-cp310-win_amd64.whl (837.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10

raylib-4.2.0.0.dev2-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.dev2-cp39-cp39-win_amd64.whl (837.9 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9

raylib-4.2.0.0.dev2-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.dev2-cp38-cp38-win_amd64.whl (837.9 kB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

raylib-4.2.0.0.dev2-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.dev2-cp37-cp37m-win_amd64.whl (837.9 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

raylib-4.2.0.0.dev2-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.dev2.tar.gz.

File metadata

  • Download URL: raylib-4.2.0.0.dev2.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.dev2.tar.gz
Algorithm Hash digest
SHA256 c1350bfcd96e22635dedac7f4d5a4ff292cc4ef333afa764a2abad41bffbd474
MD5 b7caff436f1e063e3a0a6cd322e58d21
BLAKE2b-256 087d520281892a2e5eae5fef8c033e3c3a4130f5a62dc22ce76092f9d0ec5059

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 319094ca95faf36e1a56670bc78413374e1ef251169c168b608ffb21589597fc
MD5 762657e6c8455687fc042de43033cb64
BLAKE2b-256 0e0f4c8f2ef14c7dd75a5b15e7abfc4692ed82feb8f8d10b9ac8db43c90e7365

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 17efe6b72e3d40dd5a6c2c0e9d25c2ab9ed8c05a799dd012955c08b5f3ad1e50
MD5 60ce7436b7955786330a8db2a4c5ba00
BLAKE2b-256 479417a8499875c83ac45b34123e852f1ee641f2519933fff4e93adb94ea7296

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 41526f3d0a67b38ef7bb3473f1ed0e80c05773d13c80e293c4808f7bdbb83d92
MD5 843dfb88e1d6d5ec4d0dae55a8be87c5
BLAKE2b-256 fcbb44139be1cbdf6dab1dbe298ea6f4f10b085512d0fd962717c0824af5a14c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 992acfba1175ba28f840343b438b20820d4bd80d4a7acc86033166f31c17ca19
MD5 a7863164451ea9f333bfd3dcb77de819
BLAKE2b-256 18ee1ec3e9bb4a0f3535b5d37db6c366ddf224b7a06b2d300c833e16ec65371d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd48923fb13efeaddb7966a44cb7e830f92ba67b71aee55a838e912836ff7e38
MD5 c7dcd61901fbb1a792c8d12057d20357
BLAKE2b-256 3ce5c340932153c1e6882782efc0e9ac3ba14c74886ceab06aed98feedb5f906

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a4c6c5728ab08534eb2c2690563b08a5aa316ee93e917dc8c8aeaa35d64d7f61
MD5 39bdda1246ed055a353ea04b7e5722e6
BLAKE2b-256 a1f300fbb7cf974eedb909f79665f532745063cbdaab6876da3381ce94ba7810

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp37-pypy37_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e10bf5baf0624d0bba9c752b53bb6a305c8a0a9e6b14bd2d113f538c8b7c310b
MD5 103e3b7c781133cc06a602a8af23600a
BLAKE2b-256 17b9535053d1e6cef714b7713278aead9bbd86e6dcdff51b665cd2a82f9ecf80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e087e2838e0a17c9f264b5f1769758e6c9de31fea8e8b8989baec38acccc19fd
MD5 bebc520d3db08b01dd9f97480fa935f8
BLAKE2b-256 69816c894cc745aae4ebaa7725cdef0af78e0acd409ec25a974fca8b5d1cc0c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 29d09f4fbcd564f125b1dd9531e6384bc56b4fc4c1d2a7c88ebad5b84d71cd8b
MD5 7b52c0bc09ef84b97a58172f065d920c
BLAKE2b-256 9e0b91f740a3d02269d9f67b4b8e09d47349cf52d9b823cb37fe164e0fa6e5f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 41b6afcb07a6c131f9f51779f5ba91e89e043ab6841621b92f7032302437eb37
MD5 e9756efee7f7a943aa4fa1c033170f27
BLAKE2b-256 a6462ef7382c4ff6a936730f21b3e6834fcddcca11bed2f6c3136894b7faacac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e40fb97a029ae08df1f0319a2faae30f9845400f5b53ad04ccdc386ac964702f
MD5 c8ddc2252f597c322727969bf61c9f3b
BLAKE2b-256 64c0d303262d64a97102cd4f47afb9a952282ba981303b646aea9be4600a16ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cb98c7211a57db4d0c399f9ffbebb27f6b25f0413facd7f28c100a94765eebf5
MD5 c0933e7638ed895dad76a00c8bce47a4
BLAKE2b-256 656da4ce1157cb8986e8845f784e12c928f5e0702667b6857dee50cf10909635

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cf3e4868494dfa5f4c87b49214eae45fb97cd83ece5642f7717fb3773b0dd5a1
MD5 635cfbcdfce649fdf5eb8665215860ed
BLAKE2b-256 5e1a55a033d39791e1c51ef6da303237536f9ab4c1b6dbd6c29b75e52c1bea0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 beb91bfb6f9aae663cf2efa59e6b8491b832b4f7aab88b19db75896816cd80ba
MD5 c1131b5926e3030c717f6e1c6277fcc6
BLAKE2b-256 dda34984d99500e5bb133e2cf99ec4181b99a3474d0d4b837b7f7e7ec328a26e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp310-cp310-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 399214afe246952c9f1732a64eb3b2d1425ce719a4914990c59cfc1dcf6b9b7a
MD5 72643184f2a2f972bc2bde7cdbd9a59c
BLAKE2b-256 0d122bbb3c9eae37f072cc9eadccbaace32459457e4e70757f57796ee497fe30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a6db954ecd4936f8fa73b983fb70cb6c65ea2ced5f48d4d173cd409d5ef761a4
MD5 d70d6b3fd41ec4119f660341fb762169
BLAKE2b-256 dfd177da6af9508de94e49b08ed941507bdc7384e7d1efb9e3d54b66989dd74f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 645f82eef28a2fb04ae61ab0dcce5f8352e975fb0956eb11c1dad23c83fbf7a2
MD5 4f5907526848b9726f2f069d03e3dc51
BLAKE2b-256 6e24187ccad49b7c7037017e2bf2cb6b9397e9ec577dddcda87a340703c7a9e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 985bd5aeea122505a97edbec5864ba7de9029420ee777fcb36221d0a7b87071b
MD5 d02ccea857bdcf06f1504e8af655ec89
BLAKE2b-256 19d25ed4477472ce61f33802a0d0cfca3add9af2ae737646baf442ad5d1f09a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f6acf3eba2eac6eb2b1ca6c47422b8c5d6442d0c4d9a883504f9a63f6a6ed7e1
MD5 0fc3b9fcba3d78f56b61e184f9e2c1ea
BLAKE2b-256 a8d7c4b03a3adc80747e6a9328f094d5eda154c9f148d0cdb011395c8246778c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b820214f08e5f352a683a2f38572eb4d17143efae5c7136f072e95c7f4da8e80
MD5 98aff6256dfa12d590726036d0027ac5
BLAKE2b-256 e7d5537fd80b4547752962b6df5e06ef2660e1b5303c7392bcd2fa70d8e9079b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 73f4e43533d10c36c3c2a867a9feea10f7cf29c08e33a1649e5eb2516ed65afe
MD5 99ffe932f0cb1b0fd87ff604695d677a
BLAKE2b-256 962eee0b8e944576013d271c849deb79a628407067676b10fc26c4423ca82e87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 46704883c1402f5b0fa6d22ad2c6bd19dbfc6d8f41aed10b3dc57863fa01fbed
MD5 7d334c75893807370c6b0da4cd4f8b9e
BLAKE2b-256 261bd8a99eccb771f58f95e9cabeb587a489aa8f3a16263121ac64e76f987d85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff3223e1a3f562b8c46c0c6e4137f7bd3641f25c54e9c9873d5955eb66d87791
MD5 2f8606e59468df7d2b3991916d77bff0
BLAKE2b-256 abd40fe4d49ddd94e33cd40b09f2381e9a2b5e9231ffb3a30d015cea1b9db950

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for raylib-4.2.0.0.dev2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1d3535aeb87ff72120a1ebead8254548d585bdddf63833876732317ecaf51908
MD5 318bbb9be55af282782c63a4f8ceea2c
BLAKE2b-256 308f52dee8ebd3486704a00f24797f66939c72fea256faf2d28096962bb0aa9e

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