Skip to content

Commit

Permalink
simpify cross-platform; update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Sep 14, 2023
1 parent 6e1e1ef commit 7c1c3c0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/Build-and-deploy-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: nwb-guide
#mamba-version: "*"
environment-file: environments/environment-MAC.yml
auto-activate-base: false

Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/pyflask-build-and-dist-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ jobs:
os: ubuntu-latest
label: environments/environment-Linux.yml
prefix: /usr/share/miniconda3/envs/nwb-guide
shorthand: unix

- python-version: "3.10"
- python-version: "3.9"
os: macos-latest
label: environments/environment-Mac.yml
prefix: /Users/runner/miniconda3/envs/nwb-guide
shorthand: unix

- python-version: "3.10"
- python-version: "3.9"
os: windows-latest
label: environments/environment-Windows.yml
prefix: C:\Miniconda3\envs\nwb-guide
shorthand: win

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -88,15 +85,7 @@ jobs:
run: rm -f /Users/runner/miniconda3/envs/nwb-guide/lib/python3.9/site-packages/sonpy/linux/sonpy.so

- name: Build PyFlask distribution
run: npm run build:flask:${{ matrix.shorthand }}

#- if: matrix.os == 'windows-latest'
# name: Run test on build executable
# run: node tests/testPyinstallerExecutable.js --script ./build/nwb-guide/nwb-guide.exe

#- if: matrix.os != 'windows-latest'
# name: Run test on build executable
# run: node tests/testPyinstallerExecutable.js --script ./build/nwb-guide/nwb-guide
run: npm run build:flask

- name: Run test on distributed executable
run: node tests/testPyinstallerExecutable.js
Expand Down
File renamed without changes.
23 changes: 6 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@
"dev:app": "vite src/renderer",
"dev:server": "cd pyflask && python -m flask run --port 4242",
"build": "npm run build:app",
"echo": "python -c \"print('hello')\"",
"build:app": "electron-vite build --outDir build",
"build:win": "npm run build && npm run build:flask:win && npm run build:electron:win",
"build:mac": "npm run build && npm run build:flask:mac && npm run build:electron:mac",
"build:mac-arm64": "npm run build && npm run build:flask:mac-arm64 && npm run build:electron:mac",
"build:linux": "npm run build && npm run build:flask:linux && npm run build:electron:linux",
"build:flask:win": "python -m PyInstaller nwb-guide-windows.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask",
"build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask",
"build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask",
"build:flask:linux": "python -m PyInstaller nwb-guide-linux.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask",
"build:win": "npm run build && npm run build:flask && npm run build:electron:win",
"build:mac": "npm run build && npm run build:flask && npm run build:electron:mac",
"build:linux": "npm run build && npm run build:flask && npm run build:electron:linux",
"build:flask": "python -m PyInstaller nwb-guide.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask",
"build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ndx_dandi_icephys --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator ./pyflask/app.py",
"rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"",
"build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows",
"build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys",
"rename:spec:mac": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"",
"build:flask:spec:mac": "npm run build:flask:spec:mac && npm run rename:spec:mac",
"rename:spec:mac-arm64": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac-arm64.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"",
"build:flask:spec:mac-arm64": "npm run build:flask:spec:mac-arm64 && npm run rename:spec:mac-arm64",
"rename:spec:linux": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-linux.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"",
"build:flask:spec:linux": "npm run build:flask:spec:unix && npm run rename:spec:linux",
"build:flask:spec": "npm run build:flask:spec:base && python prepare_pyinstaller_spec.py",
"build:electron:win": "electron-builder build --win --publish never",
"build:electron:mac": "electron-builder build --mac --publish never",
"build:electron:linux": "electron-builder build --linux --publish never",
Expand Down
30 changes: 30 additions & 0 deletions prepare_pyinstaller_spec.py
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.
"""


def test():
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, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n")
lines.insert(3, "\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"

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()

0 comments on commit 7c1c3c0

Please sign in to comment.