Skip to content

Commit 0b97049

Browse files
docs update
1 parent 7170a56 commit 0b97049

24 files changed

Lines changed: 347 additions & 50 deletions

AGENTS.md

Lines changed: 107 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,55 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is raylib-python-cffi8, Python CFFI bindings for Raylib 5.5 game development library. It provides two main Python modules:
8-
- `raylib`: Direct C API bindings (exact copy of C functions)
7+
This is **raylib-python-cffi** (version 6.0.1.0), Python CFFI bindings for Raylib 6.0 game development library. It provides two main Python modules:
8+
- `raylib`: Direct C API bindings (exact copy of C functions)
99
- `pyray`: More Pythonic API wrapper
1010

11+
Also includes bindings for raymath, raygui, rlgl, physac, and GLFW.
12+
1113
## Key Architecture
1214

1315
- `/raylib/`: Core static CFFI bindings module with build system
14-
- `/pyray/`: Pythonic wrapper API module
15-
- `/dynamic/`: Dynamic binding version (separate package)
16-
- `/examples/`: Python example code organized by category (core, audio, textures, etc.)
16+
- `build.py` — Main CFFI build entry point; parses C headers and generates bindings
17+
- `__init__.py` — Module init, loads compiled CFFI extension
18+
- `colors.py`, `enums.py`, `defines.py` — Generated Python constants
19+
- `/pyray/`: Pythonic wrapper API module around `raylib`
20+
- `/dynamic/`: Dynamic binding version (separate `raylib_dynamic` package)
21+
- `setup.py` — Separate setuptools config for dynamic build
22+
- `raylib/__init__.py` — Runtime-loaded dynamic bindings
23+
- `/examples/`: Python example code organized by category (core, textures, shapes, models, shaders, physics, audio, raygui, extra)
24+
- `/tests/`: Test scripts for both static and dynamic versions
1725
- `/raylib-c/`: Embedded Raylib C library source (git submodule)
18-
- `/raygui/`: Embedded raygui C library source (git submodule)
26+
- `/raygui/`: Embedded raygui C library source (git submodule)
1927
- `/physac/`: Embedded physac physics library source
20-
- `/tests/`: Test scripts for both static and dynamic versions
28+
- `/docs-src/`: Sphinx documentation source
29+
- `/docs/`: Pre-built HTML documentation (hosted on GitHub Pages)
30+
- `setup.py` — Main setuptools entry point for static builds
31+
- `version.py` — Single source of truth for package version
2132

2233
## Build System
2334

2435
The project uses CFFI with setuptools. Main build entry point is `raylib/build.py` which:
25-
- Parses C headers from embedded libraries
26-
- Generates CFFI bindings
36+
- Parses C headers from embedded libraries (`raylib-c/src/raylib.h`, etc.)
37+
- Generates CFFI bindings (`_raylib_cffi.c`)
38+
- Compiles platform-specific extension modules
2739
- Handles platform-specific linking (Desktop/SDL/DRM backends)
2840
- Supports environment variable customization for build paths
2941

42+
### Package names by platform
43+
- Default: `raylib`
44+
- SDL backend: `raylib_sdl`
45+
- DRM backend: `raylib_drm`
46+
- Software rendering (SDL): `_software` (name suffix)
47+
3048
## Development Commands
3149

3250
### Building from source
3351
```bash
34-
# Build Python library manually
52+
# Build Python library manually (generates CFFI bindings + compiles)
3553
python3 raylib/build.py
3654

37-
# Build wheel distribution
55+
# Build wheel distribution
3856
pip3 install wheel
3957
python3 setup.py bdist_wheel
4058

@@ -44,13 +62,13 @@ pip3 install dist/raylib*.whl
4462

4563
### Testing
4664
```bash
47-
# Run main test suite
65+
# Run main static test suite
4866
cd tests && ./run_tests.sh
4967

50-
# Run dynamic version tests
68+
# Run dynamic version tests
5169
cd tests && ./run_tests_dynamic.sh
5270

