Skip to content

Commit

Permalink
modify spec to be platform indepedent
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Sep 14, 2023
1 parent a9ddea5 commit 1d5579b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nwb-guide.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- mode: python ; coding: utf-8 -*-
import sys
from pathlib import Path

sys.setrecursionlimit(sys.getrecursionlimit() * 5)

from PyInstaller.utils.hooks import collect_data_files
Expand Down Expand Up @@ -27,7 +29,7 @@ block_cipher = None


a = Analysis(
['pyflask\\app.py'],
[f"{Path('pyflask') / 'app.py'}"],
pathex=[],
binaries=binaries,
datas=datas,
Expand Down
9 changes: 8 additions & 1 deletion prepare_pyinstaller_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
lines = io.readlines()

lines.insert(1, "import sys\n")
lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\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)

Expand Down

0 comments on commit 1d5579b

Please sign in to comment.