Пример #1
0
def collect_pkg_data(package, include_py_files=False, subdir=None):
    import os
    from PyInstaller.utils.hooks import get_package_paths, remove_prefix, PY_IGNORE_EXTENSIONS

    # Accept only strings as packages.
    if type(package) is not str:
        raise ValueError

    pkg_base, pkg_dir = get_package_paths(package)
    if subdir:
        pkg_dir = os.path.join(pkg_dir, subdir)
    # Walk through all file in the given package, looking for data files.
    data_toc = TOC()
    for dir_path, dir_names, files in os.walk(pkg_dir):

        copy_root_token = os.path.split(dir_path)[-1]
        copy_root = copy_root_token in ["support", "configdata"]
        # if copy_root:
        #     print("- %s" % dir_path)

        for f in files:
            extension = os.path.splitext(f)[1]
            if include_py_files or (extension not in PY_IGNORE_EXTENSIONS):
                source_file = os.path.join(dir_path, f)
                dest_folder = remove_prefix(dir_path,
                                            os.path.dirname(pkg_base) + os.sep)
                dest_file = os.path.join(dest_folder, f)
                data_toc.append((dest_file, source_file, 'DATA'))

                if copy_root:
                    source_file = os.path.join(dir_path, f)
                    root_path = os.path.join(os.path.dirname(pkg_base), "hyo2",
                                             "grids") + os.sep
                    dest_folder = remove_prefix(dir_path, root_path)
                    dest_file = os.path.join(dest_folder, f)
                    # print("%s -> %s" % (dest_file, source_file))
                    data_toc.append((dest_file, source_file, 'DATA'))

    return data_toc
Пример #2
0
def collect_dynamic_libs(package, destdir=None):
    """
    This routine produces a list of (source, dest) of dynamic library
    files which reside in package. Its results can be directly assigned to
    ``binaries`` in a hook script. The package parameter must be a string which
    names the package.

    :param destdir: Relative path to ./dist/APPNAME where the libraries
                    should be put.
    """
    # Accept only strings as packages.
    if not isinstance(package, string_types):
        raise ValueError

    logger.debug("Collecting dynamic libraries for %s" % package)
    pkg_base, pkg_dir = get_package_paths(package)
    # Walk through all file in the given package, looking for dynamic libraries.
    dylibs = []
    for dirpath, _, __ in os.walk(pkg_dir):
        # Try all file patterns in a given directory.
        for pattern in PY_DYLIB_PATTERNS:
            files = glob.glob(os.path.join(dirpath, pattern))
            for source in files:
                # Produce the tuple
                # (/abs/path/to/source/mod/submod/file.pyd,
                #  mod/submod/file.pyd)
                if destdir:
                    # Libraries will be put in the same directory.
                    dest = destdir
                else:
                    # The directory hierarchy is preserved as in the original package.
                    dest = remove_prefix(dirpath,
                                         os.path.dirname(pkg_base) + os.sep)
                logger.debug(" %s, %s" % (source, dest))
                dylibs.append((source, dest))
    return dylibs
Пример #3
0
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

import os

from PyInstaller.utils.hooks import get_package_paths
from PyInstaller.utils.hooks import is_module_satisfies
from PyInstaller import compat

# Necessary when using the vectorized subpackage
hiddenimports = ['shapely.prepared']

pkg_base, pkg_dir = get_package_paths('shapely')


binaries = []
if compat.is_win:
    if compat.is_conda:
        lib_dir = os.path.join(compat.base_prefix, 'Library', 'bin')
    else:
        lib_dir = os.path.join(pkg_dir, 'DLLs')
    dll_files = ['geos_c.dll', 'geos.dll']
    binaries += [(os.path.join(lib_dir, f), '.') for f in dll_files]
elif compat.is_linux:
    lib_dir = os.path.join(pkg_dir, '.libs')
    dest_dir = os.path.join('shapely', '.libs')

    # This duplicates the libgeos*.so* files in the build.  PyInstaller will
Пример #4
0
import os
from PyInstaller.utils.hooks import get_package_paths

sfp = get_package_paths("soundfile")

