Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage: make source_path available before stage is built #11528

Merged
merged 5 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/spack/llnl/util/tty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def msg(message, *args, **kwargs):
if not msg_enabled():
return

if isinstance(message, Exception):
message = "%s: %s" % (message.__class__.__name__, str(message))

newline = kwargs.get('newline', True)
st_text = ""
if _stacktrace:
Expand All @@ -156,6 +159,9 @@ def msg(message, *args, **kwargs):


def info(message, *args, **kwargs):
if isinstance(message, Exception):
message = "%s: %s" % (message.__class__.__name__, str(message))

format = kwargs.get('format', '*b')
stream = kwargs.get('stream', sys.stdout)
wrap = kwargs.get('wrap', False)
Expand Down
13 changes: 7 additions & 6 deletions lib/spack/spack/binary_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,22 +321,22 @@ def build_tarball(spec, outdir, force=False, rel=False, unsigned=False,
# create info for later relocation and create tar
write_buildinfo_file(spec.prefix, workdir, rel=rel)

# optinally make the paths in the binaries relative to each other
# optionally make the paths in the binaries relative to each other
# in the spack install tree before creating tarball
if rel:
try:
make_package_relative(workdir, spec.prefix, allow_root)
except Exception as e:
shutil.rmtree(workdir)
shutil.rmtree(tarfile_dir)
tty.die(str(e))
tty.die(e)
else:
try:
make_package_placeholder(workdir, spec.prefix, allow_root)
except Exception as e:
shutil.rmtree(workdir)
shutil.rmtree(tarfile_dir)
tty.die(str(e))
tty.die(e)
# create compressed tarball of the install prefix
with closing(tarfile.open(tarfile_path, 'w:gz')) as tar:
tar.add(name='%s' % workdir,
Expand Down Expand Up @@ -521,7 +521,7 @@ def extract_tarball(spec, filename, allow_root=False, unsigned=False,
Gpg.verify('%s.asc' % specfile_path, specfile_path)
except Exception as e:
shutil.rmtree(tmpdir)
tty.die(str(e))
tty.die(e)
else:
shutil.rmtree(tmpdir)
raise NoVerifyException(
Expand Down Expand Up @@ -575,7 +575,7 @@ def extract_tarball(spec, filename, allow_root=False, unsigned=False,
relocate_package(workdir, allow_root)
except Exception as e:
shutil.rmtree(workdir)
tty.die(str(e))
tty.die(e)
# Delay creating spec.prefix until verification is complete
# and any relocation has been done.
else:
Expand Down Expand Up @@ -809,7 +809,8 @@ def _download_buildcache_entry(mirror_root, descriptions):

try:
stage.fetch()
except fs.FetchError:
except fs.FetchError as e:
tty.debug(e)
if fail_if_missing:
tty.error('Failed to download required url {0}'.format(url))
return False
Expand Down
8 changes: 4 additions & 4 deletions lib/spack/spack/build_systems/autotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def _do_patch_config_guess(self):
check_call([my_config_guess], stdout=PIPE, stderr=PIPE)
# The package's config.guess already runs OK, so just use it
return
except Exception:
pass
except Exception as e:
tty.debug(e)
else:
return

Expand Down Expand Up @@ -142,8 +142,8 @@ def _do_patch_config_guess(self):
os.chmod(my_config_guess, mod)
shutil.copyfile(config_guess, my_config_guess)
return
except Exception:
pass
except Exception as e:
tty.debug(e)

raise RuntimeError('Failed to find suitable config.guess')

Expand Down
1 change: 1 addition & 0 deletions lib/spack/spack/cmd/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def install(parser, args, **kwargs):
specs = spack.cmd.parse_specs(
args.package, concretize=True, tests=tests)
except SpackError as e:
tty.debug(e)
reporter.concretization_report(e.message)
raise

Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/cmd/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def location(parser, args):
print(pkg.stage.path)

else: # args.build_dir is the default.
if not pkg.stage.source_path:
if not pkg.stage.expanded:
tty.die("Build directory does not exist yet. "
"Run this to create it:",
"spack stage " + " ".join(args.spec))
Expand Down
1 change: 1 addition & 0 deletions lib/spack/spack/cmd/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def _read_specs_from_file(filename):
s.package
specs.append(s)
except SpackError as e:
tty.debug(e)
tty.die("Parse error in %s, line %d:" % (filename, i + 1),
">>> " + string, str(e))
return specs
Expand Down
1 change: 1 addition & 0 deletions lib/spack/spack/cmd/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def refresh(module_type, specs, args):
try:
x.write(overwrite=True)
except Exception as e:
tty.debug(e)
msg = 'Could not write module file [{0}]'
tty.warn(msg.format(x.layout.filename))
tty.warn('\t--> {0} <--'.format(str(e)))
Expand Down
6 changes: 4 additions & 2 deletions lib/spack/spack/cmd/upload_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,17 @@ def upload_spec(args):
try:
spec = Spec(args.spec)
spec.concretize()
except Exception:
except Exception as e:
tty.debug(e)
tty.error('Unable to concrectize spec from string {0}'.format(
args.spec))
sys.exit(1)
else:
try:
with open(args.spec_yaml, 'r') as fd:
spec = Spec.from_yaml(fd.read())
except Exception:
except Exception as e:
tty.debug(e)
tty.error('Unable to concrectize spec from yaml {0}'.format(
args.spec_yaml))
sys.exit(1)
Expand Down
6 changes: 3 additions & 3 deletions lib/spack/spack/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,7 @@ def _construct_from_directory_layout(self, directory_layout, old_data):
except Exception as e:
# Something went wrong, so the spec was not restored
# from old data
tty.debug(e.message)
pass
tty.debug(e)

self._check_ref_counts()

Expand Down Expand Up @@ -659,7 +658,8 @@ def _write(self, type, value, traceback):
with open(temp_file, 'w') as f:
self._write_to_file(f)
os.rename(temp_file, self._index_path)
except BaseException:
except BaseException as e:
tty.debug(e)
# Clean up temp file if something goes wrong.
if os.path.exists(temp_file):
os.remove(temp_file)
Expand Down