diff options
author | Matt Rendina <rendinam@users.noreply.github.com> | 2019-10-01 14:46:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-01 14:46:22 -0400 |
commit | ef9398da516b116da1763046ac38450a55337bee (patch) | |
tree | 56e66f6ae74ca924ca7278cd3102693f4af86570 /vars | |
parent | 8726ff90c7114c1143c7247ca0c61aab620e1620 (diff) | |
download | jscu_refactor-ef9398da516b116da1763046ac38450a55337bee.tar.gz |
Dump a pip freeze of each environment if pip is present. (#64)1.3.23
Support editable installs to get git metadata without having to specify input requirements file.
Remove diagnostic output. Clean up comments.
Diffstat (limited to 'vars')
-rw-r--r-- | vars/utils.groovy | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/vars/utils.groovy b/vars/utils.groovy index d0663ea..4f73fc9 100644 --- a/vars/utils.groovy +++ b/vars/utils.groovy @@ -163,7 +163,7 @@ def installConda(version, install_dir) { def curr_ver = sh(script:"${conda_exe} --version", returnStdout: true) curr_ver = curr_ver.tokenize()[1].trim() if (curr_ver != version) { - sh "${conda_exe} install conda=${version}" + sh "${conda_exe} install -q conda=${version}" } return true @@ -512,6 +512,38 @@ def buildAndTest(config) { } else if (fileExists(local_conda)) { conda_exe = local_conda } + + pip_exe = sh(script:"which pip", returnStdout:true).trim() + if (pip_exe != '') { + def output_reqs = "reqs_${config.name}.txt" + sh(script: "${pip_exe} freeze > '${output_reqs}'") + // If requirements file used to populate the environment used the + // <pkg_name> @ git+https://URL@<commit_hash> syntax, modify each + // 'dev' package line found in the output freeze file, to take the form: + // '-e git+https://URL@<HASH>#egg=<name>' + def reqlines = readFile(output_reqs).trim().tokenize('\n') + def devlines = [] + for (line in reqlines) { + if (line.contains('.dev')) { + devlines.add(line) + } + } + for (devline in devlines) { + println(devline) + def dname = devline.tokenize('==')[0].trim() + def remote = '' + def hash = '' + dir("src/${dname}") { + hash = sh(script:'git rev-parse HEAD', returnStdout:true).trim() + remote = sh(script:'git remote -v | head -1', returnStdout:true).trim().tokenize()[1] + } + def repl = "-e git+${remote}@${hash}#egg=${dname}" + sh(script: "sed -i '/${dname}=/c\\${repl}' ${output_reqs}") + } + } else { + println('"pip" not found. Unable to generate "freeze" environment snapshot.') + } + if (conda_exe != '') { // 'def' _required_ here to prevent use of values from one build // config leaking into others. |