bins = os.path.join(sfp[0], "_soundfile_data")
datas = [(bins, "_soundfile_data")]
binaries = []
Пример #5
0
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]
Пример #6
0
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------
"""
pysoundfile:
https://github.com/bastibe/SoundFile
"""

import os

from PyInstaller.compat import is_win, is_darwin
from PyInstaller.utils.hooks import get_package_paths

# get path of soundfile
sfp = get_package_paths('soundfile')

# add binaries packaged by soundfile on OSX and Windows
# an external dependency (libsndfile) is used on GNU/Linux
path = None
if is_win:
    path = os.path.join(sfp[0], '_soundfile_data')
elif is_darwin:
    path = os.path.join(sfp[0], '_soundfile_data', 'libsndfile.dylib')

if path is not None and os.path.exists(path):
    binaries = [(path, "_soundfile_data")]
Пример #7
0
from pathlib import Path
from PyInstaller.utils.hooks import get_package_paths

# ok great, we're getting the templates directly from the horses mouth
templates = Path(get_package_paths("justpy.templates")[1])
leaf = Path(get_package_paths("humbletray")[1]) / "leaf.png"

datas = [(str(leaf), "."), (templates, "justpy/templates")]

hiddenimports = [
    "pystray._win32",
    "schedule",
    "uvicorn.lifespan.on",
    "uvicorn.protocols.websockets.auto",
    "uvicorn.protocols.http.auto",
    "uvicorn.logging",
    "uvicorn.loops.auto",
    "uvicorn.protocols",
]
Пример #8
0
import os
import ctypes

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

binaries = []
pkg_base, pkg_dir = get_package_paths('flower')

binaries += [(os.path.join(pkg_dir, 'static'), 'flower/static')]
binaries += [(os.path.join(pkg_dir, 'templates'), 'flower/templates')]
binaries += [(os.path.join(pkg_dir, 'views'), 'flower/views')]

logger.warning(binaries)
#logger.warning(datas)
import os
from PyInstaller.utils.hooks import get_package_paths, is_module_satisfies
from PyInstaller.log import logger
from PyInstaller.compat import is_darwin

binaries = list()
if is_module_satisfies('pyinstaller >= 5.0'):
    from PyInstaller import isolated

    @isolated.decorate
    def get_safe_libs():
        from pypemicro import PyPemicro
        libs = PyPemicro.get_pemicro_lib_list()
        return libs

    pkg_base, pkg_dir = get_package_paths("pypemicro")
    for lib in get_safe_libs():
        source_path = lib['path']
        source_name = lib['name']
        dest = os.path.relpath(source_path, pkg_base)
        binaries.append((os.path.join(source_path, source_name), dest))
        if is_darwin:
            libusb = os.path.join(source_path, 'libusb.dylib')
            if os.path.exists(libusb):
                binaries.append((libusb, dest))
            else:
                logger.warning(
                    "libusb.dylib was not found for Mac OS, ignored")
else:
    logger.warning("hook-pypemicro requires pyinstaller >= 5.0")
Пример #10
0
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2016-2020, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
# -----------------------------------------------------------------------------
"""
text-unidecode:
https://github.com/kmike/text-unidecode/
"""

import os
from PyInstaller.utils.hooks import get_package_paths

package_path = get_package_paths("text_unidecode")
data_bin_path = os.path.join(package_path[1], "data.bin")

if os.path.exists(data_bin_path):
    datas = [(data_bin_path, 'text_unidecode')]
Пример #11
0
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, get_package_paths
import os

hiddenimports = (
collect_submodules('spacy') +
collect_submodules('spacy.lang.en') +
collect_submodules('thinc')
)
hiddenimports.append('spacy.strings')

pkg_base, pkg_dir = get_package_paths('spacy')
root_dir = pkg_dir

def recursive_walk(base_folder, parent_folder, base_prefix):
    result = []
    folder = os.path.join(base_folder, parent_folder)
    for folderName, subfolders, filenames in os.walk(folder):
        bn = os.path.basename(folderName)
        if subfolders:
            for subfolder in subfolders:
                pf = os.path.join(parent_folder, subfolder)
                r = recursive_walk(base_folder, pf, base_prefix)
                if r:
                    result = result + r
        for filename in filenames:
            i = len(base_folder)
