Skip to main content

raylib-py

PyPI - Python Version GitHub release (latest by date) GitHub Release Date

PyPI - Wheel PyPI - License PyPI - Downloads

GitHub all releases GitHub release (by tag) GitHub forks

GitHub commit activity GitHub commits since tagged version

A python binding for the great C library raylib.

How to install:

From PyPI, in the CLI:

$ pip install raylib-py

You can also download the wheel from the releases page and install it with pip locally:

$ pip install path/to/raylib_py-6.0.0-py3-none-any.whl

How to use:

Try this (after installed raylib-py, create a new python file, save the code below into it, then run it):

from raylibpy import *


def main():

    init_window(800, 450, "raylib [core] example - basic window")

    set_target_fps(60)

    while not window_should_close():

        begin_drawing()
        clear_background(RAYWHITE)
        draw_text("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
        end_drawing()

    close_window()


if __name__ == '__main__':
    main()

API Documentation

Please refer to DOCS.md for v6.0.0 for documentation on raylib-py 6.0.

Features:

  • PEP8 naming convention only:

    Structure attributes are in snake_case, classes and other types in PascalCase.

  • Type annotation:

    def get_ray_collision_mesh(ray: Ray, mesh: Mesh, transform: Matrix) -> RayCollision:
        ...
    
  • structures with functions as methods and properties:

    sound = Sound.load('my/resorces/sound.wav')     # same as load_sound(...)
    position = Vector(4.0, 10.0)
    
    # later...
    sound.play()                                    # same as play_sound(sound)
    length = position.length                        # same as vector2length(position); uses raymath.h functions
    
    # creates an array of 3 Vector2 structures
    triangle = Vector2.array(Vector2(10.0, 10.0), Vector2(20.0, 30.0), Vector2(0.0, 30.0))
    
    # creates an array of 24 Image structures, zero initialized
    frames = Image.array(length=24)
    
  • Vector{2,3,4}, Rectangle and Color have attribute swizzling;

    vec3 = Vector3(2.0, 5.0, 3.0)
    vec2 = vec3.zxy                 # vec2 is a Vector2, not a sequence type
    other_vec3 = vec2.xxy           # same thing: other_vec3 is a Vector3
    vec2.xy = vec3.y, other_vec3.z  # sequences can be set as values
    
    c_red = Color(255, 0, 0)
    c_yellow = c_red.rrb
    
    # Rectangles have aliases for width and height: w and h respectively:
    rect = Rectangle(10.0, 10.0, 320.0, 240.0)
    other_rect = rect.whxy          # swizzling is only allowed when using four attributes, not 3 nor 2
    
  • Pretty printing: most structures implement __str__() and __repr__() in a friendly way;

  • Context managers: begin_* and end_* functions can be called as context managers:

    Without context managers:

    # this example shows a rendering step
    
    begin_drawing()
    
    begin_texture_mode(minimap_texture)
    # render the "minimap"
    draw_line(2, 2, 5, 5, RED)
    end_texture_mode(minimap_texture)
    
    begin_mode2d(main_camera)
    # 2d drawing logic...
    draw_texture(minimap_texture, 10, 10, WHITE)
    end_mode2d()
    
    end_drawing()
    

    With context managers:

    # this example shows a rendering step
    
    with drawing():
    
        with texture_mode(minimap_texture):
            # render the minimap
            draw_line(2, 2, 5, 5, RED)
    
        with mode2d(main_camera):
            # 2d drawing logic...
            draw_texture(minimap_texture, 10, 10, WHITE)
    
  • Context managers for some structures: Camera{2,3}D, Shader and others;

    Folowing the example above:

    # this example shows a rendering step
    
    with drawing():
    
        with minimap_texture:
            # render the minimap
            draw_line(2, 2, 5, 5, RED)
    
        with main_camera:
            # 2d drawing logic...
            draw_texture(minimap_texture, 10, 10, WHITE)
    
  • RLGL and RayMath functions exposed

    Includes all symbols in raymath.h and rlgl.h

And more.

Metadata

Release files for raylib-py 6.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raylib-py 6.2.0
File Size Uploaded Provenance Actions
raylib_py-6.2.0.tar.gz 5.4 MB Without provenance Details for raylib_py-6.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raylib-py 6.2.0
File Interpreter ABI Platform Actions
raylib_py-6.2.0-py3-none-any.whl Python 3 none any Details for raylib_py-6.2.0-py3-none-any.whl

Total release size: 11.1 MB

Release files / raylib_py-6.2.0.tar.gz

Download URL raylib_py-6.2.0.tar.gz
Size 5.4 MB
Tags Source
SHA-256 checksum
How to use checksums
38db920557b48ceedb8d99c36ab84d2a4bc362fbed7ca0ef9f9bbd21081c370c
BLAKE2b-256 checksum
How to use checksums
0bed52e97186d8217327f3c47b081342bee7a56b2cf44f105916962958e34799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / raylib_py-6.2.0-py3-none-any.whl

Download URL raylib_py-6.2.0-py3-none-any.whl
Size 5.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
793ca61110f38bf4f8f3e45517839018d395979ca1d3d27cb4451a8b9cbbef98
BLAKE2b-256 checksum
How to use checksums
d0caebbe29574957a68fcf44b387baed9f1df76cd5b34eddf1e604ceea1acb82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for raylib-py 6.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page