From 637d8f64dde991c9dbf3f7f3ca276ea430046319 Mon Sep 17 00:00:00 2001 From: nhertz <nhertz@nrao.edu> Date: Wed, 19 Aug 2020 15:38:41 -0600 Subject: [PATCH] Fixed bug in build_packages that would report package not valid when building it for the first time. --- build/recipes/build_pkgs/build_pkgs.py | 42 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/build/recipes/build_pkgs/build_pkgs.py b/build/recipes/build_pkgs/build_pkgs.py index ad50462f7..f542b7b3b 100644 --- a/build/recipes/build_pkgs/build_pkgs.py +++ b/build/recipes/build_pkgs/build_pkgs.py @@ -1,16 +1,38 @@ import subprocess -def get_pkg_list(): +def get_dirs(): """ - Run a couple shell commands to parse the metadata directory for its packages. - :return: List of packages in metadata directory + Finds all subdirectories containing setup.py files. + :return: List of directories as strings. """ - find_proc = subprocess.run(["find", "build/metadata", - "-name", "meta.yaml"], - stdout=subprocess.PIPE) - paths = find_proc.stdout.decode('utf-8') - fmt_paths = paths.replace("build/metadata/", "").replace("/meta.yaml", "") - return fmt_paths.split('\n') + find = subprocess.run([ + 'find', '.', '-name', 'setup.py', '-not', '-path', './build/recipes/*' + ], stdout=subprocess.PIPE) + dirs = find.stdout.decode('utf-8').split('\n') + dirs_cpy = dirs + + for i, d in enumerate(dirs_cpy): + dirs[i] = d.replace('/setup.py', '') + + return dirs + +def get_names(dirs): + """ + Generate list of subproject names based on the rule that the name of the + subproject directory will be the name of the subproject. + :return: List of names as strings. + """ + names = [] + for d in dirs: + if d != '': + name = d.split('/')[-1] + + if name == "archive": + # Case with ./services/archive having special dir structure + name = "services" + names.append(name) + + return names class Recipe: def __init__(self, buildout, name, options): @@ -23,7 +45,7 @@ class Recipe: """ self.name = name self.options = options - self.pkg_list = get_pkg_list() + self.pkg_list = get_names(get_dirs()) def install(self): """ -- GitLab