Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
33fccbb
raylib: bundle mesa so the headless wheel has no system GL deps
greatgitsby Aug 23, 2026
bb5a3fd
drop comments
greatgitsby Aug 23, 2026
7af06fa
move MESA_VERSION to top
greatgitsby Aug 23, 2026
a7cf230
clone mesa from gitlab.freedesktop.org: archive.mesa3d.org unreachabl…
greatgitsby Aug 23, 2026
d1bb3d9
raylib: llvmpipe (mesa 25 + minimal static LLVM) instead of softpipe;…
greatgitsby Aug 23, 2026
400f6a6
raylib: default to headless when there is no DISPLAY; pin cmake's nin…
greatgitsby Aug 23, 2026
adb0212
raylib: DISPLAY as a named sensed var in detect_backend
greatgitsby Aug 23, 2026
77664c3
Revert "raylib: DISPLAY as a named sensed var in detect_backend"
greatgitsby Aug 23, 2026
0e2ce5b
revert test_wheels_in_image.sh changes
greatgitsby Aug 23, 2026
c1f02d1
raylib: build llvm/mesa inside their src dirs
greatgitsby Aug 23, 2026
3020105
raylib: show meson output
greatgitsby Aug 23, 2026
8d718d0
raylib: pin mesa/llvm sources to their versions on every run, cached …
greatgitsby Aug 23, 2026
b568237
test_wheels_in_image.sh: fail on smoketest errors
greatgitsby Aug 23, 2026
0fdb001
raylib: bump mesa 26.2.1 / llvm 22.1.8; fetch llvm via sparse git clo…
greatgitsby Aug 24, 2026
ad4cc91
raylib: replace a cached non-git llvm-src
greatgitsby Aug 24, 2026
3d18ecd
ci: cache check
greatgitsby Aug 24, 2026
91c4a74
raylib: don't re-checkout llvm/mesa when already at the pinned tag, i…
greatgitsby Aug 24, 2026
13612ef
raylib: checkout_tag helper, a failing clone/fetch in a ||{} group di…
greatgitsby Aug 24, 2026
8955153
raylib: clone/fetch/checkout llvm and mesa the same way as the other …
greatgitsby Aug 24, 2026
65652f6
raylib: build mesa through ccache
greatgitsby Aug 24, 2026
5f08554
raylib: always use ccache
greatgitsby Aug 24, 2026
de15c28
ci: cache check
greatgitsby Aug 24, 2026
c84089a
ci: cache check 2
greatgitsby Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
if command -v dnf &>/dev/null; then
dnf install -y -q \
libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel \
mesa-libGL-devel mesa-libEGL-devel mesa-libGLES-devel \
mesa-libGL-devel mesa-libEGL-devel mesa-libGLES-devel bison flex \
wayland-devel wayland-protocols-devel libxkbcommon-devel
fi
fi
Expand Down
44 changes: 39 additions & 5 deletions raylib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ cd "$DIR"
INSTALL_DIR="$DIR/raylib/install"

NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
if command -v ccache &>/dev/null; then
CC="ccache ${CC:-cc}"
else
CC="${CC:-cc}"
fi
CC="ccache ${CC:-cc}" CXX="ccache ${CXX:-c++}"

