Standalone includes hardcoded external modules meaning executable can't be shared
See original GitHub issue- Nuitka version, full Python version and Platform (Windows, OSX, Linux …)
$ python -m nuitka --version
0.6.5
Python: 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
Executable: /Users/brendan/.local/share/virtualenvs/test/bin/python
OS: Darwin
Arch: x86_64
$ uname -a
Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
-
How did you install Nuitka and Python (pip, anaconda, deb, rpm, from source, what is a virtualenv …), this is very important usually.
- Python from https://www.python.org
- nuitka with pipenv
-
If possible please supply a Short, Self Contained, Correct, Example that demonstrates the issue i.e a small piece of code which reproduces the issue and can be run with out any other (or as few as possible) external dependencies.
$ cat main.py
import random
$ python -m nuitka --standalone main.py
$ ./main.dist/main
$ sudo mv /Library/Frameworks/Python.framework/Versions/3.7 /Library/Frameworks/Python.framework/Versions/3.6
$ ./main.dist/main
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/tmp/example/main.dist/./hashlib.py", line 244, in <module>
File "/tmp/example/main.dist/./hashlib.py", line 113, in __get_builtin_constructor
ValueError: unsupported hash type sha512
Traceback (most recent call last):
File "/tmp/example/main.dist/./main.py", line 1, in <module>
File "/tmp/example/main.dist/./random.py", line 46, in <module>
ImportError: cannot import name 'sha512' from 'hashlib' (/tmp/example/main.dist/./hashlib.py)
$ otool -l main.dist/*.so | grep ' name' | sort | uniq
name /Library/Frameworks/Python.framework/Versions/3.7/lib/libpanelw.5.dylib (offset 24)
name /Library/Frameworks/Python.framework/Versions/3.7/lib/libssl.1.1.dylib (offset 24)
name /Library/Frameworks/Python.framework/Versions/3.7/lib/libtcl8.6.dylib (offset 24)
name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
name /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (offset 24)
name /usr/lib/libSystem.B.dylib (offset 24)
name /usr/lib/libbz2.1.0.dylib (offset 24)
name /usr/lib/libedit.3.dylib (offset 24)
name /usr/lib/libz.1.dylib (offset 24)
name @executable_path/libcrypto.1.1.dylib (offset 24)
name @executable_path/libncursesw.5.dylib (offset 24)
name @executable_path/libtk8.6.dylib (offset 24)
i have encountered this exact problem when building a standalone executable using Python 3.7.4 and distributing to someone who doesn’t have Python 3.7 installed. Clearly the /Library/Frameworks/Python.framework/Versions/3.7
path makes it non-portable and need replacing with @executable_path/...
versions. I don’t know about the other hardcoded paths, are these reliably available on different mac versions?
In my actually application the following path is also in the above list:
name /usr/lib/libffi.dylib (offset 24)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
I encountered the same problem.
I’m using Python which is installed from Command Line Tools and the path of it is
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework
. When building with standalone option, generated binary hasLC_LOAD_DYLIB
with@rpath/Python3.framework/Versions/3.8/Python3
but does not haveLC_RPATH
. Thus, it cannot be executed.I finally solved this problem by inserting
env.Append(LINKFLAGS=["-Wl,-rpath,/Library/Developer/CommandLineTools/Library/Frameworks"])
tonuitka/build/SingleExe.scons
( which is renamed toBackend.scons
on develop branch ). Now I can get executable binary by building with standalone option. I don’t know whether this is general solution, the following snippet might help some people who are in trouble.Unfortunately I have no access to macOS. Basically in nuitka.freezer.Standalone there is code specific to macOS that should resolve the rpaths and apparently it may not be general enough. There is no way I can do it right now, and therefore I need your PRs.
I believe @tiwatsuka you are encoutering a problem from using a non-standard Python, or the same issue, I don’t quite understand honestly.