Пример #12
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013-2018, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

from PyInstaller.utils.hooks import get_package_paths

datas = [(get_package_paths('torch')[1],"torch"),]
Пример #13
0
# Ensures that PyInstaller copies the CBC binaries for the mip library.
# See https://github.com/coin-or/python-mip/issues/76.
# Should become obsolete once https://github.com/pyinstaller/pyinstaller/pull/4762
# gets merged and makes it into the pyinstaller release.

import os
from PyInstaller.utils.hooks import get_package_paths

datas = []
_, mip_path = get_package_paths("mip")
lib_path = os.path.join(mip_path, "libraries")

for f in os.listdir(lib_path):
    if f.endswith(".so") or f.endswith(".dll") or f.endswith(".dylib"):
        datas.append((os.path.join(lib_path, f), "mip/libraries"))
Пример #14
0
import os.path
import glob

from PyInstaller.compat import is_win
from PyInstaller.utils.hooks import collect_dynamic_libs, get_package_paths

if is_win:
    # GDAL appears to need `_gdal.cp38-win_amd64.pyd` located specifically in
    # `osgeo/_gdal....pyd` in order to work.  This is because the GDAL python
    # __init__ script specifically looks in the `osgeo` directory in order to
    # find it.  This is apparently only an issue on Windows.
    #
    # This will take the dynamic libraries in osgeo and put them into osgeo,
    # relative to the binaries directory.
    binaries = collect_dynamic_libs('osgeo', 'osgeo')
    pkg_base, pkg_dir = get_package_paths('osgeo')
    for pyd_file in glob.glob(os.path.join(pkg_dir, '*.pyd')):
        binaries.append((pyd_file, 'osgeo'))
Пример #15
0
def collect_submodules_traitsui(package, filter=lambda name: True):
    # Accept only strings as packages.
    if not isinstance(package, string_types):
        raise ValueError

    logger.debug('Collecting submodules for %s' % package)
    # Skip a module which is not a package.
    if not is_package(package):
        logger.debug('collect_submodules - Module %s is not a package.' % package)
        return []

    # Determine the filesystem path to the specified package.
    pkg_base, pkg_dir = get_package_paths(package)

    # Walk the package. Since this performs imports, do it in a separate
    # process.
    names = exec_statement("""
        import sys
        import pkgutil

        def ignore_err(name, err):
            # Can't print anything because printing is captured as module names
            # print ("error importing %s: %s" % (name, err))
            pass

        # ``pkgutil.walk_packages`` doesn't walk subpackages of zipped files
        # per https://bugs.python.org/issue14209. This is a workaround.
        def walk_packages(path=None, prefix='', onerror=ignore_err):
            def seen(p, m={{}}):
                if p in m:
                    return True
                m[p] = True

            for importer, name, ispkg in pkgutil.iter_modules(path, prefix):
                if not name.startswith(prefix):   ## Added
                    name = prefix + name          ## Added
                yield importer, name, ispkg

                if ispkg:
                    try:
                        __import__(name)
                    except ImportError as e:
                        if onerror is not None:
                            onerror(name, e)
                    except Exception as e:
                        if onerror is not None:
                            onerror(name, e)
                        else:
                            raise
                    else:
                        path = getattr(sys.modules[name], '__path__', None) or []

                        # don't traverse path items we've seen before
                        path = [p for p in path if not seen(p)]

                        ## Use Py2 code here. It still works in Py3.
                        for item in walk_packages(path, name+'.', onerror):
                            yield item
                        ## This is the original Py3 code.
                        #yield from walk_packages(path, name+'.', onerror)

        for module_loader, name, ispkg in walk_packages([{}], '{}.'):
            print(name)
        """.format(
                  # Use repr to escape Windows backslashes.
                  repr(pkg_dir), package))

    # Include the package itself in the results.
    mods = {package}
    # Filter through the returend submodules.
    for name in names.split():
        if filter(name):
            mods.add(name)

    logger.debug("collect_submodules - Found submodules: %s", mods)
    return list(mods)