is_linux_aarch64() {
[[ "$(uname)" == "Linux" && ( "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ) ]]
Expand All @@ -35,6 +31,8 @@ esac

# Clone and build raylib C library
RAYLIB_COMMIT="caa64e15ac20a47804a8048029c921ac091fef12"
MESA_VERSION="26.2.1"
LLVM_VERSION="22.1.8"

if [ ! -d "raylib-src/.git" ]; then
rm -rf raylib-src
Expand Down Expand Up @@ -91,6 +89,42 @@ for backend in $BACKENDS; do
build_raylib "$(backend_platform "$backend")" "libraylib_${backend}.a"
done

if [ "$(uname)" == "Linux" ] && [[ " $BACKENDS " == *" headless "* ]]; then
if [ ! -d "llvm-src/.git" ]; then
rm -rf llvm-src
git clone --depth 1 --filter=blob:none --sparse https://github.com/llvm/llvm-project.git llvm-src
git -C llvm-src sparse-checkout set llvm cmake third-party
fi
git -C llvm-src fetch --depth 1 origin "llvmorg-$LLVM_VERSION"
git -C llvm-src checkout --force FETCH_HEAD
cmake -S llvm-src/llvm -B llvm-src/build -G Ninja -DCMAKE_MAKE_PROGRAM="$(command -v ninja)" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX="$DIR/llvm-src/prefix" \
-DLLVM_TARGETS_TO_BUILD=Native -DLLVM_BUILD_TOOLS=OFF -DLLVM_TOOL_LLVM_CONFIG_BUILD=ON -DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_FFI=OFF -DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_ASSERTIONS=OFF -DLLVM_ENABLE_UNWIND_TABLES=OFF \
-DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections" -DCMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections" >/dev/null
ninja -C llvm-src/build install llvm-config >/dev/null
cp llvm-src/build/bin/llvm-config llvm-src/prefix/bin/

if [ ! -d "mesa-src/.git" ]; then
rm -rf mesa-src
git clone --depth 1 https://gitlab.freedesktop.org/mesa/mesa.git mesa-src
fi
git -C mesa-src fetch --depth 1 origin "mesa-$MESA_VERSION"
git -C mesa-src checkout --force FETCH_HEAD
CC="$CC" CXX="$CXX" PATH="$DIR/llvm-src/prefix/bin:$PATH" meson setup mesa-src mesa-src/build --reconfigure --prefix="$DIR/mesa-src/build/prefix" --libdir=lib \
-Db_ndebug=true -Dcpp_rtti=false -Dc_link_args=-Wl,--gc-sections -Dcpp_link_args=-Wl,--gc-sections \
-Dplatforms= -Degl=enabled -Dgles1=disabled -Dgles2=enabled -Dopengl=false -Dglx=disabled \
-Dgbm=disabled -Dglvnd=disabled -Dgallium-drivers=llvmpipe -Dvulkan-drivers= -Dshared-llvm=disabled \
-Dlibunwind=disabled -Dzstd=disabled -Dvalgrind=disabled -Dbuild-tests=false \
-Dxmlconfig=disabled -Dexpat=disabled -Dshader-cache=disabled
ninja -C mesa-src/build install >/dev/null
cp mesa-src/build/prefix/lib/{libEGL.so.1,libGLESv2.so.2,libgallium-$MESA_VERSION.so} "$INSTALL_DIR/lib/"
cp -L "$(cc -print-file-name=libdrm.so.2)" "$INSTALL_DIR/lib/"
patchelf --set-rpath '$ORIGIN' "$INSTALL_DIR"/lib/{libEGL.so.1,libGLESv2.so.2,libgallium-$MESA_VERSION.so}
strip "$INSTALL_DIR"/lib/*.so*
fi

# Download raygui header
RAYGUI_COMMIT="1e03efca48c50c5ea4b4a053d5bf04bad58d3e43"
curl -fsSLo "$INSTALL_DIR/include/raygui.h" \
Expand Down
2 changes: 1 addition & 1 deletion raylib/build_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def build_ffi():
else:
print("BUILDING FOR LINUX")
extra_link_args = [
raylib_archive,
raylib_archive, f'-L{RAYLIB_LIB_PATH}', '-Wl,--as-needed',
'-lm', '-lpthread', '-lrt', '-ldl', '-latomic',
*BACKEND_LINK_ARGS[RAYLIB_BACKEND],
]
Expand Down
4 changes: 2 additions & 2 deletions raylib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=70.1", "cffi>=1.17.1"]
requires = ["setuptools>=70.1", "cffi>=1.17.1", "meson", "ninja", "mako", "pyyaml"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -17,4 +17,4 @@ include = ["raylib", "pyray"]
namespaces = false

[tool.setuptools.package-data]
raylib = ["_raylib_cffi*.so", "install/include/*.h", "install/lib/*.a"]
raylib = ["_raylib_cffi*.so", "install/include/*.h", "install/lib/*.a", "install/lib/*.so*"]
8 changes: 7 additions & 1 deletion raylib/raylib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import importlib
import os

from ._backend import BACKEND_ARCHIVES, BACKEND_CFFI_MODULES, detect_backend, host_backends
from ._backend import BACKEND_ARCHIVES, BACKEND_CFFI_MODULES, HEADLESS, detect_backend, host_backends
from .version import __version__

DIR = os.path.join(os.path.dirname(__file__), "install")
Expand All @@ -25,6 +25,12 @@ def smoketest():
assert os.path.isfile(os.path.join(INCLUDE_DIR, header)), f"{header} not found"
for archive in _expected_archives():
assert os.path.isfile(os.path.join(LIB_DIR, archive)), f"{archive} not found"
if _BACKEND == HEADLESS:
rl.InitWindow(64, 64, b"")
rl.BeginDrawing()
rl.ClearBackground((0, 0, 0, 255))
rl.EndDrawing()
rl.CloseWindow()


def _load_cffi():
Expand Down
5 changes: 3 additions & 2 deletions raylib/raylib/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
BACKEND_LINK_ARGS = {
DESKTOP: ("-lGL", "-lX11"),
COMMA: ("-lGLESv2", "-lEGL", "-lgbm", "-ldrm"),
HEADLESS: ("-lGLESv2", "-lEGL"),
HEADLESS: ("-lGLESv2", "-lEGL", "-Wl,-rpath,$ORIGIN/install/lib"),
}

COMMA_DEVICE_MARKERS = ("/AGNOS", "/TICI")
Expand Down Expand Up @@ -50,5 +50,6 @@ def detect_backend(environ=None, exists=os.path.exists):

if any(exists(marker) for marker in COMMA_DEVICE_MARKERS):
return COMMA

if HEADLESS in host_backends() and not environ.get("DISPLAY"):
return HEADLESS
return DEFAULT_BACKEND
3 changes: 2 additions & 1 deletion test_wheels_in_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ docker run --rm -v "$PWD:/work" -w /work wheeltest bash -lc '
pip install dist/*.whl
for toml in */pyproject.toml; do
module="$(basename "$(dirname "$toml")" | tr "-" "_")"
python -c "import $module; $module.smoketest()" && echo "$module: OK"
python -c "import $module; $module.smoketest()" || exit 1
echo "$module: OK"
done
'

Expand Down
Loading