git: de388e576961 - main - graphics/py-glcontext: New port: Portable OpenGL context for Python

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Fri, 20 Jan 2023 19:49:20 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=de388e576961501429ee507ea3f5e8d4bd27e363

commit de388e576961501429ee507ea3f5e8d4bd27e363
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-01-20 16:09:03 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-01-20 19:49:17 +0000

    graphics/py-glcontext: New port: Portable OpenGL context for Python
---
 graphics/Makefile                                  |  1 +
 graphics/py-glcontext/Makefile                     | 31 ++++++++++++++++++++++
 graphics/py-glcontext/distinfo                     |  3 +++
 .../py-glcontext/files/patch-glcontext_egl.cpp     | 11 ++++++++
 graphics/py-glcontext/pkg-descr                    |  5 ++++
 5 files changed, 51 insertions(+)

diff --git a/graphics/Makefile b/graphics/Makefile
index bb42c7d2230f..d01e41b1d6c0 100644
--- a/graphics/Makefile
+++ b/graphics/Makefile
@@ -865,6 +865,7 @@
     SUBDIR += py-geopandas
     SUBDIR += py-giddy
     SUBDIR += py-gizeh
+    SUBDIR += py-glcontext
     SUBDIR += py-glfw
     SUBDIR += py-glooey
     SUBDIR += py-gphoto2
diff --git a/graphics/py-glcontext/Makefile b/graphics/py-glcontext/Makefile
new file mode 100644
index 000000000000..a208bdab9399
--- /dev/null
+++ b/graphics/py-glcontext/Makefile
@@ -0,0 +1,31 @@
+PORTNAME=	glcontext
+DISTVERSION=	2.3.7
+CATEGORIES=	graphics
+#MASTER_SITES=	PYPI # no tests
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Portable OpenGL context for Python
+WWW=		https://github.com/moderngl/glcontext
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR}
+
+USES=		localbase python xorg
+USE_PYTHON=	pep517 autoplist pytest
+USE_XORG=	x11
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	moderngl
+
+TEST_ENV=	${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+TEST_WRKSRC=	${WRKSRC}/tests
+
+post-install:
+	@${STRIP_CMD} \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/glcontext/x11${PYTHON_EXT_SUFFIX}.so \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/glcontext/egl${PYTHON_EXT_SUFFIX}.so
+
+.include <bsd.port.mk>
diff --git a/graphics/py-glcontext/distinfo b/graphics/py-glcontext/distinfo
new file mode 100644
index 000000000000..0f875aea5609
--- /dev/null
+++ b/graphics/py-glcontext/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1674242863
+SHA256 (moderngl-glcontext-2.3.7_GH0.tar.gz) = 91f649b1b7db6ebb66ca7c0ec5e032c9abd19975caeefb77c8fe063a401e7fe3
+SIZE (moderngl-glcontext-2.3.7_GH0.tar.gz) = 22254
diff --git a/graphics/py-glcontext/files/patch-glcontext_egl.cpp b/graphics/py-glcontext/files/patch-glcontext_egl.cpp
new file mode 100644
index 000000000000..634ebae65fa7
--- /dev/null
+++ b/graphics/py-glcontext/files/patch-glcontext_egl.cpp
@@ -0,0 +1,11 @@
+--- glcontext/egl.cpp.orig	2023-01-20 19:29:43 UTC
++++ glcontext/egl.cpp
+@@ -216,7 +216,7 @@ GLContext * meth_create_context(PyObject * self, PyObj
+             return NULL;
+         }
+ 
+-        EGLDeviceEXT* devices = malloc(sizeof(EGLDeviceEXT) * num_devices);
++        EGLDeviceEXT* devices = (EGLDeviceEXT*)malloc(sizeof(EGLDeviceEXT) * num_devices);
+         if (!res->m_eglQueryDevicesEXT(num_devices, devices, &num_devices)) {
+             PyErr_Format(PyExc_Exception, "eglQueryDevicesEXT failed (0x%x)", res->m_eglGetError());
+             free(devices);
diff --git a/graphics/py-glcontext/pkg-descr b/graphics/py-glcontext/pkg-descr
new file mode 100644
index 000000000000..814adbaff441
--- /dev/null
+++ b/graphics/py-glcontext/pkg-descr
@@ -0,0 +1,5 @@
+glcontext is a library providing OpenGL implementation for ModernGL on multiple
+platforms:
+* glcontext on github
+* glcontext on pypi
+* ModernGL