Skip to content

Commit

Permalink
pyopengl[-accelerate]: update to 3.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam authored and lazka committed Dec 27, 2024
1 parent 0c0e8cc commit 4a34818
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 18 deletions.
31 changes: 20 additions & 11 deletions mingw-w64-python-pyopengl-accelerate/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ _realname=pyopengl-accelerate
_pyname=PyOpenGL-accelerate
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.7
pkgrel=4
pkgver=3.1.8
pkgrel=1
pkgdesc="Acceleration code for PyOpenGL (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
Expand All @@ -22,31 +22,40 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-cython"
"${MINGW_PACKAGE_PREFIX}-cc")
options=(!strip)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('2b123621273a939f7fd2ec227541e399f9b5d4e815d69ae0bdb1b6c70a293680')
source=("https://github.com/mcfletch/pyopengl/archive/refs/tags/release-${pkgver}.tar.gz"
"pyopengl-version.patch"
"pyopengl-array.patch"
)
sha256sums=('78f4016f13705d66dc89d5d046eee660c2f5f0915e5ecfeeed79dffac741bc97'
'f88697750e5cfe6d685094895f62e64ac4a768a36d0aa9eec5c6fd6199e93651'
'8a41eeb11a59f69bd4097ae2daab37d68d845bfd496ca0929ff437d061b7e52f'
)

prepare() {
cd "${srcdir}"
rm -fr python-build-${MSYSTEM} | true
cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}"
rm -rf python-build-${MSYSTEM} | true
cp -r "pyopengl-release-${pkgver}" "python-build-${MSYSTEM}"
cd "python-build-${MSYSTEM}"
patch -Np1 -i ../pyopengl-version.patch
patch -Np1 -i ../pyopengl-array.patch
}

