-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #365 from NeurodataWithoutBorders/use_pyinstaller_…
…spec_files_per_platform Swap to .spec files for PyInstaller
- Loading branch information
Showing
6 changed files
with
114 additions
and
23 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
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 |
---|---|---|
|
@@ -19,8 +19,6 @@ semantic.json | |
build/ | ||
yarn.lock | ||
|
||
*.spec | ||
|
||
*.pyc | ||
src/.DS_Store | ||
.DS_Store | ||
|
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,74 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
import sys | ||
from pathlib import Path | ||
|
||
sys.setrecursionlimit(sys.getrecursionlimit() * 5) | ||
|
||
from PyInstaller.utils.hooks import collect_data_files | ||
from PyInstaller.utils.hooks import collect_all | ||
|
||
datas = [('./paths.config.json', '.'), ('./package.json', '.')] | ||
binaries = [] | ||
hiddenimports = ['scipy._distributor_init', 'scipy._lib.messagestream', 'scipy._lib._ccallback', 'scipy._lib._testutils', 'email_validator'] | ||
datas += collect_data_files('jsonschema_specifications') | ||
tmp_ret = collect_all('nwbinspector') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
tmp_ret = collect_all('neuroconv') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
tmp_ret = collect_all('pynwb') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
tmp_ret = collect_all('hdmf') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
tmp_ret = collect_all('ndx_dandi_icephys') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
tmp_ret = collect_all('ci_info') | ||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] | ||
|
||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis( | ||
[f"{Path('pyflask') / 'app.py'}"], | ||
pathex=[], | ||
binaries=binaries, | ||
datas=datas, | ||
hiddenimports=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) | ||
|
||
exe = EXE( | ||
pyz, | ||
a.scripts, | ||
[], | ||
exclude_binaries=True, | ||
name='nwb-guide', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
console=True, | ||
disable_windowed_traceback=False, | ||
argv_emulation=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None, | ||
) | ||
coll = COLLECT( | ||
exe, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
name='nwb-guide', | ||
) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Calling `pyi-makespec` regenerates the base spec file, but we need to extend the recursion limit. | ||
This script is run automatically as a part of `npm run build:flask:spec` after the `pyi-makespec` call. | ||
""" | ||
from pathlib import Path | ||
|
||
with open(file=Path(__file__).parent / "nwb-guide.spec", mode="r") as io: | ||
lines = io.readlines() | ||
|
||
lines.insert(1, "import sys\n") | ||
lines.insert(2, "from pathlib import Path\n") | ||
lines.insert(3, "\n") | ||
lines.insert(4, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") | ||
lines.insert(5, "\n") | ||
|
||
# Originally this was a separate `npm` command per platform to account for CLI syntax differences between ; and : | ||
# The spec file is, however, the same across platforms | ||
data_line_index = lines.index("datas = []\n") | ||
lines[data_line_index] = "datas = [('./paths.config.json', '.'), ('./package.json', '.')]\n" | ||
|
||
# Another platform specific difference is the app.py location | ||
app_py_line_index = next(index for index, line in enumerate(lines) if "app.py" in line) | ||
app_py_line = " [f\"{Path('pyflask') / 'app.py'}\"],\n" | ||
lines[app_py_line_index] = app_py_line | ||
|
||
with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io: | ||
io.writelines(lines) | ||
|
||
print("Sucessfully injected recursion depth extension and json paths!") |