53-
# Individual test files can be run with python3
71+
# Individual test files
5472
python3 tests/test_hello_world.py
5573
```
5674

@@ -71,19 +89,85 @@ python3 tests/test_hello_world.py
7189

7290
## Environment Variables for Build Customization
7391

74-
- `RAYLIB_PLATFORM`: Desktop (default), SDL, DRM, PLATFORM_COMMA
92+
- `RAYLIB_PLATFORM`: Desktop (default), SDL, DRM, PLATFORM_COMMA, SDL_SOFT
7593
- `RAYLIB_LINK_ARGS`: Manual linker arguments instead of pkg-config
76-
- `RAYLIB_INCLUDE_PATH`: Custom path to raylib.h
77-
- `RAYGUI_INCLUDE_PATH`: Custom path to raygui.h
78-
- `GLFW_INCLUDE_PATH`: Custom path to glfw3.h
79-
- `PHYSAC_INCLUDE_PATH`: Custom path to physac.h
94+
- `RAYLIB_INCLUDE_PATH`: Custom path to `raylib.h`
95+
- `RAYGUI_INCLUDE_PATH`: Custom path to `raygui.h`
96+
- `GLFW_INCLUDE_PATH`: Custom path to `glfw3.h`
97+
- `PHYSAC_INCLUDE_PATH`: Custom path to `physac.h`
98+
- `PKG_CONFIG_LIB_raylib`: pkg-config package name for raylib (default `raylib`)
99+
- `PKG_CONFIG_LIB_raygui`: pkg-config package name for raygui (default `raygui`)
80100

81101
## Package Variants
82102

83-
The project can be built as different packages:
103+
The project publishes multiple mutually exclusive PyPI packages:
84104
- `raylib`: Standard desktop version
85-
- `raylib_sdl`: SDL backend version
105+
- `raylib_sdl`: SDL backend version
86106
- `raylib_drm`: DRM framebuffer version
87-
- `raylib_dynamic`: Dynamic linking version (separate dynamic/ directory)
107+
- `raylib_dynamic`: Dynamic linking version (separate `dynamic/` directory)
108+
109+
Only one can be installed at a time.
110+
111+
## GitHub Actions Workflows
112+
113+
### `.github/workflows/build.yml`
114+
115+
The main CI/CD workflow. Triggered on push, pull request, and manual dispatch.
116+
117+
**Jobs:**
118+
- `build-mac-intel` — macOS Intel runners (`macos-15-intel`), Python 3.7–3.14 + PyPy 3.11, Desktop/SDL platforms
119+
- `build-mac-arm64` — macOS ARM64 (`macos-14`), Python 3.10–3.14, Desktop/SDL platforms
120+
- `build-linux` — Ubuntu 16 container (`electronstudio/ubuntu16-modern`), Python 3.7–3.14 + PyPy 3.11, Desktop/SDL/DRM/SDL_SOFT platforms
121+
- `build-linux32` — 32-bit Ubuntu 16 container, same Python versions and platforms
122+
- `build-linux-arm64` — Ubuntu ARM64 (`ubuntu-22.04-arm`), Python 3.10–3.14, Desktop/SDL/SDL_SOFT
123+
- `build-linux-arm64-drm` — Raspberry Pi OS containers (Bullseye/Bookworm), Python 3.10–3.14, DRM only
124+
- `build-windows` — Windows Server 2022, Python 3.7–3.14 + PyPy 3.11, Desktop/SDL/SDL_SOFT, x64
125+
- `build-windows32` — Windows Server 2022, same Python versions, x86
126+
- `source-distro` — Builds and publishes sdist
127+
- `dynamic-distro` — Builds and publishes `raylib_dynamic` sdist
128+
- `merge` — Merges all artifact uploads
129+
130+
**Manual dispatch inputs:**
131+
- `publish_to_pypi` (boolean): Publish wheels to PyPI after build. Requires `PYPI_KEY` secret.
132+
133+
All build jobs perform a smoke test after building: `import pyray; pyray.init_window(100,100,"test")`, checking output for `"INFO: Initializing raylib"`.
134+
135+
### `.github/workflows/test_pypi.yml`
136+
137+
On-demand workflow to verify packages work when installed directly from PyPI. Triggered manually via `workflow_dispatch`.
138+
139+
**Inputs:**
140+
- `package_name` (string): Which package to test (`raylib`, `raylib_sdl`, `raylib_drm`, `raylib_dynamic`) — default `raylib`
141+
- `version` (string): Specific version to install (e.g., `5.5.0.2`) — leave empty for latest
142+
- `pre_release` (boolean): Whether to pass `--pre` to pip to allow pre-release versions
143+
144+
**Matrix:**
145+
- OS: macOS Intel (`macos-15-intel`) and macOS ARM64 (`macos-14`)
146+
- Python versions: 3.10, 3.11, 3.12, 3.13, 3.14
147+
- Python source: Homebrew (`brew install python@X.Y`) and python.org (`actions/setup-python`)
148+
149+
The workflow installs the selected package from PyPI and runs the same smoke test (`import pyray; pyray.init_window(...)`) to verify the installed wheel works correctly.
150+
151+
## Testing Structure
152+
153+
- `test_*.py` — Standard tests (run by `run_tests.sh`)
154+
- `xtest_*.py` — Extra/manual tests (not run by default scripts)
155+
- `test_hello_world.py` — Minimal smoke test for basic import and window init
156+
- `test_pyray.py` — Tests the `pyray` wrapper API
157+
- `test_static_with_only_api_from_dynamic.py` — Ensures static API matches dynamic
158+
- `test_color.py`, `test_float_pointers.py` — Type/struct sanity checks
159+
- `test_gamepad.py`, `test_raygui_style.py` — Feature-specific tests
160+
161+
## Documentation
162+
163+
- Source: `/docs-src/` (Sphinx reStructuredText)
164+
- Built output: `/docs/` (HTML, committed for GitHub Pages)
165+
- Hosted at: https://electronstudio.github.io/raylib-python-cffi
166+
- `make_docs.sh` regenerates `/docs/` from `/docs-src/`
167+
168+
## Notes for Contributors
88169

89-
These are mutually exclusive - only one can be installed at a time.
170+
- The `version.py` file is the single source of truth for the package version.
171+
- CFFI bindings are generated at build time from headers in `raylib-c/src/`, `raygui/src/`, `physac/src/`.
172+
- Submodules must be initialized (`git submodule update --init --recursive`) before building.
173+
- The `raygui.h.diff` patch is applied in CI to fix a raygui bug before compilation.

AI_POLICY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# AI Policy
2+
13
AI will be used in this project only when it is impossible to tell that it has been used.
24

35
Given the current state of AI in 2026, this in practise means:

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ while not window_should_close():
3333
close_window()
3434
```
3535

