Files
galaxy/scripts/manage_tool_dependencies.py
T
John Chilton 939e7774a8 Create galaxy-tool-util package.
This is (so far a subset of) the tool utilities from galaxy-lib. galaxy-lib mocked out a fake galaxy.tools to allow these to all exist below the galaxy.tools - but this was a terrible hack - in order for the new packages to be true subsets of Galaxy they need to be refactored into a new package that doesn't depend on models, SA, galaxy.jobs, etc...

[x] galaxy.tools.deps -> galaxy.tool_util.deps
[x] galaxy.tools.loader -> galaxy.tool_util.loader
[x] galaxy.tools.cwl -> galaxy.tool_util.cwl
[x] galaxy.tools.loader -> galaxy.tool_util.loader
[x] galaxy.tools.fetcher -> galaxy.tool_util.fetcher
[x] galaxy.tools.locations -> galaxy.tool_util.locations
[x] galaxy.tools.parser -> galaxy.tool_util.parser
2019-05-16 16:45:25 -04:00

61 lines
2.0 KiB
Python

import os.path
import sys
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib')))
from galaxy.config import (
configure_logging,
find_path,
find_root,
parse_dependency_options,
)
from galaxy.tool_util.deps import CachedDependencyManager, DependencyManager, NullDependencyManager
from galaxy.util.script import main_factory
DESCRIPTION = "Script to manage tool dependencies (with focus on a Conda environments)."
def _init_if_needed(args, kwargs):
# If conda_auto_init is set, simply building the Conda resolver will call handle installation.
_build_dependency_manager_no_config(kwargs)
def _build_dependency_manager_no_config(kwargs):
"""Simplified variant of build_dependency_manager from galaxy.tool_util.deps.
The canonical factory method requires a full Galaxy configuration object
which we do not have available in this script (an optimization).
"""
configure_logging(kwargs)
root = find_root(kwargs)
dependency_resolvers_config_file = find_path(kwargs, "dependency_resolvers_config_file", root)
use_dependencies, tool_dependency_dir, use_cached_dependency_manager, tool_dependency_cache_dir, precache_dependencies = \
parse_dependency_options(kwargs, root, dependency_resolvers_config_file)
if not use_dependencies:
dependency_manager = NullDependencyManager()
else:
dependency_manager_kwds = {
'default_base_path': tool_dependency_dir,
'conf_file': dependency_resolvers_config_file,
'app_config': kwargs,
}
if use_cached_dependency_manager:
dependency_manager_kwds['tool_dependency_cache_dir'] = tool_dependency_cache_dir
dependency_manager = CachedDependencyManager(**dependency_manager_kwds)
else:
dependency_manager = DependencyManager(**dependency_manager_kwds)
return dependency_manager
ACTIONS = {
"init_if_needed": _init_if_needed,
}
if __name__ == '__main__':
main = main_factory(description=DESCRIPTION, actions=ACTIONS)
main()