mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-01-19 00:09:37 +03:00
dev-python/pyopengl-accelerate: add 3.1.8-r1, 9999, update for numpy-2.0
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/37232 Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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.
|
||||
--- a/accelerate/src/numpy_formathandler.pyx
|
||||
+++ b/accelerate/src/numpy_formathandler.pyx
|
||||
@@ -22,7 +22,7 @@ cdef extern from "numpy/arrayobject.h":
|
||||
int PyArray_ISCARRAY_RO( np.ndarray instance )
|
||||
cdef np.ndarray PyArray_Zeros(int nd, np.npy_intp* 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>.
|
||||
--- a/accelerate/src/numpy_formathandler.pyx
|
||||
+++ b/accelerate/src/numpy_formathandler.pyx
|
||||
@@ -23,7 +23,6 @@ cdef extern from "numpy/arrayobject.h":
|
||||
cdef np.ndarray PyArray_Zeros(int nd, np.npy_intp* 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 )
|
||||
@@ -227,4 +226,4 @@ cdef class NumpyHandler(FormatHandler):
|
||||
|
||||
# Cython numpy tutorial neglects to mention this AFAICS
|
||||
# get segfaults without it
|
||||
-import_array()
|
||||
+np.import_array()
|
||||
@@ -0,0 +1,171 @@
|
||||
From 20213b913f4a396752c515cafd7ee2ea53ab1fcf Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 17:03:20 +0200
|
||||
Subject: [PATCH 1/2] add requirements
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/requirements.txt
|
||||
+++ b/requirements.txt
|
||||
@@ -0,0 +1,4 @@
|
||||
+numpy>=2.0.0
|
||||
+pytest>=8.2.2
|
||||
+setuptools>=70.0.0
|
||||
+Cython>=3.0.10
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From bfb5c7005917fc5b4cb71e17b2ed8cc015828f1b Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 21:40:28 +0200
|
||||
Subject: [PATCH 1/5] numpy-2.0 define_macros
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -45,7 +45,7 @@ def cython_extension(
|
||||
# *cython* itself is using the deprecated api, and the
|
||||
# deprecated APIs are actually providing the attributes
|
||||
# that we use throughout our code...
|
||||
- # ('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION'),
|
||||
+ ('NPY_NO_DEPRECATED_API', 'NPY_2_0_API_VERSION'),
|
||||
],
|
||||
compiler_directives={'language_level': "3"} if have_cython else {},
|
||||
)
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From b352289a51b2629917b59ee2b35569651436af70 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 21:42:33 +0200
|
||||
Subject: [PATCH 2/5] python-3.11-PyMemoryView_GetContiguous
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/src/buffers_formathandler.pyx
|
||||
+++ b/src/buffers_formathandler.pyx
|
||||
@@ -73,8 +73,8 @@ cdef class MemoryviewHandler(FormatHandler):
|
||||
# TODO: respect no-copy flag!
|
||||
instance = PyMemoryView_GetContiguous(
|
||||
instance,
|
||||
- PyBUF_STRIDES|PyBUF_FORMAT|PyBUF_C_CONTIGUOUS,
|
||||
'C'
|
||||
+ PyBUF_WRITE,
|
||||
)
|
||||
return instance
|
||||
cdef c_from_param( self, object instance, object typeCode ):
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From 86268a423c994f0808bd745ac4b0dfe69c8682ad Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 21:43:32 +0200
|
||||
Subject: [PATCH 3/5] enable conversion to C char
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/src/buffers_formathandler.pyx
|
||||
+++ b/src/buffers_formathandler.pyx
|
||||
@@ -73,8 +73,8 @@ cdef class MemoryviewHandler(FormatHandler):
|
||||
# TODO: respect no-copy flag!
|
||||
instance = PyMemoryView_GetContiguous(
|
||||
instance,
|
||||
- 'C'
|
||||
PyBUF_WRITE,
|
||||
+ b'C'
|
||||
)
|
||||
return instance
|
||||
cdef c_from_param( self, object instance, object typeCode ):
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From 8d8618cd4d318ace3ecabe823da0dcfdae2fb0e5 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 21:44:53 +0200
|
||||
Subject: [PATCH 4/5] set language_level
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -47,7 +47,6 @@ def cython_extension(
|
||||
# that we use throughout our code...
|
||||
('NPY_NO_DEPRECATED_API', 'NPY_2_0_API_VERSION'),
|
||||
],
|
||||
- compiler_directives={'language_level': "3"} if have_cython else {},
|
||||
)
|
||||
|
||||
|
||||
@@ -116,6 +115,8 @@ if ( # Prevents running of setup during code introspection imports
|
||||
extraArguments["cmdclass"] = {
|
||||
"build_ext": build_ext,
|
||||
}
|
||||
+ for e in extensions:
|
||||
+ e.cython_directives = {'language_level': "3"}
|
||||
setup(
|
||||
options={
|
||||
"sdist": {
|
||||
--- a/src/numpy_formathandler.pyx
|
||||
+++ b/src/numpy_formathandler.pyx
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Accelerator for numpy format handler operations"""
|
||||
-#cython: language_level=3
|
||||
+# cython: language_level=3
|
||||
from ctypes import c_void_p
|
||||
import numpy as np
|
||||
cimport numpy as np
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From 6cd6e7c053e3268086e90df6d1297941cbce93f2 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
Date: Thu, 20 Jun 2024 21:46:46 +0200
|
||||
Subject: [PATCH 5/5] drop old cython numpy definitions
|
||||
|
||||
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
|
||||
--- a/src/numpy_formathandler.pyx
|
||||
+++ b/src/numpy_formathandler.pyx
|
||||
@@ -3,36 +3,18 @@
|
||||
from ctypes import c_void_p
|
||||
import numpy as np
|
||||
cimport numpy as np
|
||||
+from numpy cimport *
|
||||
from OpenGL_accelerate.formathandler cimport FormatHandler
|
||||
-import traceback, weakref
|
||||
from OpenGL.error import CopyError
|
||||
from OpenGL._bytes import bytes,unicode
|
||||
|
||||
-cdef extern from "Python.h":
|
||||
- cdef void Py_INCREF( object )
|
||||
-
|
||||
cdef extern from "numpy/arrayobject.h":
|
||||
cdef np.ndarray PyArray_FromArray( np.ndarray, np.dtype, int )
|
||||
- cdef np.ndarray PyArray_ContiguousFromAny( object op, int, int, int max_depth)
|
||||
- cdef int PyArray_Check( object )
|
||||
- cdef int PyArray_CheckScalar( object )
|
||||
- int NPY_ARRAY_CARRAY
|
||||
- int NPY_ARRAY_FORCECAST
|
||||
- int PyArray_ISCARRAY( np.ndarray instance )
|
||||
- int PyArray_ISCARRAY_RO( np.ndarray instance )
|
||||
cdef np.ndarray PyArray_Zeros(int nd, np.npy_intp* dims, np.dtype, int fortran)
|
||||
- cdef np.ndarray PyArray_EnsureArray(object)
|
||||
- cdef int PyArray_FillWithScalar(np.ndarray, object)
|
||||
- cdef void* PyArray_DATA( np.ndarray )
|
||||
- cdef int PyArray_NDIM( np.ndarray )
|
||||
- cdef int *PyArray_DIMS( np.ndarray )
|
||||
- cdef int PyArray_DIM( np.ndarray, int dim )
|
||||
- cdef np.dtype PyArray_DESCR( np.ndarray )
|
||||
- cdef np.npy_intp PyArray_SIZE( np.ndarray )
|
||||
|
||||
cdef np.dtype array_descr( np.ndarray array ):
|
||||
"""Wrap PyArray_DESCR and incref to deal with the "borrowed" reference"""
|
||||
- cdef np.dtype desc = PyArray_DESCR( array )
|
||||
+ cdef np.dtype desc = array.dtype
|
||||
Py_INCREF(<object> desc)
|
||||
return desc
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# Copyright 1999-2024 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
DISTUTILS_EXT=1
|
||||
DISTUTILS_USE_PEP517=setuptools
|
||||
PYTHON_COMPAT=( python3_{10..13} )
|
||||
|
||||
inherit distutils-r1
|
||||
|
||||
DESCRIPTION="Accelerate module for PyOpenGL"
|
||||
HOMEPAGE="
|
||||
https://pyopengl.sourceforge.net/
|
||||
https://github.com/mcfletch/pyopengl/
|
||||
https://pypi.org/project/PyOpenGL-accelerate/
|
||||
"
|
||||
|
||||
if [[ ${PV} = *9999* ]] ; then
|
||||
inherit git-r3
|
||||
EGIT_REPO_URI="https://github.com/mcfletch/pyopengl.git"
|
||||
S="${S}/accelerate"
|
||||
else
|
||||
MY_P=pyopengl-release-${PV}
|
||||
SRC_URI="
|
||||
https://github.com/mcfletch/pyopengl/archive/release-${PV}.tar.gz
|
||||
-> ${MY_P}.gh.tar.gz
|
||||
"
|
||||
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
|
||||
S=${WORKDIR}/${MY_P}/accelerate
|
||||
fi
|
||||
|
||||
LICENSE="BSD"
|
||||
SLOT="0"
|
||||
IUSE="numpy"
|
||||
|
||||
DEPEND="
|
||||
numpy? (
|
||||
dev-python/numpy:=[${PYTHON_USEDEP}]
|
||||
)
|
||||
"
|
||||
RDEPEND="
|
||||
${DEPEND}
|
||||
dev-python/pyopengl[${PYTHON_USEDEP}]
|
||||
"
|
||||
BDEPEND="
|
||||
dev-python/cython[${PYTHON_USEDEP}]
|
||||
"
|
||||
|
||||
distutils_enable_tests pytest
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
|
||||
touch requirements.txt || die
|
||||
|
||||
eapply -p2 "${FILESDIR}/${PN}-3.1.8-gcc-14.patch"
|
||||
|
||||
eapply -p1 "${FILESDIR}/${PN}-3.1.8-numpy-2.0.patch"
|
||||
}
|
||||
|
||||
src_configure() {
|
||||
rm src/*.c || die
|
||||
|
||||
if ! use numpy; then
|
||||
cat > "${T}"/numpy.py <<-EOF || die
|
||||
raise ImportError("building numpy extension disabled")
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
python_compile() {
|
||||
local -x PYTHONPATH=${T}:${PYTHONPATH}
|
||||
distutils-r1_python_compile
|
||||
}
|
||||
|
||||
python_test() {
|
||||
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
|
||||
cd "${T}" || die
|
||||
epytest "${S}"/tests
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
# Copyright 1999-2024 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
DISTUTILS_EXT=1
|
||||
DISTUTILS_USE_PEP517=setuptools
|
||||
PYTHON_COMPAT=( python3_{10..13} )
|
||||
|
||||
inherit distutils-r1
|
||||
|
||||
DESCRIPTION="Accelerate module for PyOpenGL"
|
||||
HOMEPAGE="
|
||||
https://pyopengl.sourceforge.net/
|
||||
https://github.com/mcfletch/pyopengl/
|
||||
https://pypi.org/project/PyOpenGL-accelerate/
|
||||
"
|
||||
|
||||
if [[ ${PV} = *9999* ]] ; then
|
||||
inherit git-r3
|
||||
EGIT_REPO_URI="https://github.com/mcfletch/pyopengl.git"
|
||||
S="${S}/accelerate"
|
||||
else
|
||||
MY_P=pyopengl-release-${PV}
|
||||
SRC_URI="
|
||||
https://github.com/mcfletch/pyopengl/archive/release-${PV}.tar.gz
|
||||
-> ${MY_P}.gh.tar.gz
|
||||
"
|
||||
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
|
||||
S=${WORKDIR}/${MY_P}/accelerate
|
||||
fi
|
||||
|
||||
LICENSE="BSD"
|
||||
SLOT="0"
|
||||
IUSE="numpy"
|
||||
|
||||
DEPEND="
|
||||
numpy? (
|
||||
dev-python/numpy:=[${PYTHON_USEDEP}]
|
||||
)
|
||||
"
|
||||
RDEPEND="
|
||||
${DEPEND}
|
||||
dev-python/pyopengl[${PYTHON_USEDEP}]
|
||||
"
|
||||
BDEPEND="
|
||||
dev-python/cython[${PYTHON_USEDEP}]
|
||||
"
|
||||
|
||||
distutils_enable_tests pytest
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
|
||||
touch requirements.txt || die
|
||||
|
||||
eapply -p2 "${FILESDIR}/${PN}-3.1.8-gcc-14.patch"
|
||||
|
||||
eapply -p1 "${FILESDIR}/${PN}-3.1.8-numpy-2.0.patch"
|
||||
}
|
||||
|
||||
src_configure() {
|
||||
rm src/*.c || die
|
||||
|
||||
if ! use numpy; then
|
||||
cat > "${T}"/numpy.py <<-EOF || die
|
||||
raise ImportError("building numpy extension disabled")
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
python_compile() {
|
||||
local -x PYTHONPATH=${T}:${PYTHONPATH}
|
||||
distutils-r1_python_compile
|
||||
}
|
||||
|
||||
python_test() {
|
||||
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
|
||||
cd "${T}" || die
|
||||
epytest "${S}"/tests
|
||||
}
|
||||
Reference in New Issue
Block a user