relocatable-python
relocatable-python copied to clipboard
Using link to execute relocated 3.11 bin/python3 fails to find libraries
We're using a symbolic link for munkireport-python3 to point to a relocated python framework:
→ ls -l /usr/local/munkireport/munkireport-python3
lrwxr-xr-x 1 root wheel 63 24 Feb 10:10 /usr/local/munkireport/munkireport-python3 -> /Library/MunkiReport/Python.framework/Versions/3.11/bin/python3
Executing /Library/MunkiReport/Python.framework/Versions/3.11/bin/python3 works fine:
→ /Library/MunkiReport/Python.framework/Versions/3.11/bin/python3
Python 3.11.2 (v3.11.2:878ead1ac1, Feb 7 2023, 10:02:41) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python311.zip',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11/lib-dynload',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11/site-packages']
>>> ^D
Calling it with the link fails to find platform dependent libraries:
→ /usr/local/munkireport/munkireport-python3
Could not find platform dependent libraries <exec_prefix>
Python 3.11.2 (v3.11.2:878ead1ac1, Feb 7 2023, 10:02:41) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python311.zip',
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11',
'/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload', # ouch
'/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11/site-packages']
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/MunkiReport/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 51, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
>>> ^D
A relocated 3.10 doesn't seem to have a problem with this:
→ /usr/local/munkireport/munkireport-python3
Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['',
'/Library/MunkiReport/Python.framework/Versions/3.10/lib/python310.zip',
'/Library/MunkiReport/Python.framework/Versions/3.10/lib/python3.10',
'/Library/MunkiReport/Python.framework/Versions/3.10/lib/python3.10/lib-dynload',
'/Library/MunkiReport/Python.framework/Versions/3.10/lib/python3.10/site-packages']
>>> ^D
I'm building with these options:
./make_relocatable_python_framework.py \
--upgrade-pip \
--pip-requirements="../$PKGDIR/requirements.txt" \
--os-version=11 \
--python-version "$version" \
--destination "../$FWROOT" \