diff mbox series

[bug#50505,03/12] gnu: Add python-glcontext.

Message ID 20210910112502.6466-3-daniel.meissner-i4k@ruhr-uni-bochum.de
State New
Headers show
Series gnu: Add python-manim | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Daniel Meißner Sept. 10, 2021, 11:24 a.m. UTC
* gnu/packages/python-xyz.scm (python-glcontext): New variable.
---
 gnu/packages/python-xyz.scm | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Xinglu Chen Sept. 11, 2021, 7:42 p.m. UTC | #1
On Fri, Sep 10 2021, Daniel Meißner via Guix-patches via wrote:

> * gnu/packages/python-xyz.scm (python-glcontext): New variable.
> ---
>  gnu/packages/python-xyz.scm | 46 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
> index 75646aec7f..251aad5b61 100644
> --- a/gnu/packages/python-xyz.scm
> +++ b/gnu/packages/python-xyz.scm
> @@ -18884,6 +18884,52 @@ library.")
>      (description
>       "This is the Cython-coded accelerator module for PyOpenGL.")))
>  
> +(define-public python-glcontext
> +  (package
> +   (name "python-glcontext")
> +   (version "2.3.4")
> +   (source
> +    (origin
> +     (method git-fetch)
> +     (uri (git-reference
> +           (url "https://github.com/moderngl/glcontext")
> +           (commit version)))
> +     (file-name (git-file-name name version))
> +     (sha256
> +      (base32
> +       "1m2zkl696vqmgrd5k1c5kl0krk6qgjgsz88qhahwva0l40bswvhp"))))
> +   (build-system python-build-system)
> +   (arguments
> +    '(#:phases
> +      (modify-phases %standard-phases
> +        (add-before 'build 'fix-lib-paths
> +          (lambda* (#:key inputs outputs #:allow-other-keys)
> +            (substitute* '("glcontext/x11.cpp" "glcontext/egl.cpp")
> +              (("\"libGL.so\"")
> +               (string-append "\"" (assoc-ref inputs "mesa") "/lib/libGL.so\""))
> +              (("\"libEGL.so\"")
> +               (string-append "\"" (assoc-ref inputs "mesa") "/lib/libEGL.so\""))
> +              (("\"libX11.so\"")
> +               (string-append "\"" (assoc-ref inputs "libx11") "/lib/libX11.so\"")))

Please keep lines =<80 columns wide.  Also I would use a ‘let’ form to
avoid writing (assoc-ref inputs "mesa") twice.

> +            (substitute* '("glcontext/__init__.py")
> +              (("find_library\\('GL'\\)")
> +               (string-append "'" (assoc-ref inputs "mesa") "/lib/libGL.so'"))
> +              (("find_library\\('EGL'\\)")
> +               (string-append "'" (assoc-ref inputs "mesa") "/lib/libEGL.so'"))

Likewise (‘let’ form).

> +              (("find_library\\(\"X11\"\\)")
> +               (string-append "'" (assoc-ref inputs "libx11") "/lib/libX11.so'")))
> +            #t))

Phases don’t need to return #t once the ‘core-updates-frozen’ branch
gets merged, which should happen soon™.  :-)

> +        ;; tests fail with: Exception: (standalone) XOpenDisplay: cannot open display
> +        (delete 'check))))
> +   (inputs
> +    `(("libx11" ,libx11)
> +      ("mesa" ,mesa)))
> +   (home-page "https://github.com/moderngl/glcontext")
> +   (synopsis "Portable OpenGL Context for ModernGL")
> +   (description "Python-glcontext is a library providing OpenGL implementation
> +for ModernGL on multiple platforms.")

“providing an OpenGL implementation” (missing article).
diff mbox series

Patch

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 75646aec7f..251aad5b61 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -18884,6 +18884,52 @@  library.")
     (description
      "This is the Cython-coded accelerator module for PyOpenGL.")))
 
+(define-public python-glcontext
+  (package
+   (name "python-glcontext")
+   (version "2.3.4")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://github.com/moderngl/glcontext")
+           (commit version)))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1m2zkl696vqmgrd5k1c5kl0krk6qgjgsz88qhahwva0l40bswvhp"))))
+   (build-system python-build-system)
+   (arguments
+    '(#:phases
+      (modify-phases %standard-phases
+        (add-before 'build 'fix-lib-paths
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (substitute* '("glcontext/x11.cpp" "glcontext/egl.cpp")
+              (("\"libGL.so\"")
+               (string-append "\"" (assoc-ref inputs "mesa") "/lib/libGL.so\""))
+              (("\"libEGL.so\"")
+               (string-append "\"" (assoc-ref inputs "mesa") "/lib/libEGL.so\""))
+              (("\"libX11.so\"")
+               (string-append "\"" (assoc-ref inputs "libx11") "/lib/libX11.so\"")))
+            (substitute* '("glcontext/__init__.py")
+              (("find_library\\('GL'\\)")
+               (string-append "'" (assoc-ref inputs "mesa") "/lib/libGL.so'"))
+              (("find_library\\('EGL'\\)")
+               (string-append "'" (assoc-ref inputs "mesa") "/lib/libEGL.so'"))
+              (("find_library\\(\"X11\"\\)")
+               (string-append "'" (assoc-ref inputs "libx11") "/lib/libX11.so'")))
+            #t))
+        ;; tests fail with: Exception: (standalone) XOpenDisplay: cannot open display
+        (delete 'check))))
+   (inputs
+    `(("libx11" ,libx11)
+      ("mesa" ,mesa)))
+   (home-page "https://github.com/moderngl/glcontext")
+   (synopsis "Portable OpenGL Context for ModernGL")
+   (description "Python-glcontext is a library providing OpenGL implementation
+for ModernGL on multiple platforms.")
+   (license license:expat)))
+
 (define-public python-rencode
   (package
    (name "python-rencode")