Unverified Commit 3f6cf163 authored by OTABI Tomoya's avatar OTABI Tomoya Committed by GitHub
Browse files

Merge pull request #313278 from Sigmanificient/pyray

raylib-python-cffi: init at 5.0.0.2, physac: init at 2.5-unstable-2024-05-21, raygui: init at 4.0-unstable-2024-05-21
parents 0989d93c 7d0aaba0
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
{
  stdenvNoCC,
  fetchFromGitHub,
  lib
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  name = "physac";
  version = "2.5-unstable-2023-12-11";

  src = fetchFromGitHub {
    owner = "victorfisac";
    repo = "Physac";
    rev = "29d9fc06860b54571a02402fff6fa8572d19bd12";
    hash = "sha256-PTlV1tT0axQbmGmJ7JD1n6wmbIxUdu7xho78EO0HNNk=";
  };

  dontBuild = true;
  installPhase = ''
    runHook preInstall

    mkdir -p $out/{include,lib/pkgconfig}

    install -Dm644 $src/src/physac.h $out/include/physac.h

    cat <<EOF > $out/lib/pkgconfig/physac.pc
    prefix=$out
    includedir=$out/include

    Name: physac
    Description: ${finalAttrs.meta.description}
    URL: ${finalAttrs.meta.homepage}
    Version: ${finalAttrs.version}
    Cflags: -I"{includedir}"
    EOF

    runHook postInstall
  '';

  meta = {
    description = "2D physics header-only library for raylib";
    homepage = "https://github.com/victorfisac/Physac";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ sigmanificient ];
    platforms = lib.platforms.unix;
  };
})
+47 −0
Original line number Diff line number Diff line
{
  stdenvNoCC,
  fetchFromGitHub,
  lib
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  name = "raygui";
  version = "4.0";

  src = fetchFromGitHub {
    owner = "raysan5";
    repo = "raygui";
    rev = "refs/tags/${finalAttrs.version}";
    hash = "sha256-1qnChZYsb0e5LnPhvs6a/R5Ammgj2HWFNe9625sBRo8=";
  };

  dontBuild = true;
  installPhase = ''
    runHook preInstall

    mkdir -p $out/{include,lib/pkgconfig}

    install -Dm644 $src/src/raygui.h $out/include/raygui.h

    cat <<EOF > $out/lib/pkgconfig/raygui.pc
    prefix=$out
    includedir=$out/include

    Name: raygui
    Description: ${finalAttrs.meta.description}
    URL: ${finalAttrs.meta.homepage}
    Version: ${finalAttrs.version}
    Cflags: -I"{includedir}"
    EOF

    runHook postInstall
  '';

  meta = {
    description = "A simple and easy-to-use immediate-mode gui library";
    homepage = "https://github.com/raysan5/raygui";
    license = lib.licenses.zlib;
    maintainers = with lib.maintainers; [ sigmanificient ];
    platforms = lib.platforms.unix;
  };
})
+57 −0
Original line number Diff line number Diff line
{
  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 ];
  };
}
+61 −0
Original line number Diff line number Diff line
--- 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)
+2 −0
Original line number Diff line number Diff line
@@ -13032,6 +13032,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 { };