New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frozen ctypes.util.find_library("OpenGL") returns None on macOS Big Sur #5491
Comments
I'm surprised by this. Does that file really exist? System libraries are supposed to be hidden on Big Sur. Anything using |
It actually does work as described. But only if 3.9.1 |
Interestingly, this fails on macOS 10.14, macOS 10.15, and macOS 11.1 (not frozen): In [1]: import ctypes
...: ctypes.CDLL("OpenGL", ctypes.RTLD_GLOBAL)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-3-7fa9d8669c3d> in <module>
1 import ctypes
----> 2 ctypes.CDLL("OpenGL", ctypes.RTLD_GLOBAL)
~/.pyenv/versions/3.8.2/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
371
372 if handle is None:
--> 373 self._handle = _dlopen(self._name, mode)
374 else:
375 self._handle = handle
OSError: dlopen(OpenGL, 10): image not found This is probably why PyOpenGL passes the result of |
Aha, figured it out... since our bootloader is not built for Big Sur (i.e., the SDK we build against is probably older than 11.0), the platform identification is using compatibility 10.16 identifier instead of 11.x one. And this makes _ctypes._dyld_shared_cache_contains_path() unavailable at runtime. E.g., # find_c_library.py
import platform
import ctypes.util
print("Platform:", platform.mac_ver())
print(ctypes.util.find_library("c")) Unfrozen script:
Frozen script:
Frozen script, with version compatibility mode disabled:
|
I take it then that this would be another fat binary like in #5315? i.e. Build with |
Add a runtime hook to macOS bundles that patches `ctypes.util.find_library()` to return the correct OpenGL framwork path. Necessary, to make PyOpenGL work within the macOS bundles running on macOS Big Sur. See pyinstaller/pyinstaller#5491 for details. To commit is to be reverted once PyInstaller has released a fix for this issue.
I don't think so - I think we'd just need to build against 11.0 SDK, but we can leave the minimum version at lower version. For example, if you run
(which is consistent with the note on python.org that this version should still run on 10.9 or newer). In our bootloader's case, we get:
|
Ah, that's not too bad then. I imagine this can be set somewhere in the vagrant file in the bootloader folder. |
We can close this now, as bootloaders in just-released PyInstaller 4.3 have been built against recent MacOS SDK, and so |
Description of the issue
ctypes.util.find_library("OpenGL")
returnsNone
when frozenctypes.util.find_library("OpenGL")
returns/System/Library/Frameworks/OpenGL.framework/OpenGL
when not froozen/System/Library/Frameworks/OpenGL.framework/OpenGL
(frozen and not frozen equally)I expect
ctypes.util.find_library("OpenGL")
to always return the same path, independent of being frozen or not.This issue might affect other system libraries as well.
See more motivation at the bottom as to why this is relevant.
Context information
Details
* Output of `pyinstaller --version`: `4.2` and `5.0.dev0` * Version of Python: 3.9.1 (via [`macOS 64-bit universal2 installer`](https://www.python.org/downloads/release/python-391/)) * Freezing Platform: `macOS 10.14.6 Mojave` * Runtime Platform: - incorrect behavior on `macOS 11.1 Big Sur` - correct behavior on `macOS 10.15.7 Catalina`
Checklist
--noupx
or setupx=False
in your .spec-file--debug
topyi-makespec
orpyinstaller
or useEXE(..., debug=1, ...)
in your .spec file.Passing
--debug all
causes the binary to seg fault on the runtime platform.A minimal example program which shows the error
Details
Program to be frozen: `find_opengl.py` ```py import ctypes.util
print(ctypes.util.find_library("OpenGL"))
Again, passing
--debug all
causes the binary to seg fault on the runtime platform (Big Sur).Output
Details
#### macOS 10.15.7 Catalina (frozen on macOS 10.14.6)
macOS 11.1 Big Sur (frozen on macOS 10.14.6)
macOS 11.1 Big Sur (frozen on macOS 11.1)
Motivation
Details
I am trying to freeze a larger program that depends on [PyOpenGL](https://pypi.org/project/PyOpenGL/). Unfortunately, PyOpenGL is not hosted such that one can directly link to the source. Instead, I am quoting the relevant function:
OpenGL/platform/ctypesloader.py:17-36
, called fromOpenGL/platform/darwin.py:35
dllType
is of type__main__.PyInstallerCDLL
name
isOpenGL
mode
isctypes.RTLD_GLOBAL
fullName = util.find_library( name )
returnsNone
on Big SurdllType( name, mode )
causes Pyinstaller can't find dynamically linked libs for Mac OS X Big Sur Beta #5107 (comment)OpenGL/platform/darwin.py:32-41
The text was updated successfully, but these errors were encountered: