-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into b/lock-diff-bugs
- Loading branch information
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |