Beispiel #1
0
def test_5734():
    """
    In a regression this will raise a:
        FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'
    on some Linux/gcc combinations.
    """
    from PyInstaller.depend.utils import _resolveCtypesImports
    _resolveCtypesImports(["libc"])
Beispiel #2
0
def hook(mod):
    for candidate in libusb_candidates:
        libname = ctypes.util.find_library(candidate)
        if libname is not None:
            break

    if libname is not None:
        # Use basename here because Python returns full library path
        # on Mac OSX when using ctypes.util.find_library.
        bins = [os.path.basename(libname)]
        mod.binaries.extend(_resolveCtypesImports(bins))
    elif is_cygwin:
        bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
        mod.binaries.extend(_resolveCtypesImports(bins)[0:1])

    return mod
Beispiel #3
0
def hook(mod):
    for candidate in libusb_candidates:
        libname = ctypes.util.find_library(candidate)
        if libname is not None:
            break

    if libname is not None:
        # Use basename here because Python returns full library path
        # on Mac OSX when using ctypes.util.find_library.
        bins = [os.path.basename(libname)]
        mod.pyinstaller_binaries.extend(_resolveCtypesImports(bins))
    elif is_cygwin:
        bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
        mod.pyinstaller_binaries.extend(_resolveCtypesImports(bins)[0:1])

    return mod
Beispiel #4
0
    def scancode(self):
        self.pyinstaller_imports, self.pyinstaller_warnings, self.pyinstaller_binaries, allnms = scan_code(self.co)
        self.pyinstaller_imports = self._remove_duplicate_entries(self.pyinstaller_imports)

        if allnms:
            self._all = allnms
        if ctypes and self.pyinstaller_binaries:
            self.pyinstaller_binaries = _resolveCtypesImports(self.pyinstaller_binaries)
            # Just to make sure there will be no duplicate entries.
            self.pyinstaller_binaries = self._remove_duplicate_entries(self.pyinstaller_binaries)
Beispiel #5
0
    def _find_system_mediainfo_library():
        import os
        import ctypes.util
        from PyInstaller.depend.utils import _resolveCtypesImports

        libname = ctypes.util.find_library("mediainfo")
        if libname is not None:
            resolved_binary = _resolveCtypesImports(
                [os.path.basename(libname)])
            if resolved_binary:
                return resolved_binary[0][1]
Beispiel #6
0
    def scancode(self):
        self.pyinstaller_imports, self.pyinstaller_warnings, self.pyinstaller_binaries, allnms = scan_code(
            self.co)
        self.pyinstaller_imports = self._remove_duplicate_entries(
            self.pyinstaller_imports)

        if allnms:
            self._all = allnms
        if ctypes and self.pyinstaller_binaries:
            self.pyinstaller_binaries = _resolveCtypesImports(
                self.pyinstaller_binaries)
            # Just to make sure there will be no duplicate entries.
            self.pyinstaller_binaries = self._remove_duplicate_entries(
                self.pyinstaller_binaries)
Beispiel #7
0
    def scancode(self):
        self.imports, self.warnings, self.binaries, allnms = scan_code(self.co)
        # TODO There has to be some bugs in the 'scan_code()' functions because
        #      some imports are present twice in the self.imports list.
        #      This could be fixed when scan_code will be replaced by package
        #      modulegraph.
        self.imports = self._remove_duplicate_entries(self.imports)

        if allnms:
            self._all = allnms
        if ctypes and self.binaries:
            self.binaries = _resolveCtypesImports(self.binaries)
            # Just to make sure there will be no duplicate entries.
            self.binaries = self._remove_duplicate_entries(self.binaries)
Beispiel #8
0
import os

from PyInstaller.depend.utils import _resolveCtypesImports
from PyInstaller.utils.hooks import collect_data_files, logger

datas = collect_data_files("cairocffi")

binaries = []

# NOTE: Update this if cairocffi requires more libraries
libs = ["cairo-2", "cairo", "libcairo-2"]

try:
    lib_basenames = []
    for lib in libs:
        libname = ctypes.util.find_library(lib)
        if libname is not None:
            lib_basenames += [os.path.basename(libname)]

    if lib_basenames:
        resolved_libs = _resolveCtypesImports(lib_basenames)
        for resolved_lib in resolved_libs:
            binaries.append((resolved_lib[1], '.'))
except Exception as e:
    logger.warning(
        "Error while trying to find system-installed Cairo library: %s", e)

if not binaries:
    logger.warning(
        "Cairo library not found - cairocffi will likely fail to work!")
Beispiel #9
0
# NOTE: Mind updating run-time hook when adding further libs.
libusb_candidates = (
    # libusb10
    'usb-1.0', 'usb', 'libusb-1.0',
    # libusb01
    'usb-0.1', 'libusb0',
    # openusb
    'openusb',
)

for candidate in libusb_candidates:
    libname = ctypes.util.find_library(candidate)
    if libname is not None:
        break

if libname is not None:
    # Use basename here because Python returns full library path
    # on Mac OSX when using ctypes.util.find_library.
    bins = [os.path.basename(libname)]
    binaries = _resolveCtypesImports(bins)
elif is_cygwin:
    bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
    binaries = _resolveCtypesImports(bins)[:1]  # use only the first one if any
else:
    binaries = []
if binaries:
    # `_resolveCtypesImports` returns a 3-tuple, but `binaries` are only
    # 2-tuples, so remove the last element:
    assert len(binaries[0]) == 3
    binaries.pop(2)