36-
37-
3836
Use the [project generator](https://github.com/electronstudio/python-raylib-template) to generate a complete project. [Example of project](https://github.com/electronstudio/raylib-example-game)
3937

4038
# Videos
@@ -59,6 +57,7 @@ Use the [project generator](https://github.com/electronstudio/python-raylib-temp
5957
* [Python video player](https://github.com/anrayliu/pyvidplayer2)
6058
* [A Vector2 class](https://github.com/electronstudio/raylib-python-cffi/blob/master/examples/extra/vector2_extended.py)
6159
* [Raylib C FAQ](https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions/)
60+
* [Project generator](https://github.com/electronstudio/python-raylib-template)
6261

6362
# Installation
6463

@@ -216,6 +215,16 @@ Carefully read all their [documentation](https://pygame-web.github.io/).
216215

217216
It does work for most of [these examples](https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/)
218217

218+
# Startup without printing anything
219+
220+
```python
221+
import logging
222+
logging.basicConfig(level=logging.ERROR)
223+
import pyray
224+
pyray.set_trace_log_level(pyray.LOG_ERROR)
225+
pyray.init_window(100,100,"test")
226+
```
227+
219228
# App showcase
220229

221230
[Tempest-raylib](https://github.com/Emtyloc/tempest-raylib)
@@ -230,8 +239,6 @@ It does work for most of [these examples](https://electronstudio.github.io/rayli
230239

231240
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
232241

233-
[Eidolon](https://github.com/Miou-zora/Eidolon)
234-
235242
Add your app here!
236243

237244
# RLZero
@@ -297,3 +304,7 @@ You can create a standalone binary using the Nuitka compiler. For example, here
297304

298305
[Coding Games With Pygame Zero & Python](https://github.com/electronstudio/pygame-zero-book) is
299306
a book for Python beginners.
307+
308+
# Hall of shame!
309+
310+
Apparently [comma.ai](https://comma.ai/) are now using raylib-python-cffi commercially and so have begun donating money to raylib but have chosen _not_ to give anything to raylib-python-cffi. Yes it's perfectly legal usage, but it's not very nice behaviour. 😔

RPI.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Please use Raspberry Pi OS 13 Trixie 64 bit. Bookworm should also work. Older
66
Option 1: Binary wheel
77
----------------------
88

9-
We have published binary wheels compiled for 64-bit Raspberry OS 12 Bookworm in X11 mode.
9+
We have published binary wheels compiled for 64-bit Raspberry OS 12 Bookworm in Wayland/X11 mode.
1010

1111
::
1212

1313
python -m pip install --break-system-packages raylib
1414

15-
Alternatively there is a DRM wheel called ``raylib_drm`` to use the framebuffer without X11. You can't have both wheels
15+
Alternatively there is a DRM wheel called ``raylib_drm`` to use the framebuffer mode. You can't have both wheels
1616
installed at once.
1717

1818
If it doesn't work, or you're not on Bookworm/Trixie, or you're 32 bit, you will need to compile your own raylib. See below.
@@ -79,7 +79,7 @@ Build a shared lib version of Raylib in DRM mode and install to /usr:
7979
make
8080
sudo make install
8181

82-
82+
8383
Then have pip compile and install the wheel:
8484

8585
::

docs-src/AI_POLICY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../AI_POLICY.md

docs-src/index.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ Raylib Python
1616
dynamic
1717
BUILDING
1818
RPI
19+
AI_POLICY
1920

2021

2122
* :ref:`search`
22-
23-
24-
25-

0 commit comments

Comments
 (0)