Hello! I've been using PyInstaller gainfully for a while now, but a recent 
addition of a new package to my installer is causing me some troubles, and I'm 
stumped as to how one normally solves this issue.

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?
________________________________
The information contained in this e-mail and any attachments from GrammaTech, 
Inc may contain confidential and/or proprietary information, and is intended 
only for the named recipient to whom it was originally addressed. If you are 
not the intended recipient, any disclosure, distribution, or copying of this 
e-mail or its attachments is strictly prohibited. If you have received this 
e-mail in error, please notify the sender immediately by return e-mail and 
permanently delete the e-mail and any attachments.

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/BN3P110MB0369A95AF426EECC4ECB48DEB9B39%40BN3P110MB0369.NAMP110.PROD.OUTLOOK.COM.

Reply via email to