Skip to content

Commit 6b1ef8c

Browse files
committed
build: Use a patched PyOpenGL_accelerate on Mac Intel/Linux ARM
Due to mcfletch/pyopengl#147 we have to build accelerate using the patch in mcfletch/pyopengl#155 in order for it to work on mac Intel or linux ARM with Cython >=3.1, which dropped support for Python 2.
1 parent 7c02e56 commit 6b1ef8c

File tree

4 files changed

+115
-3
lines changed

4 files changed

+115
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ prereqs/pips/grako*.whl
6767
prereqs/pips/tinyarray*.whl
6868
prereqs/pips/Cython*.whl
6969
prereqs/pips/PyOpenGL*.whl
70+
prereqs/pips/pyopengl_accelerate*.tar.gz
71+
prereqs/pips/pyopengl_accelerate-3.1.9
7072
prereqs/pips/*.dylib.arm64
7173
prereqs/pips/*.dylib
7274
prereqs/pips/qtshim*.whl

prereqs/pips/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ else
4444
CYTHON_BUILD_ARGS=
4545
endif
4646

47+
PYOPENGL_SRC = pyopengl_accelerate-3.1.9.tar.gz
48+
4749
ifeq ($(OS),Windows)
4850
else
4951
ifeq ($(OS),Linux)
5052
ifeq ($(OSARCH),LinuxArm64)
53+
PYOPENGL_WHEEL = PyOpenGL_accelerate-3.1.9-cp311-cp311-linux_aarch64.whl
5154
else
5255
endif
5356
else
@@ -57,6 +60,7 @@ ifeq ($(OSARCH),DarwinArm64)
5760
SCIPY_WHEEL = $(subst ==,-,$(shell grep scipy $(TOP)/pyproject.toml | sed -e 's/[\ ",]//g'))-cp311-cp311-macosx_12_0_arm64.whl
5861
else
5962
ifeq ($(OSARCH),DarwinIntel64)
63+
PYOPENGL_WHEEL = PyOpenGL_accelerate-3.1.9-cp311-cp311-macosx_10_9_x86_64.whl
6064
endif
6165
endif
6266
endif
@@ -77,8 +81,8 @@ app-list:
7781

7882
upgrade:
7983

80-
ifeq ($(OSARCH),DarwinArm64)
81-
app-install: app_requirements.txt $(PLATO_WHEELS) $(SCIPY_WHEEL)
84+
ifneq ($(filter $(OSARCH),DarwinIntel64 LinuxArm64),)
85+
app-install: app_requirements.txt $(PLATO_WHEELS) $(SCIPY_WHEEL) patched-pyopengl
8286
else
8387
app-install: app_requirements.txt $(PLATO_WHEELS)
8488
endif
@@ -93,6 +97,7 @@ ifdef USE_PYSIDE6
9397
$(APP_PIP_INSTALL) $(shell grep PySide6 $(TOP)/pyproject.toml | sed -e 's/[\ #",]//g')
9498
$(APP_PIP_INSTALL) $(shell grep shiboken6 $(TOP)/pyproject.toml | sed -e 's/[\ #",]//g')
9599
endif
100+
$(APP_PIP_INSTALL) $(PYOPENGL_WHEEL)
96101
ifneq (,$(SOURCE_WHEELS))
97102
LANG=$(LANG) $(PIP_INSTALL) --no-build-isolation --no-binary $(subst $(SPACE),$(COMMA),$(SOURCE_WHEELS)) $(SOURCE_VERSIONS)
98103
endif
@@ -153,6 +158,8 @@ app-upgrade:
153158
clean:
154159
-rm -f pip.log
155160
-rm -f app_requirements.txt
161+
-rm -f pyopengl_accelerate-3.1.9.tar.gz
162+
-rm -rf pyopengl_accelerate-3.1.9
156163
make -C package_checker clean
157164

158165
outdated:
@@ -177,6 +184,17 @@ app-outdated:
177184
src-outdated:
178185
$(PYTHON_EXE) -m package_checker ../../src
179186

187+
ifneq ($(filter $(OSARCH),DarwinIntel64 LinuxArm64),)
188+
$(PYOPENGL_SRC):
189+
$(APP_PIP) download --no-build-isolation --no-binary=:all: $(shell grep PyOpenGL $(TOP)/pyproject.toml | sed 's/[\ ",#]//g')
190+
191+
patched-pyopengl: $(PYOPENGL_SRC)
192+
tar -xf $(PYOPENGL_SRC)
193+
patch -N -p0 < pyopengl_accelerate.patch
194+
$(APP_PIP) -m build --wheel pyopengl_accelerate-3.1.9
195+
mv pyopengl_accelerate-3.1.9/dist/$(PYOPENGL_WHEEL) .
196+
endif
197+
180198
$(SCIPY_WHEEL):
181199
$(APP_PIP) download --platform=macosx_12_0_arm64 --no-deps $(shell grep scipy $(TOP)/pyproject.toml | sed 's/[\ ",]//g')
182200

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
diff --color -rp pyopengl_accelerate-3.1.9.old/pyproject.toml pyopengl_accelerate-3.1.9/pyproject.toml
2+
*** pyopengl_accelerate-3.1.9.old/pyproject.toml 2025-01-19 16:30:48
3+
--- pyopengl_accelerate-3.1.9/pyproject.toml 2025-07-30 13:50:18
4+
*************** dynamic=["version"]
5+
*** 1,6 ****
6+
--- 1,7 ----
7+
[project]
8+
name="PyOpenGL-accelerate"
9+
dynamic=["version"]
10+
+ requires-python = ">= 3.9" # At least Python 3.9
11+
description = "Cython-coded accelerators for PyOpenGL"
12+
authors = [
13+
{name="Mike C. Fletcher",email="[email protected]"},
14+
*************** classifiers = [
15+
*** 23,29 ****
16+
classifiers = [
17+
"License :: OSI Approved :: BSD License",
18+
"Programming Language :: Python",
19+
- "Programming Language :: Python :: 2",
20+
"Programming Language :: Python :: 3",
21+
"Topic :: Multimedia :: Graphics :: 3D Rendering",
22+
"Topic :: Software Development :: Libraries :: Python Modules",
23+
--- 24,29 ----
24+
*************** Documentation = "https://mcfletch.github.io/pyopengl/d
25+
*** 36,42 ****
26+
Documentation = "https://mcfletch.github.io/pyopengl/documentation/index.html"
27+
28+
[build-system]
29+
! requires = [ "setuptools >= 42.0", "Cython >= 0.28", "numpy" ]
30+
build-backend = "setuptools.build_meta"
31+
32+
[tool.setuptools.dynamic]
33+
--- 36,42 ----
34+
Documentation = "https://mcfletch.github.io/pyopengl/documentation/index.html"
35+
36+
[build-system]
37+
! requires = [ "setuptools >= 42.0", "Cython >= 3", "numpy" ]
38+
build-backend = "setuptools.build_meta"
39+
40+
[tool.setuptools.dynamic]
41+
*************** include=["OpenGL_accelerate"]
42+
*** 45,49 ****
43+
[tool.setuptools.packages.find]
44+
namespaces=false
45+
include=["OpenGL_accelerate"]
46+
! exclude=["tests","src"]
47+
48+
--- 45,49 ----
49+
[tool.setuptools.packages.find]
50+
namespaces=false
51+
include=["OpenGL_accelerate"]
52+
! exclude=["tests", "src"]
53+
54+
diff --color -rp pyopengl_accelerate-3.1.9.old/src/vbo.pyx pyopengl_accelerate-3.1.9/src/vbo.pyx
55+
*** pyopengl_accelerate-3.1.9.old/src/vbo.pyx 2025-01-19 16:30:48
56+
--- pyopengl_accelerate-3.1.9/src/vbo.pyx 2025-07-30 13:50:18
57+
*************** cdef class VBO:
58+
*** 188,195 ****
59+
assert not self.created, """Already created the buffer"""
60+
buffers = self.get_implementation().glGenBuffers(1)
61+
try:
62+
! self.buffer = long( buffers )
63+
! except (TypeError,ValueError) as err:
64+
self.buffer = buffers[0]
65+
self.target = self.c_resolve( self.target_spec )
66+
self.usage = self.c_resolve( self.usage_spec )
67+
--- 188,195 ----
68+
assert not self.created, """Already created the buffer"""
69+
buffers = self.get_implementation().glGenBuffers(1)
70+
try:
71+
! self.buffer = int( buffers )
72+
! except (TypeError, ValueError) as err:
73+
self.buffer = buffers[0]
74+
self.target = self.c_resolve( self.target_spec )
75+
self.usage = self.c_resolve( self.usage_spec )
76+
*************** cdef class VBO:
77+
*** 242,248 ****
78+
"""Add an integer to this VBO (offset)"""
79+
if hasattr( other, 'offset' ):
80+
other = other.offset
81+
! assert isinstance( other, (int,long) ), """Only know how to add integer/long offsets"""
82+
return VBOOffset( self, other )
83+
cdef int check_live( self ):
84+
if self.data is _NULL:
85+
--- 242,248 ----
86+
"""Add an integer to this VBO (offset)"""
87+
if hasattr( other, 'offset' ):
88+
other = other.offset
89+
! assert isinstance( other, int), """Only know how to add integer offsets"""
90+
return VBOOffset( self, other )
91+
cdef int check_live( self ):
92+
if self.data is _NULL:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ file = "README.md"
2626
gui = [
2727
"openvr==1.26.701",
2828
"PyOpenGL==3.1.9",
29-
"PyOpenGL-accelerate==3.1.9",
29+
#"PyOpenGL-accelerate==3.1.9",
3030
# PyQt handled in prereqs/PyQt"
3131
# sip handled in prereqs/PyQt
3232
#PySide6==6.9.0

0 commit comments

Comments
 (0)