import subprocess, os, glob def get_pkg_list(): """ Run a couple shell commands to parse the metadata directory for its packages. :return: List of packages in metadata directory """ find_proc = subprocess.run(["find", "metadata", "-name", "meta.yaml"], stdout=subprocess.PIPE) paths = find_proc.stdout.decode('utf-8') fmt_paths = paths.replace("metadata/", "").replace("/meta.yaml", "") return fmt_paths.split('\n') class Recipe: def __init__(self, buildout, name, options): """ Initializes fields needed for recipe. :param buildout: (Boilerplate) Dictionary of options from buildout section of buildout.cfg :param name: (Boilerplate) Name of section that uses this recipe. :param options: (Boilerplate) Options of section that uses this recipe. """ self.options = options self.pkg_list = get_pkg_list() def install(self): """ Install method that runs when recipe has components it needs to install. :return: Paths to files, as strings, created by the recipe. """ if self.options['name'] == "all": pkgs = self.pkg_list else: pkgs = self.options['name'].split(',') for p in pkgs: if p not in self.pkg_list: print("Package {} not valid. Skipping.".format(p)) continue subprocess.run(["conda", "build", "metadata/{}".format(p), "--output-folder", "pkgs/"], stdout=subprocess.PIPE) self.options.created("pkgs/") subprocess.run(["python3", "tools/transfer_to_builder.py"]) return self.options.created() update = install