forked from kahst/BirdNET-Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 5
/
pyinstaller_full.py
34 lines (24 loc) · 1.15 KB
/
pyinstaller_full.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Packages the analyzer and the gui into an application.
Librosa 0.9.2 has to be used, since pyinstaller cant package >=0.10.0.
See https://github.com/librosa/librosa/issues/1705.
"""
import pathlib
import sys
import zipfile
import PyInstaller.__main__
def build(app_name: str, create_zip=False):
PyInstaller.__main__.run(["--clean", "--noconfirm", f"{app_name}-full.spec"])
if create_zip:
print("Creating zip file.")
dist_dir = pathlib.Path(sys.argv[0]).parent / "dist"
analyzer_dir = dist_dir / app_name
with zipfile.ZipFile(dist_dir / f"{app_name}.zip", "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive:
for entry in analyzer_dir.rglob("*"):
archive.write(entry, entry.relative_to(analyzer_dir.parent))
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="parser for creating build.")
parser.add_argument("-n", "--name", default="BirdNET-Analyzer", help="Represents the name of the app.")
parser.add_argument("-z", "--zip", action="store_true")
args, _ = parser.parse_known_args()
build(args.name, create_zip=args.zip)