@@ -103,7 +103,7 @@ def config_join(*args):
103103 config_directory = mkdtemp ()
104104 try :
105105 latest_galaxy = False
106- if _install_galaxy_if_needed (config_directory , kwds ):
106+ if _install_galaxy_if_needed (ctx , config_directory , kwds ):
107107 latest_galaxy = True
108108 galaxy_root = config_join ("galaxy-dev" )
109109
@@ -309,26 +309,52 @@ def _tool_conf_entry_for(tool_path):
309309 return tool_definition
310310
311311
312- def _install_galaxy_if_needed (config_directory , kwds ):
312+ def _install_galaxy_if_needed (ctx , config_directory , kwds ):
313313 installed = False
314314 if kwds .get ("install_galaxy" , None ):
315- _install_galaxy_via_download (config_directory , kwds )
315+ if not kwds .get ("no_cache_galaxy" , False ):
316+ _install_galaxy_via_git (ctx , config_directory , kwds )
317+ else :
318+ _install_galaxy_via_download (config_directory , kwds )
316319 installed = True
317320 return installed
318321
319322
320323def _install_galaxy_via_download (config_directory , kwds ):
324+ command = galaxy_run .DOWNLOAD_GALAXY + "; tar -zxvf dev | tail"
325+ _install_with_command (config_directory , command )
326+
327+
328+ def _install_galaxy_via_git (ctx , config_directory , kwds ):
329+ _ensure_galaxy_repository_available (ctx )
330+ workspace = ctx .workspace
331+ gx_repo = os .path .join (workspace , "gx_repo" )
332+ command = "git clone %s galaxy-dev" % (gx_repo )
333+ _install_with_command (config_directory , command )
334+
335+
336+ def _install_with_command (config_directory , command ):
321337 install_cmds = [
322338 "cd %s" % config_directory ,
323- galaxy_run .DOWNLOAD_GALAXY ,
324- "tar -zxvf master | tail" ,
339+ command ,
325340 "cd galaxy-dev" ,
326341 "type virtualenv >/dev/null 2>&1 && virtualenv .venv" ,
327342 galaxy_run .ACTIVATE_COMMAND ,
328343 ]
329344 shell (";" .join (install_cmds ))
330345
331346
347+ def _ensure_galaxy_repository_available (ctx ):
348+ workspace = ctx .workspace
349+ gx_repo = os .path .join (workspace , "gx_repo" )
350+ if os .path .exists (gx_repo ):
351+ # Attempt fetch - but don't fail if not interweb, etc...
352+ shell ("git --git-dir %s fetch >/dev/null 2>&1" % gx_repo )
353+ else :
354+ remote_repo = "https://github.com/galaxyproject/galaxy"
355+ shell ("git clone --bare %s %s" % (remote_repo , gx_repo ))
356+
357+
332358def _build_env_for_galaxy (properties , template_args ):
333359 env = {}
334360 for key , value in properties .iteritems ():
0 commit comments