Skip to content
Snippets Groups Projects
Commit 98a5cb7a authored by Martyn Gigg's avatar Martyn Gigg Committed by GitHub
Browse files

Merge pull request #17847 from mantidproject/17842-conda-jenkins

Improve Conda-recipe-update script to be reused in Jenkins build
parents 1bdb5ccb cf55747e
No related merge requests found
set(CONDA_WORKDIR "conda-packaging")
configure_file(buildconfig/CMake/conda-update-recipe.py.in ${CONDA_WORKDIR}/conda-update-recipe.py)
configure_file(buildconfig/CMake/conda_update_recipe.py.in ${CONDA_WORKDIR}/conda_update_recipe.py)
add_custom_target(
conda-update-recipe
COMMAND python conda-update-recipe.py
COMMAND python conda_update_recipe.py
WORKING_DIRECTORY ${CONDA_WORKDIR}
)
......@@ -5,17 +5,24 @@ git_rev = "@MtdVersion_WC_LAST_CHANGED_SHA_LONG@"
import subprocess as sp, shlex, os
def main():
def checkout(repo_path):
# checkout recipe
if not os.path.exists('conda-recipes'):
if not os.path.exists(repo_path):
cmd = 'git clone git@github.com:mantidproject/conda-recipes'
sp.check_call(cmd.split())
else:
cmd = 'git pull'
sp.check_call(cmd.split(), cwd='conda-recipes')
sp.check_call(cmd.split(), cwd=repo_path)
return
def update_meta_yaml(repo_path, recipe_path=None):
"return: True if updated"
recipe_path = recipe_path or 'framework'
if not os.path.isabs(recipe_path):
recipe_path = os.path.join(repo_path, recipe_path)
# change framework meta.yaml
path = 'conda-recipes/framework/meta.yaml'
path = os.path.join(recipe_path, 'meta.yaml')
header = []
header.append('{% set version = "' + '%s' % version + '" %}')
header.append('{% set git_rev = "' + '%s' % git_rev + '" %}')
......@@ -25,16 +32,32 @@ def main():
# if nothing changed just exit
if header == old_header:
print "Nothing changed. Skipping."
return
return False
open(path, 'wt').write('\n'.join(header+body))
return True
def commit(repo_path):
# commit
cmd = 'git commit -m "update version and git_rev" framework/meta.yaml'
sp.check_call(shlex.split(cmd), cwd="conda-recipes")
sp.check_call(shlex.split(cmd), cwd=repo_path)
return
def push(repo_path):
# push
cmd = 'git push'
sp.check_call(cmd.split(), cwd="conda-recipes")
sp.check_call(cmd.split(), cwd=repo_path)
return
def main():
repo_path = 'conda-recipes'
checkout(repo_path)
if update_meta_yaml(repo_path):
commit(repo_path)
push(repo_path)
return
if __name__ == '__main__': main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment