Skip to content

Commit

Permalink
update spack build context type after spack/spack#35737
Browse files Browse the repository at this point in the history
  • Loading branch information
dylex committed Nov 30, 2023
1 parent e4ab4c2 commit 19ad0eb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions spack/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import nixpack
import spack

try:
from spack.context import Context
except ImportError:
class Context:
BUILD = 'build'
TEST = 'test'

# disable pre_ and post_install hooks (sbang, permissions, licensing)
def noop_hook(*args, **kwargs):
pass
Expand Down Expand Up @@ -56,7 +63,7 @@ def noop_hook(*args, **kwargs):

origenv = os.environ.copy()
# create and stash some metadata
spack.build_environment.setup_package(pkg, True, context='build')
spack.build_environment.setup_package(pkg, True, context=Context.BUILD)
os.makedirs(pkg.metadata_dir, exist_ok=True)

# log build phases to nix
Expand Down Expand Up @@ -87,7 +94,7 @@ def print_log(pkg, phase, log):
# we do this even if not testing as it may create more things (e.g., perl "extensions")
os.environ.clear()
os.environ.update(origenv)
spack.build_environment.setup_package(pkg, True, context='test')
spack.build_environment.setup_package(pkg, True, context=Context.TEST)

with open(os.path.join(spec.prefix, nixpack.NixSpec.nixSpecFile), 'w') as sf:
json.dump(spec.nixspec, sf)
Expand Down

0 comments on commit 19ad0eb

Please sign in to comment.