Detecting "Cray" as "linux" during bootstrap (#28726)
* bootstrap: avoid detecting "Cray" and treat the platform as "linux" * bootstrap: create a proper context manager to disable cray
This commit is contained in:
parent
a582670e15
commit
549c785227
3 changed files with 47 additions and 34 deletions
|
@ -33,6 +33,7 @@
|
||||||
import spack.spec
|
import spack.spec
|
||||||
import spack.store
|
import spack.store
|
||||||
import spack.user_environment
|
import spack.user_environment
|
||||||
|
import spack.util.environment
|
||||||
import spack.util.executable
|
import spack.util.executable
|
||||||
import spack.util.path
|
import spack.util.path
|
||||||
|
|
||||||
|
@ -65,12 +66,6 @@ def _try_import_from_store(module, query_spec, query_info=None):
|
||||||
"""
|
"""
|
||||||
# If it is a string assume it's one of the root specs by this module
|
# If it is a string assume it's one of the root specs by this module
|
||||||
if isinstance(query_spec, six.string_types):
|
if isinstance(query_spec, six.string_types):
|
||||||
bincache_platform = spack.platforms.real_host()
|
|
||||||
if str(bincache_platform) == 'cray':
|
|
||||||
bincache_platform = spack.platforms.linux.Linux()
|
|
||||||
with spack.platforms.use_platform(bincache_platform):
|
|
||||||
query_spec = str(spack.spec.Spec(query_spec))
|
|
||||||
|
|
||||||
# We have to run as part of this python interpreter
|
# We have to run as part of this python interpreter
|
||||||
query_spec += ' ^' + spec_for_current_python()
|
query_spec += ' ^' + spec_for_current_python()
|
||||||
|
|
||||||
|
@ -231,10 +226,6 @@ def _spec_and_platform(abstract_spec_str):
|
||||||
abstract_spec = spack.spec.Spec(abstract_spec_str)
|
abstract_spec = spack.spec.Spec(abstract_spec_str)
|
||||||
# On Cray we want to use Linux binaries if available from mirrors
|
# On Cray we want to use Linux binaries if available from mirrors
|
||||||
bincache_platform = spack.platforms.real_host()
|
bincache_platform = spack.platforms.real_host()
|
||||||
if str(bincache_platform) == 'cray':
|
|
||||||
bincache_platform = spack.platforms.Linux()
|
|
||||||
with spack.platforms.use_platform(bincache_platform):
|
|
||||||
abstract_spec = spack.spec.Spec(abstract_spec_str)
|
|
||||||
return abstract_spec, bincache_platform
|
return abstract_spec, bincache_platform
|
||||||
|
|
||||||
def _read_metadata(self, package_name):
|
def _read_metadata(self, package_name):
|
||||||
|
@ -372,9 +363,6 @@ def try_import(self, module, abstract_spec_str):
|
||||||
# Try to build and install from sources
|
# Try to build and install from sources
|
||||||
with spack_python_interpreter():
|
with spack_python_interpreter():
|
||||||
# Add hint to use frontend operating system on Cray
|
# Add hint to use frontend operating system on Cray
|
||||||
if str(spack.platforms.host()) == 'cray':
|
|
||||||
abstract_spec_str += ' os=fe'
|
|
||||||
|
|
||||||
concrete_spec = spack.spec.Spec(
|
concrete_spec = spack.spec.Spec(
|
||||||
abstract_spec_str + ' ^' + spec_for_current_python()
|
abstract_spec_str + ' ^' + spec_for_current_python()
|
||||||
)
|
)
|
||||||
|
@ -406,10 +394,6 @@ def try_search_path(self, executables, abstract_spec_str):
|
||||||
# might reduce compilation time by a fair amount
|
# might reduce compilation time by a fair amount
|
||||||
_add_externals_if_missing()
|
_add_externals_if_missing()
|
||||||
|
|
||||||
# Add hint to use frontend operating system on Cray
|
|
||||||
if str(spack.platforms.host()) == 'cray':
|
|
||||||
abstract_spec_str += ' os=fe'
|
|
||||||
|
|
||||||
concrete_spec = spack.spec.Spec(abstract_spec_str)
|
concrete_spec = spack.spec.Spec(abstract_spec_str)
|
||||||
if concrete_spec.name == 'patchelf':
|
if concrete_spec.name == 'patchelf':
|
||||||
concrete_spec._old_concretize(deprecation_warning=False)
|
concrete_spec._old_concretize(deprecation_warning=False)
|
||||||
|
@ -666,6 +650,7 @@ def _ensure_bootstrap_configuration():
|
||||||
bootstrap_store_path = store_path()
|
bootstrap_store_path = store_path()
|
||||||
user_configuration = _read_and_sanitize_configuration()
|
user_configuration = _read_and_sanitize_configuration()
|
||||||
with spack.environment.no_active_environment():
|
with spack.environment.no_active_environment():
|
||||||
|
with spack.platforms.prevent_cray_detection():
|
||||||
with spack.platforms.use_platform(spack.platforms.real_host()):
|
with spack.platforms.use_platform(spack.platforms.real_host()):
|
||||||
with spack.repo.use_repositories(spack.paths.packages_path):
|
with spack.repo.use_repositories(spack.paths.packages_path):
|
||||||
with spack.store.use_store(bootstrap_store_path):
|
with spack.store.use_store(bootstrap_store_path):
|
||||||
|
@ -673,11 +658,15 @@ def _ensure_bootstrap_configuration():
|
||||||
# and builtin but accounting for platform specific scopes
|
# and builtin but accounting for platform specific scopes
|
||||||
config_scopes = _bootstrap_config_scopes()
|
config_scopes = _bootstrap_config_scopes()
|
||||||
with spack.config.use_configuration(*config_scopes):
|
with spack.config.use_configuration(*config_scopes):
|
||||||
# We may need to compile code from sources, so ensure we have
|
# We may need to compile code from sources, so ensure we
|
||||||
# compilers for the current platform before switching parts.
|
# have compilers for the current platform
|
||||||
_add_compilers_if_missing()
|
_add_compilers_if_missing()
|
||||||
spack.config.set('bootstrap', user_configuration['bootstrap'])
|
spack.config.set(
|
||||||
spack.config.set('config', user_configuration['config'])
|
'bootstrap', user_configuration['bootstrap']
|
||||||
|
)
|
||||||
|
spack.config.set(
|
||||||
|
'config', user_configuration['config']
|
||||||
|
)
|
||||||
with spack.modules.disable_modules():
|
with spack.modules.disable_modules():
|
||||||
with spack_python_interpreter():
|
with spack_python_interpreter():
|
||||||
yield
|
yield
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
from ._functions import _host, by_name, platforms
|
from ._functions import _host, by_name, platforms, prevent_cray_detection, reset
|
||||||
from ._platform import Platform
|
from ._platform import Platform
|
||||||
from .cray import Cray
|
from .cray import Cray
|
||||||
from .darwin import Darwin
|
from .darwin import Darwin
|
||||||
|
@ -19,7 +19,9 @@
|
||||||
'Test',
|
'Test',
|
||||||
'platforms',
|
'platforms',
|
||||||
'host',
|
'host',
|
||||||
'by_name'
|
'by_name',
|
||||||
|
'reset',
|
||||||
|
'prevent_cray_detection'
|
||||||
]
|
]
|
||||||
|
|
||||||
#: The "real" platform of the host running Spack. This should not be changed
|
#: The "real" platform of the host running Spack. This should not be changed
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
import contextlib
|
||||||
|
|
||||||
import llnl.util.lang
|
import llnl.util.lang
|
||||||
|
|
||||||
|
import spack.util.environment
|
||||||
|
|
||||||
from .cray import Cray
|
from .cray import Cray
|
||||||
from .darwin import Darwin
|
from .darwin import Darwin
|
||||||
from .linux import Linux
|
from .linux import Linux
|
||||||
|
@ -22,6 +26,13 @@ def _host():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def reset():
|
||||||
|
"""The result of the host search is memoized. In case it needs to be recomputed
|
||||||
|
we must clear the cache, which is what this function does.
|
||||||
|
"""
|
||||||
|
_host.cache.clear()
|
||||||
|
|
||||||
|
|
||||||
@llnl.util.lang.memoized
|
@llnl.util.lang.memoized
|
||||||
def cls_by_name(name):
|
def cls_by_name(name):
|
||||||
"""Return a platform class that corresponds to the given name or None
|
"""Return a platform class that corresponds to the given name or None
|
||||||
|
@ -45,3 +56,14 @@ def by_name(name):
|
||||||
"""
|
"""
|
||||||
platform_cls = cls_by_name(name)
|
platform_cls = cls_by_name(name)
|
||||||
return platform_cls() if platform_cls else None
|
return platform_cls() if platform_cls else None
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def prevent_cray_detection():
|
||||||
|
"""Context manager that prevents the detection of the Cray platform"""
|
||||||
|
reset()
|
||||||
|
try:
|
||||||
|
with spack.util.environment.set_env(MODULEPATH=''):
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
reset()
|
||||||
|
|
Loading…
Reference in a new issue