-
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.
Updates based on use for my dotfiles repo (#597)
* Refactor spack-manager to be a plugin (#577) * Refactor spack-manager to be a plugin * Update create-dev-env (#580) * Add pytest compatible patch replacement * Rework unit tests for create_dev_env * Revamp develop tests (#581) * Revamp develop tests * Give env a more specific name * Add fixture to register extension in mutable config * Update tests and calling args * Restore the external command (#582) * Restore the external command * Restore deleted line * Remove some SPACK_MANAGER env variable deps * Missed delete * Add documentation for how to setup a new project (#583) * Add introduction to projects concept * Update the project creation docs - Covers creating and populating configs * Machine detection process explained. * More updates, moving into repos * clean any projects that are loaded for unit tests * Fix doc reference and unit-test * Really fix unit-tests this time * Remove breakpoints * Make code certain a project exists * Remove unused problematic code * Add installation procedure (#586) * Add installation procedure * Fix path * Add include command (#587) * Add support for quick-commands (#588) * Add support for quick-commands * Remove lingering env var * Default view to false * Fix unit-tests * Style * Retool projects core (#589) * Retool projects core Split projects object and concept out of the manager module so they are created/updated each use * Clean up * Add interface for adding and removing projects * Style * Make include relative again * Add a `--project` filter for finding machines and creating environments (#590) * Add --project filter * Add to env creation * Style * Add a tool for configuring a new platform * Update platform_configure_tool.py * Fix scope * Add config location to find-machine * Style and test * Fix missing import * Fix unit test * F/make (#601) * Add 'make' command * Updates for spack-manager parsing * Add a -j arg for most common use case * Style and docs * Add first unit-test * Style
- Loading branch information
1 parent
6c893a4
commit 2b1d8a2
Showing
11 changed files
with
254 additions
and
43 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 |
---|---|---|
@@ -1,42 +1,37 @@ | ||
extensions = ['myst_parser'] | ||
extensions = ["myst_parser"] | ||
myst_heading_anchors = 3 | ||
templates_path = ['_templates'] | ||
master_doc = 'index' | ||
project = u'Spack-Manager' | ||
copyright = u'Phil Sakievich' | ||
author = u'Phil Sakievich' | ||
version = u'0.1' | ||
release = u'0.1' | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
pygments_style = 'sphinx' | ||
templates_path = ["_templates"] | ||
master_doc = "index" | ||
project = "Spack-Manager" | ||
copyright = "Phil Sakievich" | ||
author = "Phil Sakievich" | ||
version = "0.1" | ||
release = "0.1" | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
pygments_style = "sphinx" | ||
todo_include_todos = False | ||
numfig = True | ||
numfig_format = {'figure': '%s', 'table': '%s', 'code-block': '%s'} | ||
html_theme = 'sphinx_rtd_theme' | ||
numfig_format = {"figure": "%s", "table": "%s", "code-block": "%s"} | ||
html_theme = "sphinx_rtd_theme" | ||
html_static_path = [] | ||
html_theme_options = { | ||
'navigation_depth': 3 | ||
} | ||
html_theme_options = {"navigation_depth": 3} | ||
html_show_sourcelink = True | ||
html_show_copyright = False | ||
htmlhelp_basename = 'spack-manager-doc' | ||
latex_elements = { | ||
} | ||
htmlhelp_basename = "spack-manager-doc" | ||
latex_elements = {} | ||
latex_documents = [ | ||
(master_doc, 'spack-manager.tex', u'Spack-Manager Documentation', | ||
author, 'manual'), | ||
] | ||
man_pages = [ | ||
(master_doc, 'spack-manager', u'Spack-Manager Documentation', | ||
[author], 1) | ||
(master_doc, "spack-manager.tex", "Spack-Manager Documentation", author, "manual") | ||
] | ||
man_pages = [(master_doc, "spack-manager", "Spack-Manager Documentation", [author], 1)] | ||
texinfo_documents = [ | ||
(master_doc, 'spack-manager', u'Spack-Manager Documentation', | ||
author, 'Spack-Manager', 'One line description of project.', | ||
'Miscellaneous'), | ||
( | ||
master_doc, | ||
"spack-manager", | ||
"Spack-Manager Documentation", | ||
author, | ||
"Spack-Manager", | ||
"One line description of project.", | ||
"Miscellaneous", | ||
) | ||
] | ||
source_suffix = { | ||
'.rst': 'restructuredtext', | ||
'.txt': 'markdown', | ||
'.md': 'markdown', | ||
} | ||
source_suffix = {".rst": "restructuredtext", ".txt": "markdown", ".md": "markdown"} |
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
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
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,94 @@ | ||
# Copyright (c) 2022, National Technology & Engineering Solutions of Sandia, | ||
# LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. | ||
# Government retains certain rights in this software. | ||
# | ||
# This software is released under the BSD 3-clause license. See LICENSE file | ||
# for more details. | ||
|
||
import os | ||
|
||
import llnl.util.tty as tty | ||
from llnl.util.filesystem import working_dir | ||
|
||
import spack.build_environment as build_environment | ||
import spack.builder | ||
import spack.cmd | ||
import spack.paths | ||
from spack.util.executable import Executable | ||
|
||
""" | ||
This was originally implemented by Tim Fuller @tjfulle | ||
With his permission it is being published in the spack manager | ||
subset of commands | ||
""" | ||
description = "make SPEC directly with `make` or `ninja`" | ||
section = "manager" | ||
level = "short" | ||
|
||
|
||
def setup_parser(parser): | ||
parser.add_argument( | ||
"spec", metavar="SPEC", nargs="+", help="Spack package to build (must be a develop spec)" | ||
) | ||
build_args = parser.add_mutually_exclusive_group() | ||
build_args.add_argument( | ||
"--args", | ||
"-a", | ||
default="", | ||
required=False, | ||
help="Additional arguments to pass to make as a string i.e. `--args='test -j16'`", | ||
) | ||
build_args.add_argument( | ||
"-j", | ||
type=int, | ||
required=False, | ||
help="number of ranks to build with (specialized implementation of --args)", | ||
) | ||
|
||
|
||
def make(parser, args): | ||
env = spack.cmd.require_active_env(cmd_name="make") | ||
specs = spack.cmd.parse_specs(args.spec) | ||
if args.j: | ||
extra_make_args = [f"-j{args.j}"] | ||
else: | ||
extra_make_args = args.args.split() | ||
if not specs: | ||
tty.die("You must supply a spec.") | ||
if len(specs) != 1: | ||
tty.die("Too many specs. Supply only one.") | ||
spec = env.matching_spec(specs[0]) | ||
if spec is None: | ||
tty.die(f"{specs[0]}: spec not found in environment") | ||
elif not spec.is_develop: | ||
tty.die(f"{specs[0]}: must be a develop spec") | ||
pkg = spec.package | ||
builder = spack.builder.create(pkg) | ||
if hasattr(builder, "build_directory"): | ||
build_directory = os.path.normpath(os.path.join(pkg.stage.path, builder.build_directory)) | ||
else: | ||
build_directory = pkg.stage.source_path | ||
try: | ||
build_environment.setup_package(spec.package, False, "build") | ||
except TypeError: | ||
build_environment.setup_package(spec.package, False) | ||
|
||
if not os.path.isdir(build_directory): | ||
tty.die( | ||
( | ||
"Build directory does not exist. " | ||
"Please run `spack install` to ensure the build is " | ||
"configured properly" | ||
) | ||
) | ||
|
||
with working_dir(build_directory): | ||
make_program = "ninja" if os.path.exists("build.ninja") else "make" | ||
make = Executable(make_program) | ||
make(*extra_make_args) | ||
|
||
|
||
def add_command(parser, command_dict): | ||
subparser = parser.add_parser("make", help=description) | ||
setup_parser(subparser) | ||
command_dict["make"] = make |
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,49 @@ | ||
#! /usr/bin/env spack-python | ||
import argparse | ||
import os | ||
import pathlib | ||
|
||
import spack.main | ||
import spack.util.spack_yaml as syaml | ||
from spack.util.module_cmd import module | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("input", help="input file describing what to configure") | ||
output_types = parser.add_mutually_exclusive_group(required=True) | ||
output_types.add_argument("--output", help="location where the configs should get written") | ||
output_types.add_argument("--scope", help="spack scope where the configs should get written") | ||
|
||
args = parser.parse_args() | ||
|
||
input_path = pathlib.PurePath(args.input) | ||
if args.output: | ||
output_path = pathlib.PurePath(args.output) | ||
os.environ["SPACK_USER_CONFIG_PATH"] = str(output_path) | ||
scope = "user" | ||
else: | ||
scope = args.scope | ||
|
||
exe_env = os.environ.copy() | ||
|
||
with open(input_path, "r") as f: | ||
manifest = syaml.load(f) | ||
|
||
compiler = spack.main.SpackCommand("compiler", subprocess=True) | ||
external_cmd = spack.main.SpackCommand("external", subprocess=True) | ||
|
||
if "compilers" in manifest: | ||
for c in manifest["compilers"]: | ||
module("load", c) | ||
print(compiler("find", "--scope", scope, env=exe_env)) | ||
module("unload", c) | ||
|
||
if "externals" in manifest: | ||
print(external_cmd("find", "--scope", scope, *manifest["externals"], env=exe_env)) | ||
|
||
if "modules" in manifest: | ||
for entry in manifest["modules"]: | ||
m = entry["module"] | ||
p = entry["packages"] | ||
module("load", m) | ||
print(external_cmd("find", "--scope", scope, *p, env=exe_env)) | ||
module("unload", m) |
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
Oops, something went wrong.