def test_filter_recipes_force_existing_package(): "same as above but force the recipe" # same as above, but this time force the recipe # TODO: refactor as py.test fixture r = Recipes(""" one: meta.yaml: | package: name: gffutils version: "0.8.7.1" requirements: run: - python """, from_string=True) r.write_recipes() recipes = list(r.recipe_dirs.values()) env_matrix = { 'CONDA_PY': [27, 35], } pkgs = utils.get_channel_packages('bioconda') pth = utils.built_package_path(recipes[0]) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'], force=True)) assert len(filtered) == 1
def test_filter_recipes_existing_package(): "use a known-to-exist package in bioconda" # note that we need python as a run requirement in order to get the "pyXY" # in the build string that matches the existing bioconda built package. r = Recipes(""" one: meta.yaml: | package: name: gffutils version: "0.8.7.1" requirements: run: - python """, from_string=True) r.write_recipes() recipes = list(r.recipe_dirs.values()) env_matrix = { 'CONDA_PY': [27, 35], } pkgs = utils.get_channel_packages('bioconda') pth = utils.built_package_path(recipes[0]) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) assert len(filtered) == 0
def __init__(self): logger.info('Loading packages...') repodata = defaultdict(lambda: defaultdict(list)) for platform in ['linux', 'osx']: channel_packages = utils.get_channel_packages(channel='bioconda', platform=platform) for pkg_key in channel_packages.keys(): repodata[pkg_key.name][pkg_key.version].append(platform) self.repodata = repodata
def __init__(self): logger.info('Loading packages...') repodata = defaultdict(lambda: defaultdict(list)) for platform in ['linux', 'osx']: for pkg in utils.get_channel_packages(channel='bioconda', platform=platform): name, version, _ = self._parse_pkgname(pkg) repodata[name][version].append(platform) self.repodata = repodata
def test_get_channel_packages(): with pytest.raises(requests.HTTPError): utils.get_channel_packages('bioconda_xyz_nonexistent_channel') utils.get_channel_packages('bioconda')
def setup(*args): """ Go through every folder in the `bioconda-recipes/recipes` dir and generate a README.rst file. """ print('Generating package READMEs...') repodata = defaultdict(lambda: defaultdict(list)) for platform in ['linux', 'osx']: for pkg in utils.get_channel_packages(channel='bioconda', platform=platform): d = parse_pkgname(pkg) repodata[d['name']][d['version']].append(platform) # e.g., repodata = { # 'package1': { # '0.1': ['linux'], # '0.2': ['linux', 'osx'], # }, #} summaries = [] recipes = [] for folder in os.listdir(RECIPE_DIR): # Subfolders correspond to different versions versions = [] for sf in os.listdir(op.join(RECIPE_DIR, folder)): if not op.isdir(op.join(RECIPE_DIR, folder, sf)): # Not a folder continue try: LooseVersion(sf) except ValueError: print("'{}' does not look like a proper version!".format(sf)) continue versions.append(sf) #versions.sort(key=LooseVersion, reverse=True) # Read the meta.yaml file recipe = op.join(RECIPE_DIR, folder, "meta.yaml") if op.exists(recipe): metadata = MetaData(recipe) if metadata.version() not in versions: versions.insert(0, metadata.version()) else: if versions: recipe = op.join(RECIPE_DIR, folder, versions[0], "meta.yaml") metadata = MetaData(recipe) else: # ignore non-recipe folders continue name = metadata.name() versions_in_channel = sorted(repodata[name].keys()) # Format the README notes = metadata.get_section('extra').get('notes', '') if notes: if isinstance(notes, list): notes = "\n".join(notes) notes = 'Notes\n-----\n\n' + notes summary = metadata.get_section('about').get('summary', '') summaries.append(summary) template_options = { 'title': metadata.name(), 'title_underline': '=' * len(metadata.name()), 'summary': summary, 'home': metadata.get_section('about').get('home', ''), 'versions': ', '.join(versions_in_channel), 'license': metadata.get_section('about').get('license', ''), 'recipe': ('https://github.com/bioconda/bioconda-recipes/tree/master/recipes/' + op.dirname(op.relpath(metadata.meta_path, RECIPE_DIR))), 'notes': notes } # Add additional keys to template_options for use in the recipes # datatable. template_options['Package'] = ( '<a href="recipes/{0}/README.html">{0}</a>'.format(name)) for version in versions_in_channel: t = template_options.copy() if 'linux' in repodata[name][version]: t['Linux'] = '<i class="fa fa-linux"></i>' if 'osx' in repodata[name][version]: t['OSX'] = '<i class="fa fa-apple"></i>' t['Version'] = version recipes.append(t) readme = README_TEMPLATE.format(**template_options) # Write to file try: os.makedirs(op.join(OUTPUT_DIR, folder)) # exist_ok=True on Python 3 except OSError: pass output_file = op.join(OUTPUT_DIR, folder, 'README.rst') # avoid re-writing the same contents, which invalidates the # sphinx-build cache if os.path.exists(output_file): if open(output_file, encoding='utf-8').read() == readme: continue with open(output_file, 'wb') as ofh: ofh.write(readme.encode('utf-8')) # render the recipes datatable page t = Template(RECIPES_TEMPLATE) recipes_contents = t.render( recipes=recipes, # order of columns in the table; must be keys in template_options keys=['Package', 'Version', 'License', 'Linux', 'OSX']) recipes_rst = 'source/recipes.rst' if not (os.path.exists(recipes_rst) and (open(recipes_rst).read() == recipes_contents)): with open(recipes_rst, 'w') as fout: fout.write(recipes_contents)