-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-test-environment.py
51 lines (41 loc) · 1.67 KB
/
remove-test-environment.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
import condacmds as cmds
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--python',default='3.9',
help='specify the python version for the new environment')
parser.add_argument('--buildstem',default='build-test',
help='stem for the name of the build directory')
parser.add_argument('-c','--condacmd',default='conda',choices=['conda','mamba'],
help='conda command, should be one of conda or mamba')
parser.add_argument('-e','--environment',default=None,
help='name for the new environment, autogenerated from other params by default')
parser.add_argument('--suffix',default=None,
help='suffix appended to default environment and build_dir')
args = parser.parse_args()
pbld = cmds.PymeBuild(pythonver=args.python,
build_dir=args.buildstem,
condacmd=args.condacmd,
environment=args.environment,
mk_build_dir=False,
start_log=False,
suffix=args.suffix
)
print("removing environment %s" % pbld.env)
answer = input("Continue?")
if answer.lower() not in ["y","yes"]:
print("aborting...")
import sys
sys.exit(1)
print("removing...")
print(cmds.conda_remove(pbld.env))
import pathlib
build_dir = pbld.build_dir
if build_dir.exists():
print('removing build dir "%s"' % build_dir)
answer = input("Continue?")
if answer.lower() not in ["y","yes"]:
print("aborting...")
import sys
sys.exit(1)
import shutil
shutil.rmtree(build_dir)