summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2019-12-02 23:05:02 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-02 14:05:02 -0800
commitbca59f8d834f17bfcd851909f07b3d8a8ad2f6a3 (patch)
treecf3012c741f3eb23b8d5caf2a06e33d370dade31 /var
parent1b624b9d45862d35e6112298c0ce98b9f9b7d348 (diff)
downloadspack-bca59f8d834f17bfcd851909f07b3d8a8ad2f6a3.tar.gz
spack-bca59f8d834f17bfcd851909f07b3d8a8ad2f6a3.tar.bz2
spack-bca59f8d834f17bfcd851909f07b3d8a8ad2f6a3.tar.xz
spack-bca59f8d834f17bfcd851909f07b3d8a8ad2f6a3.zip
Speedup environment activation (#13557)
* Add a transaction around repeated calls to `spec.prefix` in the activation process * cache the computation of home in the python package to speed up setting deps * ensure that module-scope variables are only set *once* per module
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/python/package.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
index 15901872e9..a92d1c6c79 100644
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -163,6 +163,9 @@ class Python(AutotoolsPackage):
_DISTUTIL_CACHE_FILENAME = 'sysconfig.json'
_distutil_vars = None
+ # Used to cache home locations, since computing them might be expensive
+ _homes = {}
+
# An in-source build with --enable-optimizations fails for python@3.X
build_directory = 'spack-build'
@@ -622,8 +625,11 @@ class Python(AutotoolsPackage):
``packages.yaml`` unknowingly. Query the python executable to
determine exactly where it is installed."""
- prefix = self.get_config_var('prefix')
- return Prefix(prefix)
+ dag_hash = self.spec.dag_hash()
+ if dag_hash not in self._homes:
+ prefix = self.get_config_var('prefix')
+ self._homes[dag_hash] = Prefix(prefix)
+ return self._homes[dag_hash]
@property
def libs(self):