forked from birdnet-team/BirdNET-Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyinstaller_full.py
56 lines (46 loc) · 1.35 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""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)