summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-07-21 14:05:49 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2021-07-21 07:22:07 -0700
commita68abc15c5b1b8266130f765d1bee6290e71fa7c (patch)
treef931f7d329c41da47e3a94354e2ddc9bf3bd19a3 /lib
parent9237a9f2449d6f14390f8f5c5661d58444ba66b0 (diff)
downloadspack-a68abc15c5b1b8266130f765d1bee6290e71fa7c.tar.gz
spack-a68abc15c5b1b8266130f765d1bee6290e71fa7c.tar.bz2
spack-a68abc15c5b1b8266130f765d1bee6290e71fa7c.tar.xz
spack-a68abc15c5b1b8266130f765d1bee6290e71fa7c.zip
Fix bootstrap from sources
#24095 introduced a couple of bugs, which are fixed here: 1. The module path is computed incorrectly for bootstrapped clingo 2. We remove too many paths for `sys.path` in case of failures
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/bootstrap.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py
index af12f095f7..92bbb2fa42 100644
--- a/lib/spack/spack/bootstrap.py
+++ b/lib/spack/spack/bootstrap.py
@@ -93,15 +93,14 @@ def make_module_available(module, spec=None, install=False):
for ispec in installed_specs:
# TODO: make sure run-environment is appropriate
- module_path = os.path.join(ispec.prefix,
- ispec['python'].package.site_packages_dir)
+ module_path = ispec['python'].package.get_python_lib(prefix=ispec.prefix)
try:
sys.path.append(module_path)
__import__(module)
return
except ImportError:
tty.warn("Spec %s did not provide module %s" % (ispec, module))
- sys.path = sys.path[:-2]
+ sys.path = sys.path[:-1]
def _raise_error(module_name, module_spec):
error_msg = 'cannot import module "{0}"'.format(module_name)
@@ -118,14 +117,13 @@ def make_module_available(module, spec=None, install=False):
spec.concretize()
spec.package.do_install()
- module_path = os.path.join(spec.prefix,
- spec['python'].package.site_packages_dir)
+ module_path = spec['python'].package.get_python_lib(prefix=spec.prefix)
try:
sys.path.append(module_path)
__import__(module)
return
except ImportError:
- sys.path = sys.path[:-2]
+ sys.path = sys.path[:-1]
_raise_error(module, spec)