diff --git a/buildconfig/CMake/conda.cmake b/buildconfig/CMake/conda.cmake index 9ff8accbc1abe7fbb7cc96c660853b20968646b1..25d5df0375c06885400a6e5da58693b00db06051 100644 --- a/buildconfig/CMake/conda.cmake +++ b/buildconfig/CMake/conda.cmake @@ -1,7 +1,7 @@ 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} ) diff --git a/buildconfig/CMake/conda-update-recipe.py.in b/buildconfig/CMake/conda_update_recipe.py.in similarity index 55% rename from buildconfig/CMake/conda-update-recipe.py.in rename to buildconfig/CMake/conda_update_recipe.py.in index 41e54936783860fef4446bb41af8a1b6e683ea91..1723c8781dc19f9d74da3bbe5b77fffa79eabbfa 100644 --- a/buildconfig/CMake/conda-update-recipe.py.in +++ b/buildconfig/CMake/conda_update_recipe.py.in @@ -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()