From aab7610c585cb27168142a62487b570719fa3413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= Date: Tue, 28 Nov 2023 15:09:50 +0100 Subject: [PATCH] Patch PyOpenGL for Python 3.12 --- build-pyinstaller.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build-pyinstaller.py b/build-pyinstaller.py index 456a08992..7eb8804df 100644 --- a/build-pyinstaller.py +++ b/build-pyinstaller.py @@ -7,6 +7,24 @@ os.path.join(".", "build-" + sys.platform), os.path.join(".", "dist-" + sys.platform)) +# patch PyOpenGL +try: + import OpenGL + if OpenGL.__version__ == '3.1.7': + fname = OpenGL.__file__ + if fname[-1] == "c": + fname = fname[:-1] + infile = open(fname, "rb").read() + infile = infile.replace(b'_bi + ".CArgObject",' , + b'("_ctypes" if sys.version_info[:2] >= (3,12) else _bi) + ".CArgObject",') + outfile = open(fname, "wb").write(infile) + infile = None + outfile = None +except ImportError: + pass +except Exception: + print("Cannot patch PyOpenGL") + if sys.platform.startswith("darwin"): if "arm64" in sys.argv: os.putenv("PYMCA_PYINSTALLER_TARGET_ARCH", "arm64")