forked from mindstorm38/portablemc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspace.py
More file actions
32 lines (24 loc) · 903 Bytes
/
workspace.py
File metadata and controls
32 lines (24 loc) · 903 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
"""
Development tool script for managing all modules at once using poetry.
"""
import subprocess
import sys
import os
def iter_module():
yield "portablemc", "core"
with os.scandir() as dirs:
for entry in dirs:
if entry.is_dir() and entry.name != "core":
yield f"portablemc-{entry.name}", entry.name
def for_each_module(args):
for name, path in iter_module():
print(f"{name} > {' '.join(args)}")
subprocess.call(args, cwd=path)
if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.abspath(__file__)))
need_uninstall = sys.argv[1] == "install" if len(sys.argv) >= 2 else False
if need_uninstall:
print("Uninstalling previously installed modules...")
subprocess.call(["pip", "uninstall", "-y", *map(lambda t: t[0], iter_module())])
for_each_module(["poetry"] + sys.argv[1:])
sys.exit(0)