Skip to content

Commit

Permalink
simplify python
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Sep 14, 2023
1 parent 9d870f7 commit a9ddea5
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions prepare_pyinstaller_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@
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()

def test():
from pathlib import Path
lines.insert(1, "import sys\n")
lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n")
lines.insert(3, "\n")

with open(file=Path(__file__).parent / "nwb-guide.spec", mode="r") as io:
lines = io.readlines()
# 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"

lines.insert(1, "import sys\n")
lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n")
lines.insert(3, "\n")
with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io:
io.writelines(lines)

# 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"

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!")


if __name__ == "__main__":
test()
print("Sucessfully injected recursion depth extension and json paths!")

0 comments on commit a9ddea5

Please sign in to comment.