forked from ucsb-cs148-s21/t7-local-network-file-transfer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
58 lines (45 loc) · 1.29 KB
/
build.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
57
58
#! /usr/bin/env python3
'''
``build.py``
============
Build script for Loft.
Usage
-----
Linux & macOS
^^^^^^^^^^^^^
In ``bash`` or similar::
$ python3 -m venv .venv # optional
$ source .venv/bin/activate # optional
$ pip install -r requirements.txt
$ python3 -OO -m build
Windows
^^^^^^^
In PowerShell::
PS > py -m venv .venv # optional
PS > .venv/Scripts/Activate.ps1 # optional
PS > pip install -r requirements.txt
PS > py -3 -OO -m build
'''
from pathlib import Path
import platform
import typing
import PyInstaller.__main__
# the name of the application
NAME: str = 'loft'
# the entry point of the application
ENTRY_POINT: Path = Path('loft', '__main__.py')
# directory containing Flask resources
FLASK_RESOURCES: Path = Path('loft', 'web')
# resources that need to be bundled with the application
RESOURCES: typing.List[Path] = [
Path(FLASK_RESOURCES, 'templates'), Path(FLASK_RESOURCES, 'static')]
def main():
pathsep: str = ';' if platform.system() == 'Windows' else ':'
PyInstaller.__main__.run([
str(ENTRY_POINT),
'-n', str(NAME),
'--onefile',
'--noconsole',
] + [f(res) for res in RESOURCES for f in (lambda _: '--add-data', lambda res: f'{res}{pathsep}{res}')])
if __name__ == '__main__':
main()