summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Green <greenc@fnal.gov>2019-03-26 17:40:49 -0500
committerPeter Scheibel <scheibel1@llnl.gov>2019-03-26 17:40:49 -0500
commite88c1d585cb3a0cb2a6ba2f482b9a7389ea03db1 (patch)
treed39385041e07677365b077904f9350ef77837206 /lib
parent7df70154dd32950529976f896e622cf369fd89b4 (diff)
downloadspack-e88c1d585cb3a0cb2a6ba2f482b9a7389ea03db1.tar.gz
spack-e88c1d585cb3a0cb2a6ba2f482b9a7389ea03db1.tar.bz2
spack-e88c1d585cb3a0cb2a6ba2f482b9a7389ea03db1.tar.xz
spack-e88c1d585cb3a0cb2a6ba2f482b9a7389ea03db1.zip
Move CMakePackage build directory to base stage directory (#8431)
Change the location of the CMake build area from the staged source directory to the stage base directory. This change allows CMake packages to refer to the build directory in setup_environment (e.g. if tests need to have a directory in PATH): Staging happens after the call to setup_environment(), and if the stage area does not exist, then spec.stage.source_path returns None. To accommodate this change, archived files (like config.log for Autotools packages) are archived relative to the stage base directory rather than the expanded source directory. Other packages (those not using CMake) will still use the staged source directory as the default working directory for builds (and will still be unable to reference this directory in setup_environment())
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_systems/cmake.py2
-rw-r--r--lib/spack/spack/package.py20
-rw-r--r--lib/spack/spack/test/cmd/install.py4
-rw-r--r--lib/spack/spack/test/conftest.py36
4 files changed, 30 insertions, 32 deletions
diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py
index 5d70994bd4..92c319b0ab 100644
--- a/lib/spack/spack/build_systems/cmake.py
+++ b/lib/spack/spack/build_systems/cmake.py
@@ -218,7 +218,7 @@ class CMakePackage(PackageBase):
:return: directory where to build the package
"""
- return os.path.join(self.stage.source_path, 'spack-build')
+ return os.path.join(self.stage.path, 'spack-build')
def cmake_args(self):
"""Produces a list containing all the arguments that must be passed to
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 76e1595daf..9114297c1d 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -739,17 +739,11 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
@property
def env_path(self):
- if self.stage.source_path is None:
- return None
- else:
- return os.path.join(self.stage.source_path, 'spack-build.env')
+ return os.path.join(self.stage.path, 'spack-build.env')
@property
def log_path(self):
- if self.stage.source_path is None:
- return None
- else:
- return os.path.join(self.stage.source_path, 'spack-build.out')
+ return os.path.join(self.stage.path, 'spack-build.out')
def _make_fetcher(self):
# Construct a composite fetcher that always contains at least
@@ -1695,7 +1689,7 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
# Archive the environment used for the build
install(self.env_path, env_install_path)
# Finally, archive files that are specific to each package
- with working_dir(self.stage.source_path):
+ with working_dir(self.stage.path):
errors = StringIO()
target_dir = os.path.join(
spack.store.layout.metadata_path(self.spec),
@@ -1703,9 +1697,9 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
for glob_expr in self.archive_files:
# Check that we are trying to copy things that are
- # in the source_path tree (not arbitrary files)
+ # in the stage tree (not arbitrary files)
abs_expr = os.path.realpath(glob_expr)
- if os.path.realpath(self.stage.source_path) not in abs_expr:
+ if os.path.realpath(self.stage.path) not in abs_expr:
errors.write(
'[OUTSIDE SOURCE PATH]: {0}\n'.format(glob_expr)
)
@@ -1714,7 +1708,7 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
# folder, make it relative and check for matches
if os.path.isabs(glob_expr):
glob_expr = os.path.relpath(
- glob_expr, self.stage.source_path
+ glob_expr, self.stage.path
)
files = glob.glob(glob_expr)
for f in files:
@@ -1769,7 +1763,7 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
if self.installed:
return spack.store.layout.build_log_path(self.spec)
else:
- return os.path.join(self.stage.source_path, 'spack-build.out')
+ return os.path.join(self.stage.path, 'spack-build.out')
@classmethod
def inject_flags(cls, name, flags):
diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py
index 98aa735960..1645cd4b0e 100644
--- a/lib/spack/spack/test/cmd/install.py
+++ b/lib/spack/spack/test/cmd/install.py
@@ -413,7 +413,9 @@ def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch,
archive_dir = os.path.join(
spack.store.layout.metadata_path(s), 'archived-files'
)
- config_log = os.path.join(archive_dir, 'config.log')
+ config_log = os.path.join(archive_dir,
+ mock_archive.expanded_archive_basedir,
+ 'config.log')
assert os.path.exists(config_log)
errors_txt = os.path.join(archive_dir, 'errors.txt')
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 774de1cb2f..d158cb0f45 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -487,12 +487,12 @@ def mock_archive(tmpdir_factory):
tar = spack.util.executable.which('tar', required=True)
tmpdir = tmpdir_factory.mktemp('mock-archive-dir')
- repo_name = 'mock-archive-repo'
- tmpdir.ensure(repo_name, dir=True)
- repodir = tmpdir.join(repo_name)
+ expanded_archive_basedir = 'mock-archive-repo'
+ tmpdir.ensure(expanded_archive_basedir, dir=True)
+ repodir = tmpdir.join(expanded_archive_basedir)
# Create the configure script
- configure_path = str(tmpdir.join(repo_name, 'configure'))
+ configure_path = str(tmpdir.join(expanded_archive_basedir, 'configure'))
with open(configure_path, 'w') as f:
f.write(
"#!/bin/sh\n"
@@ -509,18 +509,20 @@ def mock_archive(tmpdir_factory):
# Archive it
with tmpdir.as_cwd():
- archive_name = '{0}.tar.gz'.format(repo_name)
- tar('-czf', archive_name, repo_name)
+ archive_name = '{0}.tar.gz'.format(expanded_archive_basedir)
+ tar('-czf', archive_name, expanded_archive_basedir)
Archive = collections.namedtuple('Archive',
- ['url', 'path', 'archive_file'])
+ ['url', 'path', 'archive_file',
+ 'expanded_archive_basedir'])
archive_file = str(tmpdir.join(archive_name))
# Return the url
yield Archive(
url=('file://' + archive_file),
archive_file=archive_file,
- path=str(repodir))
+ path=str(repodir),
+ expanded_archive_basedir=expanded_archive_basedir)
@pytest.fixture(scope='session')
@@ -531,9 +533,9 @@ def mock_git_repository(tmpdir_factory):
git = spack.util.executable.which('git', required=True)
tmpdir = tmpdir_factory.mktemp('mock-git-repo-dir')
- repo_name = 'mock-git-repo'
- tmpdir.ensure(repo_name, dir=True)
- repodir = tmpdir.join(repo_name)
+ expanded_archive_basedir = 'mock-git-repo'
+ tmpdir.ensure(expanded_archive_basedir, dir=True)
+ repodir = tmpdir.join(expanded_archive_basedir)
# Initialize the repository
with repodir.as_cwd():
@@ -605,9 +607,9 @@ def mock_hg_repository(tmpdir_factory):
hg = spack.util.executable.which('hg', required=True)
tmpdir = tmpdir_factory.mktemp('mock-hg-repo-dir')
- repo_name = 'mock-hg-repo'
- tmpdir.ensure(repo_name, dir=True)
- repodir = tmpdir.join(repo_name)
+ expanded_archive_basedir = 'mock-hg-repo'
+ tmpdir.ensure(expanded_archive_basedir, dir=True)
+ repodir = tmpdir.join(expanded_archive_basedir)
get_rev = lambda: hg('id', '-i', output=str).strip()
@@ -651,9 +653,9 @@ def mock_svn_repository(tmpdir_factory):
svnadmin = spack.util.executable.which('svnadmin', required=True)
tmpdir = tmpdir_factory.mktemp('mock-svn-stage')
- repo_name = 'mock-svn-repo'
- tmpdir.ensure(repo_name, dir=True)
- repodir = tmpdir.join(repo_name)
+ expanded_archive_basedir = 'mock-svn-repo'
+ tmpdir.ensure(expanded_archive_basedir, dir=True)
+ repodir = tmpdir.join(expanded_archive_basedir)
url = 'file://' + str(repodir)
# Initialize the repository