The problem library is Capstone (
https://pypi.org/project/capstone/), to be specific. Upon trying to load capstone in single-file Linux executable, it immediately crashes with this error:
File "capstone/__init__.py", line 315, in <module>
ImportError: ERROR: fail to load the dynamic library.
I can confirm that the dynamic library that it searches for, libcapstone.so, is present in the installer. I include libcapstone.so by passing it in the "binaries" argument to "Analysis" in my .spec file. The relevant code in Capstone that tries to load
the library and fails is as such:
_lib = "libcapstone.so"
_found = False
def _load_lib(path):
lib_file = join(path, _lib)
if os.path.exists(lib_file):
return ctypes.cdll.LoadLibrary(lib_file)
return None
_cs = None
_path_list = [os.getenv('LIBCAPSTONE_PATH', None),
pkg_resources.resource_filename(__name__, 'lib'),
join(split(__file__)[0], 'lib'),
'',
distutils.sysconfig.get_python_lib(),
'/usr/lib64']
for _path in _path_list:
if _path is None: continue
_cs = _load_lib(_path)
if _cs is not None: break
else:
raise ImportError("ERROR: fail to load the dynamic library.")
What is the standard operating procedure for getting libraries linked to packages that look them up in
pkg_resources? If there isn't a way, is there a method
of ensuring the "LIBCAPSTONE_PATH" environment variable is set to "_MEIPASS" before any other code runs?