I have an app using nuitka, and for fun and knowledge I want to attempt to port it off nuitka and onto a native python installation that includes everything necessary.
I gather the means to do this directly would be to start with a static build of python.
I started by using this:
cython -3 hello.py --embed
# cd $HOME/GitHub/cpython
# PY_INCLUDES="$(python -m python-config --includes)"
# PY_CFLAGS="$(python -m python-config --cflags)"
# PY_LFLAGS="$(python -m python-config --ldflags)"
# cd -
PY_INCLUDES="$(python3.12-config --includes)"
PY_CFLAGS="$(python3.12-config --cflags)"
PY_LFLAGS="$(python3.12-config --ldflags --embed)"
PY_PATH="-L/usr/lib/python3.12/config-3.12-x86_64-linux-gnu/"
echo Compiling python with cflags: $PY_CFLAGS lflags: $PY_LFLAGS from path $PY_PATH
gcc --static $PY_INCLUDES $PY_CFLAGS hello.c -o hello \
-static-libgcc -static-libstdc++ $PY_PATH $PY_LFLAGS
To dump a simple hello.py script into an excutable. It worked until native modules started loading:
Traceback (most recent call last):
File "hello.py", line 1, in init hello
import base64
File "/usr/lib/python3.12/base64.py", line 10, in <module>
import struct
File "/usr/lib/python3.12/struct.py", line 13, in <module>
from _struct import *
ImportError: /usr/lib/python3.12/lib-dynload/_struct.cpython-312-x86_64-linux-gnu.so: undefined symbol: PyObject_ClearWeakRefs
I'm not exactly sure, but this reads like it's still trying to load the system modules here. So, I grabbed a static build of 3.10 out of the AUR (I, uh, couldn't get it building statically myself after digging up a few pages on it) and get this:
/usr/bin/ld: /tmp//ccAdPPcj.ltrans0.ltrans.o: in function `__pyx_pymod_exec_hello':
/home/sk3shun-8/GitHub/umomwd/hello.c:4168:(.text.unlikely+0x9ba): undefined reference to `Py_Version'
collect2: error: ld returned 1 exit status
Any suggestions greatly appreciated π