-
-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathbuild_package.py
More file actions
43 lines (34 loc) · 927 Bytes
/
Copy pathbuild_package.py
File metadata and controls
43 lines (34 loc) · 927 Bytes
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
"""
pygame-menu
https://github.com/ppizarror/pygame-menu
BUILD
Build file.
"""
import shutil
import subprocess
import sys
from pathlib import Path
assert len(sys.argv) == 2, "Argument is required, usage: build_package.py pip/twine"
mode: str = sys.argv[1].strip()
root = Path(__file__).resolve().parent
dist = root / "dist"
build = root / "build"
if mode == "pip":
if dist.is_dir():
shutil.rmtree(dist)
if build.is_dir():
shutil.rmtree(build)
subprocess.run(["python", "-m", "build"], check=True)
elif mode == "twine":
if dist.is_dir():
subprocess.run(
["python", "-m", "twine", "upload", "dist/*"],
shell=True, # required because of wildcard
check=True,
)
else:
raise FileNotFoundError(
"No distribution found, execute build_package.py pip first"
)
else:
raise ValueError(f"Unknown mode {mode}")