-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_environment.py
61 lines (54 loc) · 1.87 KB
/
setup_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
52
53
54
55
56
57
58
59
60
61
import os
import platform
import shutil
import subprocess
IS_LINUX = "Linux" in platform.platform()
if not IS_LINUX:
print(
"JAX currently only works under Linux so this software is currently limited to be Linux only"
)
exit(-1)
install_deps = input(
"Should I run 'pip3 install -r requirements.txt' for you?\
Accepting this is recommended only when working in a venv. \
Otherwise the installation of these packages will be global! [y/N] "
)
if install_deps.lower() == "y":
subprocess.run(["python3", "-m", "pip", "install", "-r", "requirements.txt"])
try:
import FEMcommon.fem_toolkit
except Exception as ex:
# check for rust toolchain
s = subprocess.run(
["cargo", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout = s.stdout.decode("ascii")
CARGO_INSTALLED = "cargo" in stdout
# check for git
s = subprocess.run(
["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout = s.stdout.decode("ascii")
GIT_INSTALLED = "git" in stdout
if not GIT_INSTALLED:
print("Please install git!")
exit(-1)
if not CARGO_INSTALLED:
print(
"Please install the Rust programming language toolchain by going to https://www.rust-lang.org/tools/install"
)
exit(-1)
else:
compile = input(
"Missing Rust-based dynamic library. Should I compile it for you? This might take a while! [y/N] "
)
if compile.lower() == "y":
subprocess.run(
["git", "clone", "https://github.com/vasilvas99/fem-helpers.git"]
)
os.chdir("fem-helpers")
subprocess.run(["cargo", "build", "--release"])
shutil.copyfile(
"./target/release/libfem_toolkit.so", "../FEMcommon/fem_toolkit.so"
)
shutil.rmtree(os.getcwd())