Пример #16
0
#
# See
# https://github.com/pyinstaller/pyinstaller/issues/1881
# https://github.com/pyinstaller/pyinstaller/issues/1969
# for more information
import os
import os.path
import re
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller import log as logging
from PyInstaller import compat

binaries = []

# look for libraries in numpy package path
pkg_base, pkg_dir = get_package_paths('numpy.core')
re_anylib = re.compile(r'\w+\.(?:dll|so|dylib)', re.IGNORECASE)
dlls_pkg = [f for f in os.listdir(pkg_dir) if re_anylib.match(f)]
binaries += [(os.path.join(pkg_dir, f), '.') for f in dlls_pkg]

# look for MKL libraries in pythons lib directory
# TODO: check numpy.__config__ if numpy is actually depending on MKL
# TODO: determine which directories are searched by the os linker
if compat.is_win:
    lib_dir = os.path.join(compat.base_prefix, "Library", "bin")
else:
    lib_dir = os.path.join(compat.base_prefix, "lib")
if os.path.isdir(lib_dir):
    re_mkllib = re.compile(r'^(?:lib)?mkl\w+\.(?:dll|so|dylib)', re.IGNORECASE)
    dlls_mkl = [f for f in os.listdir(lib_dir) if re_mkllib.match(f)]
    if dlls_mkl:
Пример #17
0
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
# -----------------------------------------------------------------------------

"""
sounddevice:
https://github.com/spatialaudio/python-sounddevice/
"""

import os

from PyInstaller.compat import is_darwin, is_win
from PyInstaller.utils.hooks import get_package_paths

sfp = get_package_paths("sounddevice")

path = None
if is_win:
    path = os.path.join(sfp[0], "_sounddevice_data", "portaudio-binaries")
elif is_darwin:
    path = os.path.join(
        sfp[0], "_sounddevice_data", "portaudio-binaries", "libportaudio.dylib"
    )

if path is not None and os.path.exists(path):
    binaries = [(path,
                 os.path.join("_sounddevice_data", "portaudio-binaries"))]
Пример #18
0
import sys
import PyInstaller
from PyInstaller.utils.hooks import is_module_satisfies, get_package_paths
from PyInstaller.compat import is_win, is_darwin, is_linux, is_py2
from PyInstaller import log as logging

# Constants
CEFPYTHON_MIN_VERSION = "57.0"
PYINSTALLER_MIN_VERSION = "3.2.1"

# Makes assumption that using "python.exe" and not "pyinstaller.exe"
# TODO: use this code to work cross-platform:
# > from PyInstaller.utils.hooks import get_package_paths
# > get_package_paths("cefpython3")

CEFPYTHON3_DIR = get_package_paths("cefpython3")[1]

CYTHON_MODULE_EXT = ".pyd" if is_win else ".so"

# Globals
logger = logging.getLogger(__name__)


# Functions
def check_platforms():
    if not is_win and not is_darwin and not is_linux:
        raise SystemExit("Error: Currently only Windows, Linux and Darwin "
                         "platforms are  supported, see Issue #135.")


def check_pyinstaller_version():
Пример #19
0
#-----------------------------------------------------------------------------
# Based on examples at https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/
#-----------------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files, exec_statement, copy_metadata,\
    collect_submodules, get_package_paths
import os.path

(_, obspy_root) = get_package_paths('obspy')

binaries = collect_dynamic_libs('obspy')
datas = [
    # Dummy path, this needs to exist for obspy.core.util.libnames._load_cdll
    (os.path.join(obspy_root, "*.txt"), os.path.join('obspy', 'core', 'util')),
    # Data
    (os.path.join(obspy_root, "imaging",
                  "data"), os.path.join('obspy', 'imaging', 'data')),
    (os.path.join(obspy_root, "taup",
                  "data"), os.path.join('obspy', 'taup', 'data')),
    (os.path.join(obspy_root, "geodetics",
                  "data"), os.path.join('obspy', 'geodetics', 'data')),
]

# Plugins are defined in the metadata (.egg-info) directory, but if we grab the whole thing it causes
# other errors, so include only entry_points.txt
metadata = copy_metadata('obspy')
egg = metadata[0]
if '.egg' not in egg[0]:
    raise Exception("Unexpected metadata: %s" % (metadata, ))
