def a_pyz_exe(): root = Path(__file__).parents[3] block_cipher = None datas = [(file_path, str(file_path.parent.relative_to(root))) for file_path in get_data_paths()] hiddenimports = [*collect_submodules(), 'babel.numbers'] a = Analysis(['betty/_package/pyinstaller/main.py'], pathex=['./'], binaries=[], datas=datas, hiddenimports=hiddenimports, hookspath=[str(HOOKS_DIRECTORY_PATH)], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='betty', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=False, icon=str(ROOT_DIRECTORY_PATH / 'betty' / 'assets' / 'public' / 'static' / 'betty.ico')) return a, pyz, exe
def test_issue_2492(monkeypatch, tmpdir): # Crash if an extension module has an hidden import to ctypes (e.g. added # by the hook). # Need to set up some values monkeypatch.setattr( 'PyInstaller.config.CONF', { 'workpath': str(tmpdir), 'spec': str(tmpdir), 'warnfile': str(tmpdir.join('warn.txt')), 'dot-file': str(tmpdir.join('imports.dot')), 'xref-file': str(tmpdir.join('imports.xref')), 'hiddenimports': [], 'specnm': 'issue_2492_script' }) # Speedup: avoid analyzing base_library.zip monkeypatch.setattr(analysis, 'PY3_BASE_MODULES', []) script = tmpdir.join('script.py') script.write('import _struct') # create a hook tmpdir.join('hook-_struct.py').write('hiddenimports = ["ctypes"]') a = Analysis([str(script)], hookspath=[str(tmpdir)], excludes=['encodings', 'pydoc', 'xml', 'distutils'])
def speed_pefile(): log.logging.basicConfig(level=log.DEBUG) tempdir = mkdtemp("speed_pefile") workdir = join(tempdir, "build") distdir = join(tempdir, "dist") script = join(tempdir, 'speed_pefile_script.py') warnfile = join(workdir, 'warn.txt') os.makedirs(workdir) os.makedirs(distdir) with open(script, 'w') as f: f.write(''' from PySide2 import QtCore from PySide2 import QtGui ''') CONF['workpath'] = workdir CONF['distpath'] = distdir CONF['warnfile'] = warnfile CONF['hiddenimports'] = [] CONF['spec'] = join(tempdir, 'speed_pefile_script.spec') CONF['specpath'] = tempdir CONF['specnm'] = 'speed_pefile_script' start = time.time() a = Analysis([script]) duration = time.time() - start logger.warn("Analysis duration: %s", duration) shutil.rmtree(tempdir, ignore_errors=True)
def test_issue_5131(monkeypatch, tmpdir): """ While fixing the endless recursion when the package's __init__ module is an extension (see tests/unit/test_modulegraph_more.py::package_init_is_extension_*), another error occured: PyInstaller.building._utils._load_code() tried to complote the source code for extension module - triggered by PYZ.assemble(), which is collecting all source files - caused by this being marked as "PYMODULE" in the TOC. """ def getImports(*args, **kwargs): # Our faked binary does not match the expected file-format for all # platforms, thus the resp. code might crash. Simply ignore this. try: return orig_getImports(*args, **kwargs) except: # noqa return [] monkeypatch.setattr( 'PyInstaller.config.CONF', { 'workpath': str(tmpdir), 'spec': str(tmpdir), 'warnfile': str(tmpdir.join('warn.txt')), 'dot-file': str(tmpdir.join('imports.dot')), 'xref-file': str(tmpdir.join('imports.xref')), 'hiddenimports': [], 'specnm': 'issue_5131_script' }) # Speedup: avoid analyzing base_library.zip monkeypatch.setattr(analysis, 'PY3_BASE_MODULES', []) orig_getImports = bindepend.getImports monkeypatch.setattr(bindepend, "getImports", getImports) pkg = (tmpdir / 'mypkg').mkdir() init = pkg / ('__init__' + EXTENSION_SUFFIXES[0]) init.write_binary(b'\0\0\0\0\0\0\0\0\0\0\0\0' * 20) script = tmpdir.join('script.py') script.write('import mypkg') a = Analysis([str(script)], excludes=['encodings', 'pydoc', 'xml', 'distutils']) PYZ(a.pure, a.zipped_data)
# -*- mode: python -*- from PyInstaller.building.api import PYZ, EXE, COLLECT from PyInstaller.building.build_main import Analysis block_cipher = None a = Analysis([ 'main.py', 'monitor.py', 'D:\\users\lenovo\PyQt5\综合应用\getCityWeather\CallWeatherWin.py', 'D:\\users\lenovo\PyQt5\综合应用\getCityWeather\WeatherWin.py', 'D:\\users\lenovo\PyQt5\综合应用\getCityWeather\images_rc.py' ], pathex=['test_wpf_python_msg'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, exclude_binaries=True, name='main', debug=False, strip=False, upx=True, console=True)
UPX = True BASENAME = 'metreload' name_with_version = '{}-{}'.format(BASENAME, version) # pylint: disable=C0103 # Do analysis a = Analysis(['metreload/cli.py'], pathex=[], binaries=[], datas=copy_metadata('pydap')\ + collect_data_files('distributed')\ + collect_data_files('dask')\ + [('docs/_build/html', 'documentation')], hiddenimports=['pandas._libs.tslibs.np_datetime', 'pandas._libs.skiplist', 'pydap.responses.das', 'pydap.responses.html', 'pydap.responses.ascii', 'pydap.responses.version'], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=BLOCK_CIPHER) pyz = PYZ(a.pure, a.zipped_data, cipher=BLOCK_CIPHER) options = dict(strip=False, upx=UPX) exe_options = dict(name=BASENAME, debug=False, console=True)