Skip to content

Commit

Permalink
Patch PyOpenGL for Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed Nov 28, 2023
1 parent b952b01 commit aab7610
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build-pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit aab7610

Please sign in to comment.