# Specify the source as just the entry points file
metadata = [(os.path.join(egg[0], 'entry_points.txt'), egg[1])]
"""
Hook manually adding orderedmultidict.__version__ which is missing
from the pyinstaller build for some reason
"""
from PyInstaller.utils.hooks import get_package_paths
datas = [(get_package_paths('orderedmultidict')[1] + "/__version__.py",
          'orderedmultidict')]
Пример #21
0
#-----------------------------------------------------------------------------
# Based on examples at https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/
#-----------------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files, exec_statement, copy_metadata,\
    collect_submodules, get_package_paths
import os.path

(_, obspy_root) = get_package_paths('obspy')

binaries = collect_dynamic_libs('obspy')
datas = [
    # Dummy path, this needs to exist for obspy.core.util.libnames._load_cdll
    (os.path.join(obspy_root, "*.txt"), os.path.join('obspy', 'core', 'util')),
    # Data
    (os.path.join(obspy_root, "imaging", "data"), os.path.join('obspy', 'imaging', 'data')),
    (os.path.join(obspy_root, "taup", "data"), os.path.join('obspy', 'taup', 'data')),
    (os.path.join(obspy_root, "geodetics", "data"), os.path.join('obspy', 'geodetics', 'data')),
]

# Plugins are defined in the metadata (.egg-info) directory, but if we grab the whole thing it causes
# other errors, so include only entry_points.txt
metadata = copy_metadata('obspy')
egg = metadata[0]
if '.egg' not in egg[0]:
    raise Exception("Unexpected metadata: %s" % (metadata,))
# Specify the source as just the entry points file
metadata = [(os.path.join(egg[0], 'entry_points.txt'), egg[1])]
datas += metadata

# Thse are the actual plugin packages
Пример #22
0
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------
import os

from PyInstaller.compat import is_win
from PyInstaller.utils.hooks import collect_submodules, is_module_satisfies, get_package_paths

hiddenimports = ['fractions'] + collect_submodules("av")

# Starting with av 9.1.1, the DLLs shipped with Windows PyPI wheels are stored
# in site-packages/av.libs instead of directly in the site-packages/av.
if is_module_satisfies("av >= 9.1.1") and is_win:
    pkg_base, pkg_dir = get_package_paths("av")
    lib_dir = os.path.join(pkg_base, "av.libs")
    if os.path.isdir(lib_dir):
        # We collect DLLs as data files instead of binaries to suppress binary
        # analysis, which would result in duplicates (because it collects a copy
        # into the top-level directory instead of preserving the original layout).
        # In addition to DLls, this also collects .load-order* file (required on
        # python < 3.8), and ensures that Shapely.libs directory exists (required
        # on python >= 3.8 due to os.add_dll_directory call).
        datas = [(os.path.join(lib_dir, lib_file), 'av.libs')
                 for lib_file in os.listdir(lib_dir)]
Пример #23
0
# ------------------------------------------------------------------
# Copyright (c) 2020 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import get_package_paths

datas = [
    (get_package_paths('torch')[1], "torch"),
]
Пример #24
0
def collect_submodules_traitsui(package, filter=lambda name: True):
    # Accept only strings as packages.
    if not isinstance(package, string_types):
        raise ValueError

    logger.debug('Collecting submodules for %s' % package)
    # Skip a module which is not a package.
    if not is_package(package):
        logger.debug('collect_submodules - Module %s is not a package.' %
                     package)
        return []

    # Determine the filesystem path to the specified package.
    pkg_base, pkg_dir = get_package_paths(package)

    # Walk the package. Since this performs imports, do it in a separate
    # process.
    names = exec_statement("""
        import sys
        import pkgutil

        def ignore_err(name, err):
            # Can't print anything because printing is captured as module names
            # print ("error importing %s: %s" % (name, err))
            pass

        # ``pkgutil.walk_packages`` doesn't walk subpackages of zipped files
        # per https://bugs.python.org/issue14209. This is a workaround.
        def walk_packages(path=None, prefix='', onerror=ignore_err):
            def seen(p, m={{}}):
                if p in m:
                    return True
                m[p] = True

            for importer, name, ispkg in pkgutil.iter_modules(path, prefix):
                if not name.startswith(prefix):   ## Added
                    name = prefix + name          ## Added
                yield importer, name, ispkg

                if ispkg:
                    try:
                        __import__(name)
                    except ImportError, e:
                        if onerror is not None:
                            onerror(name, e)
                    except Exception, e:
                        if onerror is not None:
                            onerror(name, e)
                        else:
                            raise
                    else:
                        path = getattr(sys.modules[name], '__path__', None) or []

                        # don't traverse path items we've seen before
                        path = [p for p in path if not seen(p)]

                        ## Use Py2 code here. It still works in Py3.
                        for item in walk_packages(path, name+'.', onerror):
                            yield item
                        ## This is the original Py3 code.
                        #yield from walk_packages(path, name+'.', onerror)

        for module_loader, name, ispkg in walk_packages([{}], '{}.'):
            print(name)
        """.format(
        # Use repr to escape Windows backslashes.
        repr(pkg_dir),
        package))

    # Include the package itself in the results.
    mods = {package}
    # Filter through the returend submodules.
    for name in names.split():
        if filter(name):
            mods.add(name)

    logger.debug("collect_submodules - Found submodules: %s", mods)
    return list(mods)
