forked from NOAA-ORR-ERD/PyGnome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_conda_env.py
executable file
·64 lines (44 loc) · 1.45 KB
/
create_conda_env.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
#!/usr/bin/env python
import sys
import subprocess
from pathlib import Path
USAGE = """
create_conda_env.py environment_name [run|test|all]
create a conda environment for the gnome project
saves typing in all the requirements files
default is "all" -- full dev environment
"run" will only give you wnat you need to run the code
"build" will add what's needed to build PYGNOME
"test" will add what you need to run the tests
"docs" will add what's need to build the docs
Example:
./create_conda_env gnome build test
Will create and environment called "gnome" with everything needed to
build, run and test PyGNOME
NOTE: currently hard-coded for Python 3.10
"""
PYTHON="3.10"
if __name__ == "__main__":
try:
env_name = sys.argv[1]
except IndexError:
print(USAGE)
sys.exit(1)
argv = sys.argv[2:]
if not argv or "all" in argv:
here = Path(__file__).parent
reqs = here.glob("conda_requirements*.txt")
reqs = [str(r) for r in reqs]
else:
reqs = ["conda_requirements.txt"]
if "build" in argv:
reqs.append("conda_requirements_build.txt")
if "test" in argv:
reqs.append("conda_requirements_test.txt")
if "docs" in argv:
reqs.append("conda_requirements_docs.txt")
cmd = ["conda", "create", "-n", env_name, f"python={PYTHON}"]
for req in reqs:
cmd.extend(["--file", req])
print("running\n", cmd)
subprocess.run(cmd)