-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev_setup.py
executable file
·71 lines (62 loc) · 1.69 KB
/
dev_setup.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
71
#!/usr/bin/env python3
import signal
from pathlib import Path
from subprocess import check_call
from subprocess import check_output
signal.signal(signal.SIGINT, signal.SIG_DFL)
source_dir = Path(__file__).resolve().parent
print("=== System packages (sudo apt install ...) ===")
apt_install = [
"python3",
"python3-dev",
"python3-pip",
"python3-venv",
"libcairo2-dev",
"libgeos-dev",
"libproj-dev",
]
dpkg_query_command = ["dpkg-query", "--show", "--showformat=${Package}\\n"]
installed = set(check_output(dpkg_query_command).decode().split())
if not installed.issuperset(apt_install):
check_call(["sudo", "apt", "install"] + apt_install)
import venv # In case it just got installed above.
print()
print(f"=== Python packages (pip install ...) ===")
venv_dir = source_dir / "python_venv"
if not venv_dir.is_dir():
print(f"Creating {venv_dir}...")
venv.create(venv_dir, symlinks=True, with_pip=True)
pip_install = [
"addfips",
"autoflake",
"beautifulsoup4",
"black",
"cachecontrol[filecache]",
"cattrs",
"charset-normalizer",
"dominate",
"isort",
"matplotlib",
"moviepy",
"mplcairo",
"numpy",
"openpyxl",
"pandas",
"pyarrow",
"pybind11",
"pycountry",
"pyreadr",
"requests",
"scipy",
"us",
"xlrd",
]
if Path("/usr/include/proj_api.h").is_file():
pip_install.extend(["cartopy==0.19.0.post1", "--no-binary", "cartopy"])
else:
pip_install.append("cartopy")
check_call(["direnv", "allow", source_dir])
check_call(["direnv", "exec", source_dir, "pip", "install", "wheel"])
check_call(["direnv", "exec", source_dir, "pip", "install"] + pip_install)
print()
print("::: Setup complete :::")