forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activated.py
executable file
·41 lines (28 loc) · 847 Bytes
/
activated.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
#!/usr/bin/env python3
from __future__ import annotations
import enum
import os
import pathlib
import subprocess
import sys
here = pathlib.Path(__file__).parent.absolute()
class Env(enum.Enum):
chia = ".venv"
poetry = ".penv"
def main(*args: str) -> int:
if len(args) == 0:
print("Parameters required")
return 1
env = Env.chia
if args[0].startswith("--"):
env = Env[args[0][2:]]
args = args[1:]
if sys.platform == "win32":
script = "activated.ps1"
command = ["powershell", os.fspath(here.joinpath(script)), env.value, *args]
else:
script = "activated.sh"
command = ["sh", os.fspath(here.joinpath(script)), env.value, *args]
completed_process = subprocess.run(command)
return completed_process.returncode
sys.exit(main(*sys.argv[1:]))