-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlaunch.py
More file actions
46 lines (39 loc) · 1.05 KB
/
launch.py
File metadata and controls
46 lines (39 loc) · 1.05 KB
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
import sys
import os
import venv
import traceback
from subprocess import run
def setup_env():
workdir = os.path.abspath(os.path.dirname(__file__))
print("Workdir : ", workdir)
env = os.path.join(workdir, ".pvenv")
try:
if os.path.exists(env):
return True
else:
venv.create(env, with_pip=True)
run(["bin/pip", "install", "--prefer-binary", workdir], cwd=env)
except Exception as e:
print("Error occurred while trying to access environment ", e)
traceback.print_exc()
return False
if __name__ == "__main__":
setup_env()
eampv = os.environ["EAMPVIEW"]
if eampv is None or len(eampv) == 0:
print(
"Env. variable 'EAMPVIEW' to point to ParaView python 'pvpython' not set/found"
)
args = [
eampv,
"--force-offscreen-rendering",
"quickview/app.py",
"--venv",
".pvenv",
]
args.extend(sys.argv[1:])
try:
run(args)
except Exception as e:
print(e)
exit(1)