From e3dc46a8cd835671ff2a5a85ef9fcbfa70030f5e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 25 Nov 2016 16:46:49 +0100 Subject: [PATCH] fix pyinstaller (#1788) --- .../hook-mitmproxy.addons.onboardingapp.py | 3 +++ release/hooks/hook-pydivert.py | 3 +++ release/rtool.py | 22 ++++++++++++++---- release/setup.py | 6 ++--- release/specs/mitmdump.spec | 23 ------------------- release/specs/mitmproxy.spec | 23 ------------------- release/specs/mitmweb.spec | 23 ------------------- release/specs/pathoc.spec | 23 ------------------- release/specs/pathod.spec | 23 ------------------- 9 files changed, 27 insertions(+), 122 deletions(-) create mode 100644 release/hooks/hook-mitmproxy.addons.onboardingapp.py create mode 100644 release/hooks/hook-pydivert.py delete mode 100644 release/specs/mitmdump.spec delete mode 100644 release/specs/mitmproxy.spec delete mode 100644 release/specs/mitmweb.spec delete mode 100644 release/specs/pathoc.spec delete mode 100644 release/specs/pathod.spec diff --git a/release/hooks/hook-mitmproxy.addons.onboardingapp.py b/release/hooks/hook-mitmproxy.addons.onboardingapp.py new file mode 100644 index 000000000..1587f40a9 --- /dev/null +++ b/release/hooks/hook-mitmproxy.addons.onboardingapp.py @@ -0,0 +1,3 @@ +from PyInstaller.utils.hooks import collect_data_files + +datas = collect_data_files('mitmproxy.addons.onboardingapp') \ No newline at end of file diff --git a/release/hooks/hook-pydivert.py b/release/hooks/hook-pydivert.py new file mode 100644 index 000000000..3fe8c5520 --- /dev/null +++ b/release/hooks/hook-pydivert.py @@ -0,0 +1,3 @@ +from PyInstaller.utils.hooks import collect_data_files + +datas = collect_data_files('pydivert.windivert_dll') \ No newline at end of file diff --git a/release/rtool.py b/release/rtool.py index fbca40e23..3bc3fdaa7 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -40,6 +40,8 @@ BUILD_DIR = join(RELEASE_DIR, "build") DIST_DIR = join(RELEASE_DIR, "dist") PYINSTALLER_SPEC = join(RELEASE_DIR, "specs") +# PyInstaller 3.2 does not bundle pydivert's Windivert binaries +PYINSTALLER_HOOKS = join(RELEASE_DIR, "hooks") PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller") PYINSTALLER_DIST = join(BUILD_DIR, "binaries") @@ -166,7 +168,7 @@ def make_wheel(): print("Creating wheel...") subprocess.check_call( [ - "python", "./setup.py", "-q", + "python3", "./setup.py", "-q", "bdist_wheel", "--dist-dir", DIST_DIR, "--universal" ], cwd=ROOT_DIR @@ -175,7 +177,7 @@ def make_wheel(): print("Creating virtualenv for test install...") if exists(VENV_DIR): shutil.rmtree(VENV_DIR) - subprocess.check_call(["virtualenv", "-q", VENV_DIR]) + subprocess.check_call(["python3", "-m", "virtualenv", "-q", VENV_DIR]) with chdir(DIST_DIR): print("Install wheel into virtualenv...") @@ -198,7 +200,11 @@ def make_wheel(): @cli.command("bdist") @click.option("--use-existing-wheel/--no-use-existing-wheel", default=False) -@click.argument("pyinstaller_version", envvar="PYINSTALLER_VERSION", default="PyInstaller~=3.1.1") +@click.argument( + "pyinstaller_version", + envvar="PYINSTALLER_VERSION", + default="git+https://github.com/pyinstaller/pyinstaller.git@483c819d6a256b58db6740696a901bd41c313f0c" +) @click.argument("setuptools_version", envvar="SETUPTOOLS_VERSION", default="setuptools>=25.1.0,!=25.1.1") @click.pass_context def make_bdist(ctx, use_existing_wheel, pyinstaller_version, setuptools_version): @@ -230,12 +236,20 @@ def make_bdist(ctx, use_existing_wheel, pyinstaller_version, setuptools_version) "--clean", "--workpath", PYINSTALLER_TEMP, "--distpath", PYINSTALLER_DIST, + "--additional-hooks-dir", PYINSTALLER_HOOKS, + # PyInstaller 3.2 does not handle Python 3.5's ucrt correctly. + "-p", r"C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86", + "--onefile", + "--console", + "--icon", "icon.ico", # This is PyInstaller, so setting a # different log level obviously breaks it :-) # "--log-level", "WARN", - "%s.spec" % tool + tool ] ) + # Delete the spec file - we're good without. + os.remove("{}.spec".format(tool)) # Test if it works at all O:-) executable = join(PYINSTALLER_DIST, tool) diff --git a/release/setup.py b/release/setup.py index 5781ff9ba..d784a4a5b 100644 --- a/release/setup.py +++ b/release/setup.py @@ -6,10 +6,10 @@ setup( py_modules=["rtool"], install_requires=[ "click>=6.2, <7.0", - "twine>=1.6.5, <1.8", - "virtualenv>=14.0.5, <15.1", + "twine>=1.6.5, <1.9", + "virtualenv>=14.0.5, <15.2", "wheel>=0.29.0, <0.30", - "pysftp>=0.2.8, !=0.2.9, <0.3", + "pysftp==0.2.8", ], entry_points={ "console_scripts": [ diff --git a/release/specs/mitmdump.spec b/release/specs/mitmdump.spec deleted file mode 100644 index 5314137d9..000000000 --- a/release/specs/mitmdump.spec +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: python -*- - -from PyInstaller.utils.hooks import collect_data_files - -a = Analysis(['mitmdump'], - binaries=None, - datas=collect_data_files("mitmproxy.addons.onboardingapp"), - hiddenimports=[], - hookspath=None, - runtime_hooks=None, - excludes=None) -pyz = PYZ(a.pure, a.zipped_data) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='mitmdump', - debug=False, - strip=None, - upx=True, - console=True, - icon='icon.ico' ) diff --git a/release/specs/mitmproxy.spec b/release/specs/mitmproxy.spec deleted file mode 100644 index b0141e5ec..000000000 --- a/release/specs/mitmproxy.spec +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: python -*- - -from PyInstaller.utils.hooks import collect_data_files - -a = Analysis(['mitmproxy'], - binaries=None, - datas=collect_data_files("mitmproxy.addons.onboardingapp"), - hiddenimports=[], - hookspath=None, - runtime_hooks=None, - excludes=None) -pyz = PYZ(a.pure, a.zipped_data) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='mitmproxy', - debug=False, - strip=None, - upx=True, - console=True, - icon='icon.ico' ) diff --git a/release/specs/mitmweb.spec b/release/specs/mitmweb.spec deleted file mode 100644 index ea6192a4e..000000000 --- a/release/specs/mitmweb.spec +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: python -*- - -from PyInstaller.utils.hooks import collect_data_files - -a = Analysis(['mitmweb'], - binaries=None, - datas=collect_data_files("mitmproxy"), - hiddenimports=[], - hookspath=None, - runtime_hooks=None, - excludes=None) -pyz = PYZ(a.pure, a.zipped_data) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='mitmweb', - debug=False, - strip=None, - upx=True, - console=True, - icon='icon.ico' ) diff --git a/release/specs/pathoc.spec b/release/specs/pathoc.spec deleted file mode 100644 index d4f4d0d99..000000000 --- a/release/specs/pathoc.spec +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: python -*- - -from PyInstaller.utils.hooks import collect_data_files - -a = Analysis(['pathoc'], - binaries=None, - datas=None, - hiddenimports=['_cffi_backend'], - hookspath=None, - runtime_hooks=None, - excludes=None) -pyz = PYZ(a.pure, a.zipped_data) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='pathoc', - debug=False, - strip=None, - upx=True, - console=True, - icon='icon.ico' ) diff --git a/release/specs/pathod.spec b/release/specs/pathod.spec deleted file mode 100644 index f3a977f2b..000000000 --- a/release/specs/pathod.spec +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: python -*- - -from PyInstaller.utils.hooks import collect_data_files - -a = Analysis(['pathod'], - binaries=None, - datas=collect_data_files("pathod"), - hiddenimports=['_cffi_backend'], - hookspath=None, - runtime_hooks=None, - excludes=None) -pyz = PYZ(a.pure, a.zipped_data) -exe = EXE(pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - name='pathod', - debug=False, - strip=None, - upx=True, - console=True, - icon='icon.ico' )