def check_conda(tool_name, ctx, **kwds): """ Get the most up-to-date conda version for a tool requirement """ conda_context = planemo.conda.build_conda_context(ctx, **kwds) if not conda_context.is_conda_installed(): error("Conda is not installed! Try running planemo conda_init.") target = planemo.conda.conda_util.CondaTarget(tool_name) search_results = conda_util.best_search_result(target, conda_context=conda_context) return search_results[0]['version']
def best_practice_search(conda_target, conda_context=None, platform=None): # Call it in offline mode after the first time. try: best_practice_search_first.previously_called # TODO: Undo this... offline = False except AttributeError: best_practice_search_first.previously_called = True offline = False if not conda_context: conda_context = conda_util.CondaContext() return conda_util.best_search_result( conda_target, conda_context=conda_context, channels_override=BEST_PRACTICE_CHANNELS, offline=offline, platform=platform, )
def check_conda(tool_name, ctx, **kwds): """ Get the most up-to-date conda version for a tool requirement """ conda_context = planemo.conda.build_conda_context(ctx, **kwds) if not conda_context.is_conda_installed(): # check directly via Anaconda API r = requests.get('https://api.anaconda.org/search', params={'name': tool_name}) search_results = sum([ n['versions'] for n in r.json() if n['name'] == tool_name and n['owner'] in kwds['conda_ensure_channels'] ], []) return sorted(search_results, key=lambda n: packaging.version.parse(n))[-1] target = planemo.conda.conda_util.CondaTarget(tool_name) search_results = conda_util.best_search_result(target, conda_context=conda_context) return search_results[0]['version']
def get_conda_hits_for_targets(targets, conda_context): search_results = (best_search_result(t, conda_context, platform='linux-64')[0] for t in targets) return [r for r in search_results if r]