diff --git a/manager/manager_cmds/external.py b/manager/manager_cmds/external.py index 10051953..06293e01 100644 --- a/manager/manager_cmds/external.py +++ b/manager/manager_cmds/external.py @@ -11,7 +11,6 @@ import spack import spack.config -import spack.detection import spack.environment as ev import spack.util.spack_yaml as syaml from spack.detection.common import _pkg_config_dict @@ -46,11 +45,11 @@ def create_external_detected_spec(env, spec): return None # attempt to return a valid spec using the current spack instance try: - return spack.detection.DetectedPackage(Spec.from_detection(pruned_spec), prefix) + return Spec.from_detection(pruned_spec, external_path=prefix) except spack.variant.UnknownVariantError: # if it is an old spec then a variant could have changed so we just create a spec from the # pruned_spec string - return spack.detection.DetectedPackage(Spec(pruned_spec), prefix) + return Spec(pruned_spec, external_path=prefix) def assemble_dict_of_detected_externals(env, exclude, include): diff --git a/scripts/recursive_develop.py b/scripts/recursive_develop.py new file mode 100755 index 00000000..941d3ec2 --- /dev/null +++ b/scripts/recursive_develop.py @@ -0,0 +1,51 @@ +#! /usr/bin/env spack-python +import argparse + +import spack.cmd +import spack.main + +develop = spack.main.SpackCommand("develop") +#def develop(*args): +# print(f"Calling spack develop on {args}") + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('spec', help='Spec to recursively call spack develop until the root is hit.', default=None) + parser.add_argument("--forward", "-f", help="string containing arguments to forward to 'spack develop' calls") + return parser.parse_args() + +def develop_dependents(input, env, develop_args=[]): + specs = spack.cmd.parse_specs(input) + if len(specs) > 1: + raise SpackError("spack develop requires at most one named spec") + spec = specs[0] + + calling_args=develop_args+[input] + + print(f"Calling spack develop {' '.join(calling_args)}") + + develop(*develop_args) + + concrete_specs = env.all_matching_specs(spec) + if not concrete_specs: + return + for cspec in concrete_specs: + for p in cspec.traverse_edges(direction="parents"): + calling_args=develop_args+[p.spec.format("{name}@{version}")] + develop(*calling_args) + return + + +def main(): + args = parse_args() + env = spack.cmd.require_active_env(cmd_name="recursive") + if args.forward: + develop_args = args.forward.split() + else: + develop_args = [] + with env: + develop_dependents(args.spec, env, develop_args) + + +if __name__ == "__main__": + main()