forked from OGGM/oggm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasv_oggm_plugin.py
41 lines (31 loc) · 1.85 KB
/
asv_oggm_plugin.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
import subprocess
import glob
import sys
import os
from asv.plugins.virtualenv import Virtualenv
class OggmVirtualenv(Virtualenv):
tool_name = "oggm_virtualenv"
def _install_requirements(self):
# pip>=10 is broken for some of our dependencies
self.run_executable("pip", ["install", "-v", "--upgrade", "pip<10", "setuptools"])
env_key = "OGGM_ASV_WHEEL_DIR_" + self._python.replace(".", "_")
if env_key not in os.environ:
env_key = "OGGM_ASV_WHEEL_DIR"
# check if there are global wheels available somewhere
if env_key in os.environ:
wheel_dir = os.path.expanduser(os.environ[env_key])
wheel_dir = os.path.join(wheel_dir, "*.whl")
wheels = glob.glob(wheel_dir)
self.run_executable("pip", ["install", "-v"] + wheels)
else:
# some packages(rasterio...) need numpy during setup.py. So install it and some other similar stuff individually.
self.run_executable("pip", ["install", "-v", "numpy", "six", "cython"])
# handle odd cases of GDAL/Fiona
gdal_version = subprocess.check_output(["gdal-config", "--version"]).strip().decode("utf-8")
gdal_flags = subprocess.check_output(["gdal-config", "--cflags"]).strip().decode("utf-8")
gdal_flags = gdal_flags.replace("-I", "--include-dirs=")
self.run_executable("pip", ["install", "-v", "--upgrade", "gdal==" + gdal_version, "--install-option=build_ext", "--install-option=" + gdal_flags])
self.run_executable("pip", ["install", "-v", "--upgrade", "fiona", "--install-option=build_ext", "--install-option=" + gdal_flags])
# install latest salem
self.run_executable("pip", ["install", "-v", "--upgrade", "git+https://github.com/fmaussion/salem.git"])
super(OggmVirtualenv, self)._install_requirements()