diff --git a/pkgs/development/python-modules/raylib-python-cffi/default.nix b/pkgs/development/python-modules/raylib-python-cffi/default.nix new file mode 100644 index 000000000000..f1d46c1822d1 --- /dev/null +++ b/pkgs/development/python-modules/raylib-python-cffi/default.nix @@ -0,0 +1,57 @@ +{ + buildPythonPackage, + fetchFromGitHub, + setuptools, + cffi, + pkg-config, + glfw, + libffi, + raylib, + physac, + raygui, + lib +}: + +buildPythonPackage rec { + pname = "raylib-python-cffi"; + version = "5.0.0.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "electronstudio"; + repo = "raylib-python-cffi"; + rev = "refs/tags/v${version}"; + hash = "sha256-DlnZRJZ0ZnkLii09grA/lGsJHPUYrbaJ55BVWJ8JzfM="; + }; + + build-system = [ setuptools ]; + dependencies = [ cffi ]; + + patches = [ + # This patch fixes to the builder script function to call pkg-config + # using the library name rather than searching only through raylib + ./fix_pyray_builder.patch + ]; + + nativeBuildInputs = [ pkg-config ]; + + # tests require a graphic environment + doCheck = false; + + pythonImportsCheck = [ "pyray" ]; + + buildInputs = [ + glfw + libffi + raylib + physac + raygui + ]; + + meta = { + description = "Python CFFI bindings for Raylib"; + homepage = "https://electronstudio.github.io/raylib-python-cffi"; + license = lib.licenses.epl20; + maintainers = with lib.maintainers; [ sigmanificient ]; + }; +} diff --git a/pkgs/development/python-modules/raylib-python-cffi/fix_pyray_builder.patch b/pkgs/development/python-modules/raylib-python-cffi/fix_pyray_builder.patch new file mode 100644 index 000000000000..0d167e2b0795 --- /dev/null +++ b/pkgs/development/python-modules/raylib-python-cffi/fix_pyray_builder.patch @@ -0,0 +1,61 @@ +--- a/raylib/build.py 2024-05-18 18:36:26.911488056 +0200 ++++ b/raylib/build.py 2024-05-18 18:40:04.770587090 +0200 +@@ -32,8 +32,8 @@ + return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0 + + +-def get_the_include_path(): +- return subprocess.run(['pkg-config', '--variable=includedir', 'raylib'], text=True, ++def get_the_include_path(libname): ++ return subprocess.run(['pkg-config', '--variable=includedir', libname], text=True, + stdout=subprocess.PIPE).stdout.strip() + + +@@ -106,9 +106,9 @@ + if not check_raylib_installed(): + raise Exception("ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib.") + +- raylib_h = get_the_include_path() + "/raylib.h" +- rlgl_h = get_the_include_path() + "/rlgl.h" +- raymath_h = get_the_include_path() + "/raymath.h" ++ raylib_h = get_the_include_path("raylib") + "/raylib.h" ++ rlgl_h = get_the_include_path("raylib") + "/rlgl.h" ++ raymath_h = get_the_include_path("raylib") + "/raymath.h" + + if not os.path.isfile(raylib_h): + raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib.") +@@ -125,13 +125,13 @@ + #include "raymath.h" + """ + +- glfw3_h = get_the_include_path() + "/GLFW/glfw3.h" ++ glfw3_h = get_the_include_path("glfw3") + "/GLFW/glfw3.h" + if check_header_exists(glfw3_h): + ffi_includes += """ + #include "GLFW/glfw3.h" + """ + +- raygui_h = get_the_include_path() + "/raygui.h" ++ raygui_h = get_the_include_path("raygui") + "/raygui.h" + if check_header_exists(raygui_h): + ffi_includes += """ + #define RAYGUI_IMPLEMENTATION +@@ -139,7 +139,7 @@ + #include "raygui.h" + """ + +- physac_h = get_the_include_path() + "/physac.h" ++ physac_h = get_the_include_path("physac") + "/physac.h" + if check_header_exists(physac_h): + ffi_includes += """ + #define PHYSAC_IMPLEMENTATION +@@ -172,7 +172,7 @@ + + ffibuilder.set_source("raylib._raylib_cffi", + ffi_includes, +- include_dirs=[get_the_include_path()], ++ include_dirs=[get_the_include_path("libffi")], + extra_link_args=extra_link_args, + extra_compile_args=extra_compile_args, + libraries=libraries) + diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index d5683ca178c1..68976eb48ed1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -13036,6 +13036,8 @@ self: super: with self; { ray = callPackage ../development/python-modules/ray { }; + raylib-python-cffi = callPackage ../development/python-modules/raylib-python-cffi {}; + razdel = callPackage ../development/python-modules/razdel { }; rbtools = callPackage ../development/python-modules/rbtools { };