def get_qt_conf_file(qt_library_info): # No-op if requested Qt-based package is not available if qt_library_info.version is None: return [] # Find ``qt.conf`` in location['PrefixPath'] datas = [x for x in hooks.collect_system_data_files( qt_library_info.location['PrefixPath'], qt_library_info.qt_rel_dir) if os.path.basename(x[0]) == 'qt.conf'] return datas
def collect_glib_etc_files(*path): """path is relative to the system config directory (eg, /etc)""" glib_config_dirs = get_glib_sysconf_dirs() if glib_config_dirs is None: return [] destdir = os.path.join('etc', *path) # TODO: will this return too much? collected = [] for config_dir in glib_config_dirs: p = os.path.join(config_dir, *path) collected += collect_system_data_files(p, destdir=destdir, include_py_files=False) return collected
def collect_glib_share_files(*path): """path is relative to the system data directory (eg, /usr/share)""" glib_data_dirs = get_glib_system_data_dirs() if glib_data_dirs is None: return [] destdir = os.path.join('share', *path) # TODO: will this return too much? collected = [] for data_dir in glib_data_dirs: p = os.path.join(data_dir, *path) collected += collect_system_data_files(p, destdir=destdir, include_py_files=False) return collected
if compat.is_win: rel_data_path = ['PySide2'] else: rel_data_path = ['PySide2', 'Qt'] pyside2_locations = pyside2_library_info.location if compat.is_darwin: # This is based on the layout of the Mac wheel from PyPi. data_path = pyside2_locations['DataPath'] libraries = [ 'QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtNetwork', 'QtGui', 'QtWebChannel', 'QtPositioning' ] for i in libraries: datas += collect_system_data_files( os.path.join(data_path, 'lib', i + '.framework'), prefix_with_path(rel_data_path, 'lib'), True) datas += [(os.path.join(data_path, 'lib', 'QtWebEngineCore.framework', 'Resources'), os.curdir)] else: locales = 'qtwebengine_locales' resources = 'resources' datas += [ # Gather translations needed by Chromium. (os.path.join(pyside2_locations['TranslationsPath'], locales), prefix_with_path(rel_data_path, 'translations', locales)), # Per the `docs # <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_, # ``DataPath`` is the base directory for ``resources``. # (os.path.join(pyside2_locations['DataPath'],
# 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) #----------------------------------------------------------------------------- import os from PyInstaller.utils.hooks import collect_system_data_files from PyInstaller.utils.hooks.qt import pyqt5_library_info, get_qt_binaries # Ensure PyQt5 is importable before adding info depending on it. if pyqt5_library_info.version: hiddenimports = [ # PyQt5.10 and earlier uses sip in an separate package; 'sip', # PyQt5.11 and later provides SIP in a private package. Support both. 'PyQt5.sip' ] # Collect the ``qt.conf`` file. datas = [ x for x in collect_system_data_files( pyqt5_library_info.location['PrefixPath'], 'PyQt5') if os.path.basename(x[0]) == 'qt.conf' ] # Collect required Qt binaries. binaries = get_qt_binaries(pyqt5_library_info)
def get_qt_webengine_binaries_and_data_files(qt_library_info): binaries = [] datas = [] # Output directory (varies between PyQt and PySide and among OSes; the difference is abstracted by # qt_library_info.qt_rel_dir) rel_data_path = qt_library_info.qt_rel_dir if compat.is_darwin: # On macOS, Qt shared libraries are provided in form of .framework bundles. However, PyInstaller collects shared # library from the bundle into top-level application directory, breaking the bundle structure. # # QtWebEngine and its underlying Chromium engine, however, have very strict data file layout requirements due to # sandboxing, and does not work if the helper process executable does not load the shared library from # QtWebEngineCore.framework (which also needs to contain all resources). # # Therefore, we collect the QtWebEngineCore.framework manually, in order to obtain a working QtWebEngineProcess # helper executable. But because that bypasses our dependency scanner, we need to collect the dependent # .framework bundles as well. And we need to override QTWEBENGINEPROCESS_PATH in rthook, because the # QtWebEngineWidgets python extension actually loads up the copy of shared library that is located in # sys._MEIPASS (as opposed to the manually-copied one in .framework bundle). Furthermore, because the extension # modules use Qt shared libraries in sys._MEIPASS, we also copy all contents of # QtWebEngineCore.framework/Resources into sys._MEIPASS to make resource loading in the main process work. # # Besides being ugly, this approach has three main ramifications: # 1. we bundle two copies of each Qt shared library involved: the copy used by main process, picked up by # dependency scanner; and a copy in manually-collected .framework bundle that is used by the helper process. # 2. the trick with copying contents of Resource directory of QtWebEngineCore.framework does not work in onefile # mode, and consequently QtWebEngine does not work in onefile mode. # 3. copying contents of QtWebEngineCore.framework/Resource means that its Info.plist ends up in sys._MEIPASS, # causing the main process in onedir mode to be mis-identified as "QtWebEngineProcess". # # In the near future, this quagmire will hopefully be properly sorted out, but in the mean time, we have to live # with what we have been given. data_path = qt_library_info.location['DataPath'] libraries = [ 'QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtQmlModels', 'QtNetwork', 'QtGui', 'QtWebChannel', 'QtPositioning' ] for i in libraries: framework_dir = i + '.framework' datas += hooks.collect_system_data_files( os.path.join(data_path, 'lib', framework_dir), os.path.join(rel_data_path, 'lib', framework_dir), True) datas += [(os.path.join(data_path, 'lib', 'QtWebEngineCore.framework', 'Resources'), os.curdir)] else: # Windows and linux locales = 'qtwebengine_locales' resources = 'resources' # Translations datas.append(( os.path.join(qt_library_info.location['TranslationsPath'], locales), os.path.join(rel_data_path, 'translations', locales), )) # Resources; ``DataPath`` is the base directory for ``resources``, as per the # `docs <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_. datas.append( (os.path.join(qt_library_info.location['DataPath'], resources), os.path.join(rel_data_path, resources)), ) # Helper process executable (QtWebEngineProcess), located in ``LibraryExecutablesPath``. dest = os.path.join( rel_data_path, os.path.relpath(qt_library_info.location['LibraryExecutablesPath'], qt_library_info.location['PrefixPath'])) datas.append( (os.path.join(qt_library_info.location['LibraryExecutablesPath'], 'QtWebEngineProcess*'), dest)) # Add Linux-specific libraries. if compat.is_linux: # The automatic library detection fails for `NSS <https://packages.ubuntu.com/search?keywords=libnss3>`_, which # is used by QtWebEngine. In some distributions, the ``libnss`` supporting libraries are stored in a # subdirectory ``nss``. Since ``libnss`` is not statically linked to these, but dynamically loads them, we need # to search for and add them. # First, get all libraries linked to ``QtWebEngineWidgets`` extension module. module_file = hooks.get_module_file_attribute( qt_library_info.namespace + '.QtWebEngineWidgets') module_imports = bindepend.getImports(module_file) for imp in module_imports: # Look for ``libnss3.so``. if os.path.basename(imp).startswith('libnss3.so'): # Find the location of NSS: given a ``/path/to/libnss.so``, add ``/path/to/nss/*.so`` to get the # missing NSS libraries. nss_glob = os.path.join(os.path.dirname(imp), 'nss', '*.so') if glob.glob(nss_glob): binaries.append((nss_glob, 'nss')) return binaries, datas
# 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 collect_system_data_files from PyInstaller.utils.hooks.qt import pyside2_library_info, get_qt_binaries from PyInstaller.compat import is_win # Only proceed if PySide2 can be imported. if pyside2_library_info.version: hiddenimports = ['shiboken2'] # Collect the ``qt.conf`` file. if is_win: target_qt_conf_dir = ['PySide2'] else: target_qt_conf_dir = ['PySide2', 'Qt'] datas = [ x for x in collect_system_data_files( pyside2_library_info.location['PrefixPath'], os.path.join(*target_qt_conf_dir)) if os.path.basename(x[0]) == 'qt.conf' ] # Collect required Qt binaries. binaries = get_qt_binaries(pyside2_library_info)
from PyInstaller.compat import is_darwin import os if is_darwin: # Assume we're using homebrew to install GDAL and collect data files # accordingly. from PyInstaller.utils.hooks import get_homebrew_path from PyInstaller.utils.hooks import collect_system_data_files datas = collect_system_data_files(path=os.path.join( get_homebrew_path('gdal'), 'share', 'gdal'), destdir='gdal-data')
# Ensure PyQt5 is importable before adding info depending on it. if pyqt5_library_info.version: hiddenimports, binaries, datas = add_qt5_dependencies(__file__) # Include the web engine process, translations, and resources. rel_data_path = ['PyQt5', 'Qt'] if compat.is_darwin: # This is based on the layout of the Mac wheel from PyPi. data_path = pyqt5_library_info.location['DataPath'] libraries = [ 'QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtNetwork', 'QtGui', 'QtWebChannel', 'QtPositioning' ] for i in libraries: datas += collect_system_data_files( os.path.join(data_path, 'lib', i + '.framework'), os.path.join(*(rel_data_path + ['lib'])), True) datas += [(os.path.join(data_path, 'lib', 'QtWebEngineCore.framework', 'Resources'), os.curdir)] else: locales = 'qtwebengine_locales' resources = 'resources' datas += [ # Gather translations needed by Chromium. (os.path.join(pyqt5_library_info.location['TranslationsPath'], locales), os.path.join('PyQt5', 'Qt', 'translations', locales)), # Per the `docs <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_, # ``DataPath`` is the base directory for ``resources``. # # When Python 3.4 goes EOL (see `PEP 448`_, this is better written as
# ----------------------------------------------------------------------------- # Copyright (c) 2005-2019, 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. # ----------------------------------------------------------------------------- import os.path from PyInstaller.utils.hooks import collect_system_data_files from PyInstaller.utils.hooks.qt import pyside2_library_info, get_qt_binaries hiddenimports = ['shiboken2'] # Collect the ``qt.conf`` file. datas = [x for x in collect_system_data_files(pyside2_library_info.location['PrefixPath'], 'PySide2') if os.path.basename(x[0]) == 'qt.conf'] # Collect required Qt binaries. binaries = get_qt_binaries(pyside2_library_info)
# 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) #----------------------------------------------------------------------------- import os from PyInstaller.utils.hooks import collect_system_data_files from PyInstaller.utils.hooks.qt import pyqt5_library_info, get_qt_binaries # Ensure PyQt5 is importable before adding info depending on it. if pyqt5_library_info.version is not None: hiddenimports = [ # PyQt5.10 and earlier uses sip in an separate package; 'sip', # PyQt5.11 and later provides SIP in a private package. Support both. 'PyQt5.sip' ] # Collect the ``qt.conf`` file. datas = [ x for x in collect_system_data_files( pyqt5_library_info.location['PrefixPath'], os.path.join('PyQt5', 'Qt')) if os.path.basename(x[0]) == 'qt.conf' ] # Collect required Qt binaries. binaries = get_qt_binaries(pyqt5_library_info)
import pkg_resources from PyInstaller.utils.hooks import collect_system_data_files path = pkg_resources.resource_filename('tornado_swagger_ui', '') datas = ( collect_system_data_files(path) )
# Copyright (c) 2005-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) #----------------------------------------------------------------------------- import os from PyInstaller.utils.hooks import collect_system_data_files from PyInstaller.utils.hooks.qt import pyside2_library_info, get_qt_binaries from PyInstaller.compat import is_win hiddenimports = ['shiboken2'] # Collect the ``qt.conf`` file. if is_win: target_qt_conf_dir = os.curdir else: target_qt_conf_dir = 'PySide2' datas = [x for x in collect_system_data_files(pyside2_library_info.location['PrefixPath'], target_qt_conf_dir) if os.path.basename(x[0]) == 'qt.conf'] # Collect required Qt binaries. binaries = get_qt_binaries(pyside2_library_info)
# Ensure PyQt5 is importable before adding info depending on it. if pyqt5_library_info.version is not None: hiddenimports, binaries, datas = add_qt5_dependencies(__file__) # Include the web engine process, translations, and resources. rel_data_path = ['PyQt5', 'Qt'] if compat.is_darwin: # This is based on the layout of the Mac wheel from PyPi. data_path = pyqt5_library_info.location['DataPath'] libraries = ['QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtQmlModels', 'QtNetwork', 'QtGui', 'QtWebChannel', 'QtPositioning'] for i in libraries: framework_dir = i + '.framework' datas += collect_system_data_files( os.path.join(data_path, 'lib', framework_dir), os.path.join(*rel_data_path, 'lib', framework_dir), True) datas += [(os.path.join(data_path, 'lib', 'QtWebEngineCore.framework', 'Resources'), os.curdir)] else: locales = 'qtwebengine_locales' resources = 'resources' datas += [ # Gather translations needed by Chromium. (os.path.join(pyqt5_library_info.location['TranslationsPath'], locales), os.path.join('PyQt5', 'Qt', 'translations', locales)), # Per the `docs <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_, # ``DataPath`` is the base directory for ``resources``. # # When Python 3.4 goes EOL (see `PEP 448`_, this is better written as
from PyInstaller.compat import is_darwin from PyInstaller.utils.hooks import (collect_system_data_files, collect_data_files, collect_submodules) import os if is_darwin: # Assume we're using a local conda env to install gdal. # glob for gcs.csv instead of passing the env name. import glob datas = collect_system_data_files(path=os.path.dirname( glob.glob('**/gcs.csv', recursive=True)[0]), destdir='gdal-data') else: datas = collect_data_files('osgeo')
# Include the web engine process, translations, and resources. # According to https://bugreports.qt.io/browse/PYSIDE-642?focusedCommentId=461015&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-461015, # there's no subdir for windows rel_data_path = ['PySide2' ] if sys.platform == 'win32' else ['PySide2', 'Qt'] if compat.is_darwin: # This is based on the layout of the Mac wheel from PyPi. data_path = pyside2_library_info.location['DataPath'] libraries = [ 'QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtNetwork', 'QtGui', 'QtWebChannel', 'QtPositioning' ] for i in libraries: datas += collect_system_data_files( os.path.join(data_path, 'lib', i + '.framework'), os.path.join(*(rel_data_path + ['lib'])), True) datas += [(os.path.join(data_path, 'lib', 'QtWebEngineCore.framework', 'Resources'), os.curdir)] else: locales = 'qtwebengine_locales' resources = 'resources' datas += [ # Gather translations needed by Chromium. (os.path.join(pyside2_library_info.location['TranslationsPath'], locales), os.path.join(*(rel_data_path + ['translations', locales]))), # Per the `docs <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_, # ``DataPath`` is the base directory for ``resources``. # # When Python 3.4 goes EOL (see `PEP 448`_, this is better written as
import PyInstaller.compat as compat hiddenimports, binaries, datas = add_qt5_dependencies(__file__) # Include the web engine process, translations, and resources. rel_data_path = ['PyQt5', 'Qt'] if compat.is_darwin: # This is based on the layout of the Mac wheel from PyPi. data_path = pyqt5_library_info.location['DataPath'] resources = ['lib', 'QtWebEngineCore.framework', 'Resources'] web_engine_process = ['lib', 'QtWebEngineCore.framework', 'Helpers'] # When Python 3.4 goes EOL (see # `PEP 448 <https://www.python.org/dev/peps/pep-0448/>`_, this is # better written as ``os.path.join(*rel_data_path, *resources[:-1])``. datas += collect_system_data_files( os.path.join(data_path, *resources), os.path.join(*(rel_data_path + resources[:-1])), True) datas += collect_system_data_files( os.path.join(data_path, *web_engine_process), os.path.join(*(rel_data_path + web_engine_process[:-1])), True) else: locales = 'qtwebengine_locales' resources = 'resources' datas += [ # Gather translations needed by Chromium. (os.path.join(pyqt5_library_info.location['TranslationsPath'], locales), os.path.join('PyQt5', 'Qt', 'translations', locales)), # Per the `docs <https://doc.qt.io/qt-5.10/qtwebengine-deploying.html#deploying-resources>`_, # ``DataPath`` is the base directory for ``resources``. #