Skip to content

Commit

Permalink
Merge branch 'main' into b/lock-diff-bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich authored Dec 20, 2024
2 parents 0d50d6d + 8dec871 commit 315f54f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
5 changes: 2 additions & 3 deletions manager/manager_cmds/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
51 changes: 51 additions & 0 deletions scripts/recursive_develop.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 315f54f

Please sign in to comment.