Пример #25
0
# *****************************************************
# hook-CodeChat.py - PyInstaller hook file for CodeChat
# *****************************************************
# PyInstaller can't find hidden imports (such as the
# dynamically-discovered plugins), not can it know about
# data files (such as ``.css`` files). This hook informs
# PyInstaller that these files must be included in the CodeChat
# bundle. See
# http://htmlpreview.github.io/?https://github.com/pyinstaller/pyinstaller/blob/develop/doc/Manual.html#using-hook-files
# for details.
from PyInstaller.utils.hooks import get_package_paths
import os.path

# The ``template/`` directory contains data files to be copied. Get an
# absolute path to the CodeChat directory containing it.
pkg_base, pkg_dir = get_package_paths('CodeChat')
# -------------Source files------------  -----dest path-----
datas = [(os.path.join(pkg_dir, 'template', '*'), 'CodeChat/template')]

# This isn't imported by CodeChat directly, so include it for Sphinx's use.
hiddenimports = ['CodeChat.CodeToRestSphinx']
Пример #26
0
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]
#-----------------------------------------------------------------------------
# Copyright (c) 2016-2020, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------
"""
enzyme:
https://github.com/Diaoul/enzyme
"""

import os
from PyInstaller.utils.hooks import get_package_paths

# get path of enzyme
ep = get_package_paths('enzyme')

# add the data
data = os.path.join(ep[1], 'parsers', 'ebml', 'specs', 'matroska.xml')
datas = [(data, "enzyme/parsers/ebml/specs")]
Пример #28
0
import os
import shutil
import PyInstaller.__main__
from PyInstaller.utils.hooks import get_package_paths

if __name__ == "__main__":
    assert os.path.isfile("ffmpeg\\bin\\ffmpeg.exe")
    assert os.path.isfile("en_v5.jit")
    assert os.path.isfile("application\\static\\favicon\\app-icon.ico")
    pytorch_libs = os.path.join(get_package_paths("torch")[1], "lib")
    PyInstaller.__main__.run([
        "main.py",
        "--onefile",
        "--clean",
        "--icon=application\\static\\favicon\\app-icon.ico",
        "--additional-hooks=extra-hooks",
        "--hidden-import=scipy.special.cython_special",
        "--add-data=application/static;application/static",
        "--add-data=alphabets;alphabets",
        "--add-data=training/hifigan;training/hifigan",
        "--add-data=ffmpeg/bin/ffmpeg.exe;.",
        "--add-data=en_v5.jit;.",
    ])
    shutil.rmtree("build")
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller.compat import is_win

datas = [(get_package_paths('torchvision')[1], "site-packages/torchvision"),
         (get_package_paths('torchvision')[1], "torchvision"),
         (get_package_paths('torch')[1], "site-packages/torch"),
         (get_package_paths('torch')[1], "torch")
         ] + ([(get_package_paths('mkl_fft')[1], "site-packages/mkl_fft"),
               (get_package_paths('mkl_fft')[1], "mkl_fft")] if is_win else [])
