-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_package.py
executable file
·47 lines (37 loc) · 1.06 KB
/
build_package.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
#!/usr/bin/env python3
# Copyright (c) 2019 Blake Covarrubias
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
"""Build a zipapp package for k3s-helmchart-generate.py"""
import os
import shutil
import subprocess
import sys
import tempfile
import zipapp
def main():
"""Main function"""
# Create a temporary directory to build the app
with tempfile.TemporaryDirectory() as build_dir:
program_name = "k3s-helmchart-generate.py"
shutil.copy(src=program_name, dst=os.path.join(build_dir, "__main__.py"))
pip_install_cmd = [
sys.executable,
"-m",
"pip",
"install",
"--requirement",
"requirements.txt",
"--target",
build_dir,
]
subprocess.check_call(pip_install_cmd)
zipapp.create_archive(
source=build_dir,
target=f"{program_name}z",
interpreter="/usr/bin/env python3",
compressed=True,
)
if __name__ == "__main__":
main()