-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import logging | ||
import os | ||
import site | ||
import sys | ||
from pathlib import Path | ||
|
||
import coloredlogs | ||
import PyInstaller.__main__ | ||
|
||
import pymobiledevice3.__main__ | ||
import pymobiledevice3.cli | ||
import pymobiledevice3.resources | ||
|
||
coloredlogs.install(level=logging.DEBUG) | ||
|
||
ROOT = Path(__file__).parent.parent.parent | ||
DEFAULT_OUTPUT = ROOT / Path('dist/__main__').with_suffix('.exe' if sys.platform == 'win32' else '') | ||
OUTPUT = (ROOT / 'dist/pymobiledevice3').with_suffix('.exe' if sys.platform == 'win32' else '') | ||
|
||
|
||
def main() -> None: | ||
site_packages_path = site.getsitepackages()[0] | ||
resources_dir = Path(pymobiledevice3.resources.__file__).parent | ||
pymobiledevice3_cli_path = Path(pymobiledevice3.cli.__file__).parent | ||
|
||
hidden_imports = [] | ||
|
||
for module in pymobiledevice3_cli_path.iterdir(): | ||
if module.name.endswith('.py') and module.name != '__init__.py': # Avoid including the __init__.py | ||
# Create the module name to be added to hidden imports | ||
module_name = 'pymobiledevice3.cli.' + os.path.splitext(module.name)[0] | ||
hidden_imports.append('--hidden-import=' + module_name) | ||
|
||
pyinstaller_args = [ | ||
pymobiledevice3.__main__.__file__, | ||
'--hidden-import=ipsw_parser', | ||
'--hidden-import=zeroconf', | ||
'--hidden-import=pyimg4', | ||
'--hidden-import=zeroconf._utils.ipaddress', | ||
'--hidden-import=zeroconf._handlers.answers', | ||
'--hidden-import=readchar', | ||
'--copy-metadata=pyimg4', | ||
'--copy-metadata=readchar', | ||
'--copy-metadata=apple_compress', | ||
'--onefile', | ||
] | ||
if sys.platform == 'win32': | ||
pyinstaller_args.extend([ | ||
'--add-binary', f'{site_packages_path}/Lib/site-packages/pytun_pmd3/wintun/*;pytun_pmd3/wintun/bin', | ||
'--add-binary', f'{resources_dir}/webinspector;pymobiledevice3/resources/webinspector', | ||
]) | ||
else: | ||
pyinstaller_args.extend([ | ||
'--add-binary', f'{site_packages_path}/pytun_pmd3:pytun_pmd3', | ||
'--add-binary', f'{resources_dir}/webinspector:pymobiledevice3/resources/webinspector', | ||
]) | ||
pyinstaller_args.extend(hidden_imports) | ||
PyInstaller.__main__.run(pyinstaller_args) | ||
DEFAULT_OUTPUT.rename(OUTPUT) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ debug/ | |
*.egg-info/ | ||
pymobiledevice3/_version.py | ||
.python-version | ||
__main__.spec |