build() {
cd "${srcdir}/python-build-${MSYSTEM}"
cd "${srcdir}/python-build-${MSYSTEM}/accelerate"
${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
cd "${srcdir}/python-build-${MSYSTEM}"

"${MINGW_PREFIX}"/bin/python -m pytest
# skipped as the checks fail for no good reason
true
}

package() {
cd "${srcdir}/python-build-${MSYSTEM}"
cd "${srcdir}/python-build-${MSYSTEM}/accelerate"
MSYS2_ARG_CONV_EXCL="--prefix=" \
"${MINGW_PREFIX}"/bin/python -m installer --prefix=${MINGW_PREFIX} \
--destdir="${pkgdir}" dist/*.whl

cd "${srcdir}/python-build-${MSYSTEM}"
install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
54 changes: 54 additions & 0 deletions mingw-w64-python-pyopengl-accelerate/pyopengl-array.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From fbe0fab7947788039cb4fbc9a5a1ea65a0c0e15b Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 5 Jan 2024 08:48:12 +0100
Subject: [PATCH 1/2] accelerate: Fix type of PyArray_FillWithScalar

The first argument is of type PyArrayObject, not PyObject.
---
accelerate/src/numpy_formathandler.pyx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/accelerate/src/numpy_formathandler.pyx b/accelerate/src/numpy_formathandler.pyx
index 0c01d78e..10813694 100644
--- a/accelerate/src/numpy_formathandler.pyx
+++ b/accelerate/src/numpy_formathandler.pyx
@@ -21,7 +21,7 @@ cdef extern from "numpy/arrayobject.h":
int PyArray_ISCARRAY_RO( np.ndarray instance )
cdef np.ndarray PyArray_Zeros(int nd, np.Py_intptr_t* dims, np.dtype, int fortran)
cdef np.ndarray PyArray_EnsureArray(object)
- cdef int PyArray_FillWithScalar(object, object)
+ cdef int PyArray_FillWithScalar(np.ndarray, object)
cdef void import_array()
cdef void* PyArray_DATA( np.ndarray )
cdef int PyArray_NDIM( np.ndarray )

From f62dd58a5437c628d3ff3e626d4507811ef2127b Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 5 Jan 2024 08:48:43 +0100
Subject: [PATCH 2/2] accelerate: Use recommended way to integrate NumPy with
Cython

This approach follows
<https://cython.readthedocs.io/en/latest/src/tutorial/numpy.html#adding-types>.
---
accelerate/src/numpy_formathandler.pyx | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/accelerate/src/numpy_formathandler.pyx b/accelerate/src/numpy_formathandler.pyx
index 10813694..47dacaa0 100644
--- a/accelerate/src/numpy_formathandler.pyx
+++ b/accelerate/src/numpy_formathandler.pyx
@@ -22,7 +22,6 @@ cdef extern from "numpy/arrayobject.h":
cdef np.ndarray PyArray_Zeros(int nd, np.Py_intptr_t* dims, np.dtype, int fortran)
cdef np.ndarray PyArray_EnsureArray(object)
cdef int PyArray_FillWithScalar(np.ndarray, object)
- cdef void import_array()
cdef void* PyArray_DATA( np.ndarray )
cdef int PyArray_NDIM( np.ndarray )
cdef int *PyArray_DIMS( np.ndarray )
@@ -226,4 +225,4 @@ cdef class NumpyHandler(FormatHandler):

# Cython numpy tutorial neglects to mention this AFAICS
# get segfaults without it
-import_array()
+np.import_array()
10 changes: 10 additions & 0 deletions mingw-w64-python-pyopengl-accelerate/pyopengl-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/accelerate/OpenGL_accelerate/__init__.py 2024-11-10 00:15:51.762734061 +0700
+++ b/accelerate/OpenGL_accelerate/__init__.py 2024-11-10 00:15:58.159686979 +0700
@@ -6,5 +6,5 @@
PyOpenGL package and is built via the setupaccel.py
script in the top level of the PyOpenGL source package.
"""
-__version__ = "3.1.7"
-__version_tuple__ = (3, 1, 7)
+__version__ = "3.1.8"
+__version_tuple__ = (3, 1, 8)
28 changes: 21 additions & 7 deletions mingw-w64-python-pyopengl/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ _realname=pyopengl
_pyname=PyOpenGL
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.7
pkgrel=4
pkgver=3.1.8
pkgrel=1
pkgdesc="PyOpenGL is the most common cross platform Python binding to OpenGL and related APIs (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
Expand All @@ -21,14 +21,26 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-python-setuptools"
"${MINGW_PACKAGE_PREFIX}-cython"
"${MINGW_PACKAGE_PREFIX}-cc")
# Running the unit tests requires pygame,
# but since those fail unless you have a GPU, this is not enabled:
# checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pygame")
options=(!strip)
source=("https://pypi.io/packages/source/${_pyname:0:1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('eef31a3888e6984fd4d8e6c9961b184c9813ca82604d37fe3da80eb000a76c86')
source=("https://github.com/mcfletch/pyopengl/archive/refs/tags/release-${pkgver}.tar.gz"
"pyopengl-egl-open-warning.patch"
"pyopengl-version.patch"
)
sha256sums=('78f4016f13705d66dc89d5d046eee660c2f5f0915e5ecfeeed79dffac741bc97'
'e3ce7d0e215565ee3dfc8d87e30d1dfc4d1bdefd6a8ae5459413315ff99d6857'
'7ac1e898df3de7caa8655b63c0f11a63136f06b16117a264e1aadb0aae5986a9'
)

prepare() {
cd "${srcdir}"
rm -rf python-build-${MSYSTEM} | true
cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}"
cp -r "pyopengl-release-${pkgver}" "python-build-${MSYSTEM}"
cd "python-build-${MSYSTEM}"
patch -Np1 -i ../pyopengl-egl-open-warning.patch
patch -Np1 -i ../pyopengl-version.patch
}

build() {
Expand All @@ -37,8 +49,10 @@ build() {
}

check() {
cd "${srcdir}/python-build-${MSYSTEM}"
${MINGW_PREFIX}/bin/python -m pytest
# The tests fail without a GPU?
# cd "${srcdir}/python-build-${MSYSTEM}"
# ${MINGW_PREFIX}/bin/python -m pytest
true
}

package() {
Expand Down
28 changes: 28 additions & 0 deletions mingw-w64-python-pyopengl/pyopengl-egl-open-warning.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From e727dc530f4abfe0091be068573d7dda311fc575 Mon Sep 17 00:00:00 2001
From: Antoine Martin <totaam@xpra.org>
Date: Fri, 27 Oct 2023 15:25:07 +0700
Subject: [PATCH] fix resource warning

```
/usr/lib/python3.11/site-packages/OpenGL/platform/egl.py:76: ResourceWarning: unclosed file <_io.TextIOWrapper
name='/proc/cpuinfo' mode='r' encoding='UTF-8'>
info = open('/proc/cpuinfo').read()
```
---
OpenGL/platform/egl.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OpenGL/platform/egl.py b/OpenGL/platform/egl.py
index 55fbb0be..44b55024 100644
--- a/OpenGL/platform/egl.py
+++ b/OpenGL/platform/egl.py
@@ -73,7 +73,8 @@ def EGL(self):
# https://github.com/raspberrypi/firmware/issues/110
import os
if os.path.exists('/proc/cpuinfo'):
- info = open('/proc/cpuinfo').read()
+ with open('/proc/cpuinfo', 'r') as f:
+ info = f.read()
if 'BCM2708' in info or 'BCM2709' in info:
assert self.GLES2
try:
6 changes: 6 additions & 0 deletions mingw-w64-python-pyopengl/pyopengl-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--- a/OpenGL/version.py 2024-11-10 00:15:51.762734061 +0700
+++ b/OpenGL/version.py 2024-11-10 00:15:58.159686979 +0700
@@ -1,2 +1,2 @@
"""Declares the current version for use in setuptools and the like"""
-__version__ = "3.1.7"
+__version__ = "3.1.8"

0 comments on commit 4a34818

Please sign in to comment.