Add --source option to spack install (#4102)
- -- source will copy source into prefix along with the package. - added a test for --source, as well
This commit is contained in:
parent
359b21c888
commit
fa1d0a8a4d
@ -68,6 +68,9 @@ def setup_parser(subparser):
|
||||
subparser.add_argument(
|
||||
'--restage', action='store_true', dest='restage',
|
||||
help="if a partial install is detected, delete prior state")
|
||||
subparser.add_argument(
|
||||
'--source', action='store_true', dest='install_source',
|
||||
help="install source files in prefix")
|
||||
subparser.add_argument(
|
||||
'-n', '--no-checksum', action='store_true', dest='no_checksum',
|
||||
help="do not check packages against checksum")
|
||||
@ -314,6 +317,7 @@ def install(parser, args, **kwargs):
|
||||
'keep_prefix': args.keep_prefix,
|
||||
'keep_stage': args.keep_stage,
|
||||
'restage': args.restage,
|
||||
'install_source': args.install_source,
|
||||
'install_deps': 'dependencies' in args.things_to_install,
|
||||
'make_jobs': args.jobs,
|
||||
'run_tests': args.run_tests,
|
||||
|
@ -1193,6 +1193,7 @@ def _update_explicit_entry_in_db(self, rec, explicit):
|
||||
def do_install(self,
|
||||
keep_prefix=False,
|
||||
keep_stage=False,
|
||||
install_source=False,
|
||||
install_deps=True,
|
||||
skip_patch=False,
|
||||
verbose=False,
|
||||
@ -1213,6 +1214,8 @@ def do_install(self,
|
||||
keep_stage (bool): By default, stage is destroyed only if there
|
||||
are no exceptions during build. Set to True to keep the stage
|
||||
even with exceptions.
|
||||
install_source (bool): By default, source is not installed, but
|
||||
for debugging it might be useful to keep it around.
|
||||
install_deps (bool): Install dependencies before installing this
|
||||
package
|
||||
skip_patch (bool): Skip patch stage of build if True.
|
||||
@ -1260,6 +1263,7 @@ def do_install(self,
|
||||
dep.package.do_install(
|
||||
keep_prefix=keep_prefix,
|
||||
keep_stage=keep_stage,
|
||||
install_source=install_source,
|
||||
install_deps=install_deps,
|
||||
fake=fake,
|
||||
skip_patch=skip_patch,
|
||||
@ -1312,6 +1316,13 @@ def build_process():
|
||||
if fake:
|
||||
self.do_fake_install()
|
||||
else:
|
||||
source_path = self.stage.source_path
|
||||
if install_source and os.path.isdir(source_path):
|
||||
src_target = join_path(
|
||||
self.spec.prefix, 'share', self.name, 'src')
|
||||
tty.msg('Copying source to {0}'.format(src_target))
|
||||
install_tree(self.stage.source_path, src_target)
|
||||
|
||||
# Do the real install in the source directory.
|
||||
self.stage.chdir_to_source()
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
##############################################################################
|
||||
import argparse
|
||||
import os
|
||||
import filecmp
|
||||
|
||||
import pytest
|
||||
|
||||
@ -130,3 +131,14 @@ def test_install_output_on_python_error(builtin_mock, mock_archive, mock_fetch,
|
||||
assert isinstance(install.error, spack.build_environment.ChildError)
|
||||
assert install.error.name == 'InstallError'
|
||||
assert 'raise InstallError("Expected failure.")' in out
|
||||
|
||||
|
||||
def test_install_with_source(
|
||||
builtin_mock, mock_archive, mock_fetch, config, install_mockery):
|
||||
"""Verify that source has been copied into place."""
|
||||
install('--source', '--keep-stage', 'trivial-install-test-package')
|
||||
spec = Spec('trivial-install-test-package').concretized()
|
||||
src = os.path.join(
|
||||
spec.prefix.share, 'trivial-install-test-package', 'src')
|
||||
assert filecmp.cmp(os.path.join(mock_archive.path, 'configure'),
|
||||
os.path.join(src, 'configure'))
|
||||
|
@ -456,7 +456,7 @@ function _spack_install {
|
||||
then
|
||||
compgen -W "-h --help --only -j --jobs --keep-prefix --keep-stage
|
||||
-n --no-checksum -v --verbose --fake --clean --dirty
|
||||
--run-tests --log-format --log-file" -- "$cur"
|
||||
--run-tests --log-format --log-file --source" -- "$cur"
|
||||
else
|
||||
compgen -W "$(_all_packages)" -- "$cur"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user