do_install : can stop at an arbitrary phase
Now uses a StopIteration exception as a signal
This commit is contained in:
parent
9af964a6d6
commit
513cdd580e
1 changed files with 18 additions and 23 deletions
|
@ -104,7 +104,8 @@ def phase_wrapper(spec, prefix):
|
||||||
# and give them the chance to fail
|
# and give them the chance to fail
|
||||||
for check in self.sanity_checks:
|
for check in self.sanity_checks:
|
||||||
check(instance)
|
check(instance)
|
||||||
|
if getattr(instance, 'last_phase', None) == self.name:
|
||||||
|
raise StopIteration('Stopping at \'{0}\' phase'.format(self.name))
|
||||||
return phase_wrapper
|
return phase_wrapper
|
||||||
|
|
||||||
|
|
||||||
|
@ -1047,15 +1048,9 @@ def do_install(self,
|
||||||
# Set run_tests flag before starting build.
|
# Set run_tests flag before starting build.
|
||||||
self.run_tests = run_tests
|
self.run_tests = run_tests
|
||||||
|
|
||||||
last_phase = kwargs.get('stop_at', None)
|
self.last_phase = kwargs.get('stop_at', None)
|
||||||
phases_to_be_executed = self.phases
|
if self.last_phase is not None and self.last_phase not in self.phases:
|
||||||
# We want to stop early
|
tty.die('\'{0.last_phase}\' is not among the allowed phases for package {0.name}'.format(self))
|
||||||
if last_phase is not None:
|
|
||||||
if last_phase not in self.phases:
|
|
||||||
raise KeyError('phase {0} is not among the allowed phases for package {1}'.format(last_phase, self))
|
|
||||||
idx = self.phases.index(last_phase)
|
|
||||||
phases_to_be_executed = self.phases[:idx + 1]
|
|
||||||
keep_stage = True
|
|
||||||
|
|
||||||
# Set parallelism before starting build.
|
# Set parallelism before starting build.
|
||||||
self.make_jobs = make_jobs
|
self.make_jobs = make_jobs
|
||||||
|
@ -1097,13 +1092,11 @@ def build_process():
|
||||||
self.log_path = log_path
|
self.log_path = log_path
|
||||||
self.env_path = env_path
|
self.env_path = env_path
|
||||||
dump_environment(env_path)
|
dump_environment(env_path)
|
||||||
for phase_name, phase in zip(phases_to_be_executed, self._InstallPhase_phases):
|
log_redirection = log_output(log_path, verbose, sys.stdout.isatty(), True)
|
||||||
log_file = open(log_path, 'a')
|
for phase_name, phase in zip(self.phases, self._InstallPhase_phases):
|
||||||
tty.msg('Executing phase : \'{0}\''.format(phase_name))
|
tty.msg('Executing phase : \'{0}\''.format(phase_name))
|
||||||
with log_output(log_file, verbose, sys.stdout.isatty(), True):
|
with log_redirection:
|
||||||
getattr(self, phase)(self.spec, self.prefix)
|
getattr(self, phase)(self.spec, self.prefix)
|
||||||
if len(phases_to_be_executed) != len(self._InstallPhase_phases):
|
|
||||||
return
|
|
||||||
self.log()
|
self.log()
|
||||||
# Run post install hooks before build stage is removed.
|
# Run post install hooks before build stage is removed.
|
||||||
spack.hooks.post_install(self)
|
spack.hooks.post_install(self)
|
||||||
|
@ -1125,7 +1118,6 @@ def build_process():
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if len(phases_to_be_executed) == len(self.phases):
|
|
||||||
# Create the install prefix and fork the build process.
|
# Create the install prefix and fork the build process.
|
||||||
spack.install_layout.create_install_directory(self.spec)
|
spack.install_layout.create_install_directory(self.spec)
|
||||||
except directory_layout.InstallDirectoryAlreadyExistsError:
|
except directory_layout.InstallDirectoryAlreadyExistsError:
|
||||||
|
@ -1142,6 +1134,13 @@ def build_process():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
spack.build_environment.fork(self, build_process, dirty=dirty)
|
spack.build_environment.fork(self, build_process, dirty=dirty)
|
||||||
|
# note: PARENT of the build process adds the new package to
|
||||||
|
# the database, so that we don't need to re-read from file.
|
||||||
|
spack.installed_db.add(self.spec, self.prefix, explicit=explicit)
|
||||||
|
except StopIteration as e:
|
||||||
|
tty.msg(e.message)
|
||||||
|
if not keep_prefix:
|
||||||
|
self.remove_prefix()
|
||||||
except:
|
except:
|
||||||
# remove the install prefix if anything went wrong during install.
|
# remove the install prefix if anything went wrong during install.
|
||||||
if not keep_prefix:
|
if not keep_prefix:
|
||||||
|
@ -1154,11 +1153,6 @@ def build_process():
|
||||||
wrap=False)
|
wrap=False)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# note: PARENT of the build process adds the new package to
|
|
||||||
# the database, so that we don't need to re-read from file.
|
|
||||||
if len(phases_to_be_executed) == len(self.phases):
|
|
||||||
spack.installed_db.add(self.spec, self.prefix, explicit=explicit)
|
|
||||||
|
|
||||||
def log(self):
|
def log(self):
|
||||||
# Copy provenance into the install directory on success
|
# Copy provenance into the install directory on success
|
||||||
log_install_path = spack.install_layout.build_log_path(
|
log_install_path = spack.install_layout.build_log_path(
|
||||||
|
@ -1571,6 +1565,7 @@ def install(self, spec, prefix):
|
||||||
|
|
||||||
PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix)
|
PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix)
|
||||||
|
|
||||||
|
|
||||||
class AutotoolsPackage(PackageBase):
|
class AutotoolsPackage(PackageBase):
|
||||||
phases = ['autoreconf', 'configure', 'build', 'install']
|
phases = ['autoreconf', 'configure', 'build', 'install']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue