-
Notifications
You must be signed in to change notification settings - Fork 248
build: PyInstallerをv6へ更新 #1766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: PyInstallerをv6へ更新 #1766
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,51 @@ | ||
| # -*- mode: python ; coding: utf-8 -*- | ||
| # このファイルはPyInstallerによって自動生成されたもので、それをカスタマイズして使用しています。 | ||
| from PyInstaller.utils.hooks import collect_data_files | ||
| import os | ||
|
|
||
| datas = [ | ||
| ('resources', 'resources'), | ||
| ('engine_manifest.json', '.'), | ||
| ('licenses.json', '.'), | ||
| ] | ||
| datas += collect_data_files('pyopenjtalk') | ||
| from argparse import ArgumentParser | ||
| from pathlib import Path | ||
| from shutil import copy2, copytree | ||
|
|
||
| core_model_dir_path = os.environ.get('CORE_MODEL_DIR_PATH') | ||
| if core_model_dir_path: | ||
| print('CORE_MODEL_DIR_PATH is found:', core_model_dir_path) | ||
| if not os.path.isdir(core_model_dir_path): | ||
| raise Exception("CORE_MODEL_DIR_PATH was found, but it is not directory!") | ||
| datas += [(core_model_dir_path, "model")] | ||
| from PyInstaller.utils.hooks import collect_data_files | ||
|
|
||
| # コアとONNX Runtimeはバイナリであるが、`binaries`に加えると | ||
| # 依存関係のパスがPyInstallerに書き換えらるので、`datas`に加える | ||
| # 参考: https://github.com/VOICEVOX/voicevox_engine/pull/446#issuecomment-1210052318 | ||
| libcore_path = os.environ.get('LIBCORE_PATH') | ||
| if libcore_path: | ||
| print('LIBCORE_PATH is found:', libcore_path) | ||
| if not os.path.isfile(libcore_path): | ||
| raise Exception("LIBCORE_PATH was found, but it is not file!") | ||
| datas += [(libcore_path, ".")] | ||
| parser = ArgumentParser() | ||
| parser.add_argument("--libcore_path", type=Path) | ||
| parser.add_argument("--libonnxruntime_path", type=Path) | ||
| parser.add_argument("--core_model_dir_path", type=Path) | ||
| options = parser.parse_args() | ||
|
|
||
| libonnxruntime_path = os.environ.get('LIBONNXRUNTIME_PATH') | ||
| if libonnxruntime_path: | ||
| print('LIBONNXRUNTIME_PATH is found:', libonnxruntime_path) | ||
| if not os.path.isfile(libonnxruntime_path): | ||
| raise Exception("LIBCORE_PATH was found, but it is not file!") | ||
| datas += [(libonnxruntime_path, ".")] | ||
| libcore_path: Path | None = options.libcore_path | ||
| if libcore_path is not None and not libcore_path.is_file(): | ||
| raise Exception(f"libcore_path: {libcore_path} is not file") | ||
|
|
||
| libonnxruntime_path: Path | None = options.libonnxruntime_path | ||
| if libonnxruntime_path is not None and not libonnxruntime_path.is_file(): | ||
| raise Exception(f"libonnxruntime_path: {libonnxruntime_path} is not file") | ||
|
|
||
| block_cipher = None | ||
| core_model_dir_path: Path | None = options.core_model_dir_path | ||
| if core_model_dir_path is not None and not core_model_dir_path.is_dir(): | ||
| raise Exception(f"core_model_dir_path: {core_model_dir_path} is not dir") | ||
|
|
||
|
|
||
| a = Analysis( | ||
| ['run.py'], | ||
| ["run.py"], | ||
| pathex=[], | ||
| binaries=[], | ||
| datas=datas, | ||
| datas=collect_data_files("pyopenjtalk"), | ||
| hiddenimports=[], | ||
| hookspath=[], | ||
| hooksconfig={}, | ||
| 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) | ||
| pyz = PYZ(a.pure) | ||
|
|
||
| exe = EXE( | ||
| pyz, | ||
| a.scripts, | ||
| [], | ||
| exclude_binaries=True, | ||
| name='run', | ||
| name="run", | ||
| debug=False, | ||
| bootloader_ignore_signals=False, | ||
| strip=False, | ||
|
|
@@ -72,15 +56,37 @@ exe = EXE( | |
| target_arch=None, | ||
| codesign_identity=None, | ||
| entitlements_file=None, | ||
| contents_directory="engine_internal", # 実行時に"sys._MEIPASS"が参照するディレクトリ名 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここのメモは「今そうなってる」というwhatはわかるけど、結局なぜこの値なのかのwhyがわからないかもと感じました! ・・・・・・これちなみになんで指定が必要なんでしたっけ・・・。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #828 (comment) 無指定だと 正直なところこの引数にこれ以上詳細な説明を書くことに疑問を感じています。
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. あ、なるほどです!!ありがとうございます!!
・・・だったけど、今のエディタはエンジンを
|
||
| ) | ||
|
|
||
| coll = COLLECT( | ||
| exe, | ||
| a.binaries, | ||
| a.zipfiles, | ||
| a.datas, | ||
| strip=False, | ||
| upx=True, | ||
| upx_exclude=[], | ||
| name='run', | ||
| name="run", | ||
| ) | ||
|
|
||
| # 実行ファイルのディレクトリに配置するファイルのコピー | ||
|
|
||
| # 実行ファイルと同じrootディレクトリ | ||
| target_dir = Path(DISTPATH) / "run" | ||
|
|
||
| # リソースをコピー | ||
| manifest_file_path = Path("engine_manifest.json") | ||
| copy2(manifest_file_path, target_dir) | ||
| copytree("resources", target_dir / "resources") | ||
|
|
||
| license_file_path = Path("licenses.json") | ||
| if license_file_path.is_file(): | ||
| copy2("licenses.json", target_dir) | ||
|
|
||
| # 動的ライブラリをコピー | ||
| if libonnxruntime_path is not None: | ||
| copy2(libonnxruntime_path, target_dir) | ||
| if core_model_dir_path is not None: | ||
| copytree(core_model_dir_path, target_dir / "model") | ||
| if libcore_path is not None: | ||
| copy2(libcore_path, target_dir) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.