Beispiel #10
0
        'usb',
        'libusb-1.0',
        # libusb01
        'usb-0.1',
        'libusb0',
        # openusb
        'openusb',
    )

    for candidate in libusb_candidates:
        libname = ctypes.util.find_library(candidate)
        if libname is not None:
            break

    if libname is not None:
        # Use basename here because Python returns full library path
        # on Mac OSX when using ctypes.util.find_library.
        bins = [os.path.basename(libname)]
        binaries = _resolveCtypesImports(bins)
    elif is_cygwin:
        bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
        binaries = _resolveCtypesImports(bins)[:1]  # use only the first one
    else:
        binaries = []

    if binaries:
        # `_resolveCtypesImports` returns a 3-tuple, but `binaries` are only
        # 2-tuples, so remove the last element:
        assert len(binaries[0]) == 3
        binaries = [(binaries[0][1], '')]
Beispiel #11
0
 def scancode(self):
     self.imports, self.warnings, self.binaries, allnms = scan_code(self.co)
     if allnms:
         self._all = allnms
     if ctypes and self.binaries:
         self.binaries = _resolveCtypesImports(self.binaries)
Beispiel #12
0
 def scancode(self):
     self.imports, self.warnings, self.binaries, allnms = scan_code(self.co)
     if allnms:
         self._all = allnms
     if ctypes and self.binaries:
         self.binaries = _resolveCtypesImports(self.binaries)
Beispiel #13
0
    try:
        # get the backend symbols before find
        backend_contents_before_discovery = set(dir(usb.backend))
        # perform find, which will load a usb library if found
        usb.core.find()
        # get the backend symbols which have been added (loaded)
        backends = set(dir(usb.backend)) - backend_contents_before_discovery
        # gather the libraries from the loaded backends
        backend_lib_basenames = []
        for usblib in [getattr(usb.backend, be)._lib for be in backends]:
            if usblib is not None:
                # OSX returns the full path, Linux only the filename.
                # save the basename and reconstruct the path after gathering.
                backend_lib_basenames.append(os.path.basename(usblib._name))
        # try to resolve the library names to absolute paths.
        binaries = _resolveCtypesImports(backend_lib_basenames)
    except (ValueError, usb.core.USBError) as exc:
        logger.warning("%s", exc)

# If pyusb didn't find a backend, manually search for usb libraries.
if not binaries:
    # NOTE: Update these lists when adding further libs.
    if is_cygwin:
        libusb_candidates = ['cygusb-1.0-0.dll', 'cygusb0.dll']
    else:
        libusb_candidates = [
            # libusb10
            'usb-1.0', 'usb', 'libusb-1.0',
            # libusb01
            'usb-0.1', 'libusb0',
            # openusb
Beispiel #14
0
import os
import ctypes

from PyInstaller.utils.hooks import collect_dynamic_libs, logger, get_package_paths
from PyInstaller.depend.utils import _resolveCtypesImports


def collect_native_files(package, files):
    pkg_base, pkg_dir = get_package_paths(package)
    return [(os.path.join(pkg_dir, file), '.') for file in files]


#files = ['libGLES_mali.so']
excludes = ['tvm._ffi._cy3.core', 'tvm._ffi._cy3']

#datas = collect_native_files('tvm', files)

binaries = collect_dynamic_libs("tvm")
binaries += _resolveCtypesImports('libtvm')
hiddenimports = [
    '_cffi_backend', 'tvm._ffi._ctypes', 'tvm._ffi._ctypes.ndarray',
    'tvm._ffi._cy2', 'tvm._ffi._cy2.core'
]
logger.warning(binaries)
#logger.warning(datas)
Beispiel #15
0
    try:
        # get the backend symbols before find
        backend_contents_before_discovery = set(dir(usb.backend))
        # perform find, which will load a usb library if found
        usb.core.find()
        # get the backend symbols which have been added (loaded)
        backends = set(dir(usb.backend)) - backend_contents_before_discovery
        # gather the libraries from the loaded backends
        backend_lib_basenames = []
        for usblib in [getattr(usb.backend, be)._lib for be in backends]:
            if usblib is not None:
                # OSX returns the full path, Linux only the filename.
                # save the basename and reconstruct the path after gathering.
                backend_lib_basenames.append(os.path.basename(usblib._name))
        # try to resolve the library names to absolute paths.
        binaries = _resolveCtypesImports(backend_lib_basenames)
    except (ValueError, usb.core.USBError) as exc:
        logger.warning("%s", exc)


# If pyusb didn't find a backend, manually search for usb libraries.
if not binaries:
    # NOTE: Update these lists when adding further libs.
    if is_cygwin:
        libusb_candidates = ['cygusb-1.0-0.dll', 'cygusb0.dll']
    else:
        libusb_candidates = [
            # libusb10
            'usb-1.0', 'usb', 'libusb-1.0',
            # libusb01
            'usb-0.1', 'libusb0',
Beispiel #16
0
# first try to use pyusb library locator
try:
    # get the backend symbols before find
    pyusb_backend_dir = set(dir(usb.backend))

    # perform find, which will load a usb library if found
    usb.core.find()

    # get the backend symbols which have been added (loaded)
    backends = set(dir(usb.backend)) - pyusb_backend_dir

    # for each of the loaded backends, see if they have a library
    binaries = []
    for usblib in [getattr(usb.backend, be)._lib for be in backends]:
        if usblib is not None:
            binaries = _resolveCtypesImports([os.path.basename(usblib._name)])
            assert len(binaries[0]) == 3
            binaries = [(binaries[0][1], '')]

except (ValueError, usb.core.USBError) as exc:
    logger.warning("%s", exc)

# if nothing found, try to use our custom mechanism
if not binaries:
    # Try to resolve your libusb libraries in the following order:
    #
    #   libusb-1.0, libusb-0.1, openusb
    #
    # NOTE: Mind updating run-time hook when adding further libs.
    libusb_candidates = (
        # libusb10