aboutsummaryrefslogtreecommitdiff
path: root/vars
diff options
context:
space:
mode:
authorMatt Rendina <mrendina@stsci.edu>2018-02-09 14:59:13 -0500
committerMatt Rendina <mrendina@stsci.edu>2018-02-09 14:59:13 -0500
commita2d970a6706044d9f36969df3c7f1e959fb70959 (patch)
tree809ea38317076a984845bbc909d3b077ab2650c3 /vars
parenta07b71f554883bd84e841c3538c6428cb2ae67e4 (diff)
downloadshared_utils-a2d970a6706044d9f36969df3c7f1e959fb70959.tar.gz
Initial import
Diffstat (limited to 'vars')
-rw-r--r--vars/conda.groovy50
1 files changed, 50 insertions, 0 deletions
diff --git a/vars/conda.groovy b/vars/conda.groovy
new file mode 100644
index 0000000..8b80dd9
--- /dev/null
+++ b/vars/conda.groovy
@@ -0,0 +1,50 @@
+// Shared functionality for managing conda installation.
+
+def install(version="4.3.31", py_maj_version=3, install_dir="miniconda") {
+
+ def CONDA_BASE_URL = "https://repo.continuum.io/miniconda"
+ def conda_installers = ["Linux-py2":"Miniconda2-${CONDA_INSTALLER_VERSION}-Linux-x86_64.sh",
+ "Linux-py3":"Miniconda3-${CONDA_INSTALLER_VERSION}-Linux-x86_64.sh",
+ "MacOSX-py2":"Miniconda2-${CONDA_INSTALLER_VERSION}-MacOSX-x86_64.sh",
+ "MacOSX-py3":"Miniconda3-${CONDA_INSTALLER_VERSION}-MacOSX-x86_64.sh"]
+ def OSname = null
+ def uname = sh(script: "uname", returnStdout: true).trim()
+ if (uname == "Darwin") {
+ OSname = "MacOSX"
+ println("OSname=${OSname}")
+ }
+ if (uname == "Linux") {
+ OSname = uname
+ println("OSname=${OSname}")
+ }
+ assert uname != null
+
+ // Check for the availability of a download tool and then use it
+ // to get the conda installer.
+ def dl_cmds = ["curl -OSs",
+ "wget --no-verbose --server-response --no-check-certificate"]
+ def dl_cmd = null
+ def stat1 = 999
+ for (cmd in dl_cmds) {
+ stat1 = sh(script: "which ${cmd.tokenize()[0]}", returnStatus: true)
+ if( stat1 == 0 ) {
+ dl_cmd = cmd
+ break
+ }
+ }
+ if (stat1 != 0) {
+ println("Could not find a download tool. Unable to proceed.")
+ return false
+ }
+
+ def WORKDIR = pwd()
+ def conda_install_dir = "${WORKDIR}/${install_dir}"
+ def conda_installer =
+ conda_installers["${OSname}-py${py_maj_version}"]
+ dl_cmd = dl_cmd + " ${CONDA_BASE_URL}/${conda_installer}"
+ sh dl_cmd
+
+ // Install specific version of miniconda
+ sh "bash ./${conda_installer} -b -p ${conda_install_dir}"
+ return true
+}