Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ python3 build_versions.py apply "$POST_N" */pyproject.toml
uv build --all-packages --wheel --out-dir dist --no-create-gitignore
restore_build_versions

if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
mkdir -p dist/unrepaired/
mv dist/comma_deps_raylib-*.whl dist/unrepaired/
auditwheel repair \
--ldpaths "$ROOT_DIR/raylib/raylib/install/lib:/usr/lib64:/lib64" \
--wheel-dir dist/ dist/unrepaired/comma_deps_raylib-*.whl
fi

if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
VENV_DIR="$ROOT_DIR/.venv-manylinux"
else
Expand Down
32 changes: 29 additions & 3 deletions raylib/build_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import platform
import re
import shutil
import subprocess
import sys

Expand All @@ -15,7 +16,7 @@
RAYLIB_LIB_PATH = os.path.join(PACKAGE_DIR, "install", "lib")

sys.path.insert(0, PACKAGE_DIR)
from _backend import BACKEND_ARCHIVES, BACKEND_CFFI_MODULES, BACKEND_LINK_ARGS, detect_backend # noqa: E402
from _backend import BACKEND_ARCHIVES, BACKEND_CFFI_MODULES, BACKEND_LINK_ARGS, DESKTOP, detect_backend # noqa: E402
from validate_bindings import validate_static_bindings # noqa: E402

RAYLIB_BACKEND = detect_backend()
Expand All @@ -31,6 +32,26 @@ def _raylib_archive():
return archive


def _private_desktop_libs():
private_libs = {}
for soname in ("libGL.so.1", "libGLX.so.0", "libX11.so.6", "libXext.so.6"):
source = subprocess.check_output(["gcc", f"-print-file-name={soname}"], text=True).strip()
if source == soname or not os.path.isfile(source):
raise FileNotFoundError(f"{soname} not found")

private_soname = soname.replace(".so", "-comma.so", 1)
target = os.path.join(RAYLIB_LIB_PATH, private_soname)
shutil.copy2(source, target)
subprocess.check_call(["patchelf", "--set-soname", private_soname, target])
private_libs[soname] = target

for target in private_libs.values():
for soname, dependency in private_libs.items():
subprocess.check_call(["patchelf", "--replace-needed", soname, os.path.basename(dependency), target])

return private_libs["libGL.so.1"], private_libs["libX11.so.6"]


def pre_process_header(filename, remove_function_bodies=False):
print("Pre-processing " + filename)
with open(filename, "r") as f:
Expand Down Expand Up @@ -87,10 +108,15 @@ def build_ffi():
extra_compile_args = ["-Wno-error=incompatible-function-pointer-types"]
else:
print("BUILDING FOR LINUX")
backend_link_args = BACKEND_LINK_ARGS[RAYLIB_BACKEND]
if RAYLIB_BACKEND == DESKTOP and os.environ.get("AUDITWHEEL_PLAT"):
backend_link_args = _private_desktop_libs()

extra_link_args = [
raylib_archive,
'-lm', '-lpthread', '-lrt', '-ldl', '-latomic',
*BACKEND_LINK_ARGS[RAYLIB_BACKEND],
'-lm', '-lpthread', '-lrt', '-ldl',
'-Wl,-Bstatic', '-latomic', '-Wl,-Bdynamic',
*backend_link_args,
]
extra_compile_args = ["-Wno-incompatible-pointer-types"]

Expand Down
12 changes: 10 additions & 2 deletions raylib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import sys

from setuptools import setup
from setuptools import Distribution, setup
from setuptools.command.build_py import build_py
from setuptools.command.bdist_wheel import bdist_wheel

Expand Down Expand Up @@ -61,4 +61,12 @@ def get_tag(self):
return "py3", "none", plat_tag


setup(cmdclass={"build_py": BuildRaylib, "bdist_wheel": PlatformWheel})
class BinaryDistribution(Distribution):
def has_ext_modules(self):
return True


setup(
cmdclass={"build_py": BuildRaylib, "bdist_wheel": PlatformWheel},
distclass=BinaryDistribution,
)
1 change: 1 addition & 0 deletions test_wheels_in_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ docker run --rm -v "$PWD:/work" -w /work wheeltest bash -lc '
module="$(basename "$(dirname "$toml")" | tr "-" "_")"
python -c "import $module; $module.smoketest()" && echo "$module: OK"
done
RAYLIB_BACKEND=headless python -c "import raylib; raylib.smoketest()"
'

echo
Expand Down
Loading