Пример #30
0
import os
import os.path
import re
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller import log as logging
from PyInstaller import compat

binaries = []

logger = logging.getLogger(__name__)
logger.info("Using custom numpy.core hook")


# look for libraries in numpy package path
pkg_base, pkg_dir = get_package_paths('numpy.core')
re_anylib = re.compile(r'\w+\.(?:dll|so|dylib)', re.IGNORECASE)
dlls_pkg = [f for f in os.listdir(pkg_dir) if re_anylib.match(f)]
binaries += [(os.path.join(pkg_dir, f), '') for f in dlls_pkg]

# look for MKL libraries in pythons lib directory
# TODO: check numpy.__config__ if numpy is actually depending on MKL
# TODO: determine which directories are searched by the os linker
if compat.is_win:
    lib_dir = os.path.join(compat.base_prefix, "Library", "bin")
else:
    lib_dir = os.path.join(compat.base_prefix, "lib")
if os.path.isdir(lib_dir):
    re_mkllib = re.compile(r'^(?:lib)?mkl\w+\.(?:dll|so|dylib)', re.IGNORECASE)
    dlls_mkl = [f for f in os.listdir(lib_dir) if re_mkllib.match(f)]
    if dlls_mkl:
Пример #31
0
#
# The botocore package is compatible with Python versions 2.6.5, Python 2.7.x,
# and Python 3.3.x and higher.
#
# https://botocore.readthedocs.org/en/latest/
#
# Tested with botocore 1.4.36

import os.path
from PyInstaller.utils.hooks import get_package_paths
try:
    from PyInstaller.compat import is_py2
except ImportError:
    import sys
    is_py2 = sys.version[0] == 2

from PyInstaller.utils.hooks import is_module_satisfies

if is_module_satisfies('botocore >= 1.4.36'):
    if is_py2:
        hiddenimports = ['HTMLParser']
    else:
        hiddenimports = ['html.parser']


pkg_base, pkg_dir = get_package_paths('botocore')

datas = [(os.path.join(pkg_dir, "cacert.pem"), 'botocore'),
         (os.path.join(pkg_dir, "data", "*.json"), 'botocore/data'),
         (os.path.join(pkg_dir, "data", "ec2", "2016-11-15"), 'botocore/data/ec2/2016-11-15')]
Пример #32
0
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

import os

from PyInstaller.utils.hooks import get_package_paths
from PyInstaller.utils.hooks import is_module_satisfies
from PyInstaller import compat

# Necessary when using the vectorized subpackage
hiddenimports = ['shapely.prepared']

pkg_base, pkg_dir = get_package_paths('shapely')

binaries = []
if compat.is_win:
    if compat.is_conda:
        lib_dir = os.path.join(compat.base_prefix, 'Library', 'bin')
    else:
        lib_dir = os.path.join(pkg_dir, 'DLLs')
    dll_files = ['geos_c.dll', 'geos.dll']
    binaries += [(os.path.join(lib_dir, f), '.') for f in dll_files]
elif compat.is_linux:
    lib_dir = os.path.join(pkg_dir, '.libs')
    dest_dir = os.path.join('shapely', '.libs')

    # This duplicates the libgeos*.so* files in the build.  PyInstaller will
    # copy them into the root of the build by default, but shapely cannot load
Пример #33
0
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller.compat import is_linux

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


def remove_prefix(string, prefix):
    if string.startswith(prefix):
        return string[len(prefix):]
    else:
        return string


if is_linux:
    pkg_base, pkg_dir = get_package_paths('tensorflow.contrib')
    # Walk through all file in the given package, looking for data files.
    _datas = []
    for dirpath, dirnames, files in os.walk(pkg_dir):
        for f in files:
            extension = os.path.splitext(f)[1]
            print(extension)
            if extension in ['.so']:
                source = os.path.join(dirpath, f)
                dest = remove_prefix(dirpath,
                                     os.path.dirname(pkg_base) + os.sep)
                _datas.append((source, dest))
    #datas = collect_native_files('tensorflow.contrib.bigtable.python.ops', ['_bigtable.so'])
    print(_datas)
    datas = _datas