pyinstaller: move hooks into package

This commit is contained in:
Maximilian Hils 2022-06-28 13:38:12 +02:00
parent 661b756520
commit 87d3d1cb88
8 changed files with 11 additions and 6 deletions

View file

@ -0,0 +1,7 @@
from pathlib import Path
here = Path(__file__).parent.absolute()
def hook_dirs() -> list[str]:
return [here]

View file

@ -357,7 +357,6 @@ def build_pyinstaller(be: BuildEnviron) -> None: # pragma: no cover
click.echo("Building pyinstaller package...")
PYINSTALLER_SPEC = be.release_dir / "specs"
PYINSTALLER_HOOKS = be.release_dir / "hooks"
PYINSTALLER_TEMP = be.build_dir / "pyinstaller"
PYINSTALLER_DIST = be.build_dir / "binaries" / be.platform_tag
@ -407,8 +406,6 @@ def build_pyinstaller(be: BuildEnviron) -> None: # pragma: no cover
PYINSTALLER_TEMP,
"--distpath",
PYINSTALLER_DIST,
"--additional-hooks-dir",
PYINSTALLER_HOOKS,
"--onefile",
"--console",
"--icon",

View file

@ -3,8 +3,6 @@ from pathlib import Path
from PyInstaller.building.api import PYZ, EXE, COLLECT
from PyInstaller.building.build_main import Analysis
assert SPECPATH == "."
here = Path(r".")
tools = ["mitmproxy", "mitmdump", "mitmweb"]
@ -12,7 +10,6 @@ analysis = Analysis(
tools,
excludes=["tcl", "tk", "tkinter"],
pathex=[str(here)],
hookspath=[str(here / ".." / "hooks")],
)
pyz = PYZ(analysis.pure, analysis.zipped_data)

View file

@ -63,6 +63,9 @@ setup(
"mitmproxy = mitmproxy.tools.main:mitmproxy",
"mitmdump = mitmproxy.tools.main:mitmdump",
"mitmweb = mitmproxy.tools.main:mitmweb",
],
"pyinstaller40": [
"hook-dirs = mitmproxy.utils.pyinstaller:hook_dirs",
]
},
python_requires=">=3.9",

View file

@ -16,6 +16,7 @@ def check_src_files_have_test():
"mitmproxy/test/",
"mitmproxy/tools/",
"mitmproxy/platform/",
"mitmproxy/utils/pyinstaller/",
]
src_files = glob.glob("mitmproxy/**/*.py", recursive=True)
src_files = [f for f in src_files if os.path.basename(f) != "__init__.py"]