This sections describes details about specific features. For a full list of features please refer to the website.
Ctypes is a foreign function library for Python, that allows calling functions present in shared libraries. Those libraries are not imported as Python packages, because they are not picked up via Python imports: their path is passed to ctypes instead, which deals with the shared library directly; this caused <1.4 PyInstaller import detect machinery to miss those libraries, failing the goal to build self-contained PyInstaller executables:
from ctypes import * # This will pass undetected under PyInstaller detect machinery, # because it's not a direct import. handle = CDLL("/usr/lib/library.so") handle.function_call()
PyInstaller contains a pragmatic implementation of Ctypes dependencies: it will search for simple standard usages of ctypes and automatically track and bundle the referenced libraries. The following usages will be correctly detected:
CDLL("library.so") WinDLL("library.so") ctypes.DLL("library.so") cdll.library # Only valid under Windows - a limitation of ctypes, not PyInstaller's windll.library # Only valid under Windows - a limitation of ctypes, not PyInstaller's cdll.LoadLibrary("library.so") windll.LoadLibrary("library.so")
More in detail, the following restrictions apply:
We feel that it should be enough to cover most ctypes’ usages, with little or no modification required in your code.
does not detect a library, you can add it to your
bundle by passing the respective information to
listing it in the .spec-file
. If your frozen
application will be able to pick up the library at run-time can not be
guaranteed as it depends on the detailed implementation.
The ctypes detection system at
is based on
This means that you have to make sure
that while performing
and running frozen,
all the environment values
uses to search libraries
are aligned to those when running un-frozen.
Examples include using
PyInstaller tries to detect binary modules created by SWIG. This detection requires:
automatically generated by SWIG.
_). (This is a SWIG restriction already.)
Also some restrictions apply for Python 3, due to the way the SWIG wrapper is implemented:
pkg2._cmod), as one would overwrite the other.
PyInstaller can follow import statements that refer to Cython C object modules and bundle them – like for any other module implemented in C.
But – again, as for any other module implemented in C –
determine if the Cython C object module is importing some Python module.
These will typically show up as in a traceback like this
Traceback (most recent call last): […] File "myapp\cython_module.pyx", line 3, in init myapp.cython_module ModuleNotFoundError: No module named 'csv'
So if you are using a Cython C object module, which imports Python modules,
you will have to list these as