-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_requirements_file.py
executable file
·72 lines (53 loc) · 1.98 KB
/
build_requirements_file.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
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
"""
script to combine requirements files required for running and
testing the webgnomeapi into one file:
conda_requirements_all.txt
It requires that the other repositories are installed "alongside"
This one.
After running this script, you should be able to make a new
environment with the one command:
conda create -n webgnomeapi --file conda_requirements_all.txt
"""
PYTHON_VER = "3.10"
import datetime
from pathlib import Path
import textwrap
HERE = Path(__file__).parent
req_files = [HERE / "../pygnome/py_gnome/conda_requirements.txt",
# not needed -- adios_db is in the pygnome requirements
# HERE / "../oil_database/adios_db/conda_requirements.txt",
HERE / "../libgoods/conda_requirements.txt",
HERE / "conda_requirements.txt",
HERE / "conda_requirements_test.txt",
]
HEADER = f""" # All WebGnome requirements (including tests)
#
# NOTE: This file was auto-generated by:
#
# build_requirements_file.py
#
# on {str(datetime.date.today())}
#
# It should be rerun if any of the requirements have changed
# for PyGNOME or webgnomeapi
#
# NOTE: the python version is pinned to: {PYTHON_VER} in the
# build_requirements_file.py script.
"""
with open("conda_requirements_all.txt", 'wt') as outfile:
outfile.write(textwrap.dedent(HEADER))
outfile.write(f"python={PYTHON_VER}\n")
for req_file in req_files:
try:
with open(req_file) as infile:
print("Adding:", req_file)
for line in infile:
# strip the commented out lines
line = line.lstrip()
if line and not line[0] == '#':
outfile.write(line)
except FileNotFoundError:
print("All required repos must be installed alongside this one")
print("Couldn't open:", req_file)
raise