Repository navigation
Expand file tree
/
Copy pathbuild.py
More file actions
52 lines (41 loc) · 1.41 KB
/
Copy pathbuild.py
File metadata and controls
52 lines (41 loc) · 1.41 KB
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
#!/usr/bin/env python3
"""Build a single-file SessionGuard executable for whichever OS this
script is run on.
PyInstaller does not cross-compile — a Windows .exe has to be built on
Windows, a macOS binary on macOS, and a Linux binary on Linux. To get
all three from one push, run this via the .github/workflows/build.yml
matrix (build.yml runs it on windows-latest, macos-latest, and
ubuntu-latest), or run it locally on each OS by hand.
Usage:
pip install -e ".[build]"
python packaging/build.py
Output: dist/sessionguard (or dist/sessionguard.exe on Windows)
"""
import platform
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def main() -> None:
system = platform.system()
name = "sessionguard"
entry = str(ROOT / "src" / "sessionguard" / "__main__.py")
args = [
sys.executable, "-m", "PyInstaller",
"--onefile",
"--name", name,
"--paths", str(ROOT / "src"),
"--distpath", str(ROOT / "dist"),
"--workpath", str(ROOT / "build"),
"--specpath", str(ROOT / "build"),
"--console",
"--clean",
"--noconfirm",
entry,
]
print(f"Building SessionGuard for {system}...")
subprocess.run(args, check=True)
binary_name = f"{name}.exe" if system == "Windows" else name
print(f"Done — binary at dist/{binary_name}")
if __name__ == "__main__":
main()