From 91fc4cf28fa7145e1f855f8c03f30574a550308f Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 12 Jan 2022 17:18:16 +0100 Subject: bootstrap: fix bootstrapping GnuPG from different macOS versions (#28350) --- lib/spack/spack/bootstrap.py | 4 +++- lib/spack/spack/build_environment.py | 12 ++++++++++-- lib/spack/spack/user_environment.py | 19 ++++++++++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py index 69978eb670..16195ff381 100644 --- a/lib/spack/spack/bootstrap.py +++ b/lib/spack/spack/bootstrap.py @@ -575,7 +575,9 @@ def ensure_executables_in_path_or_raise(executables, abstract_spec): root=True, order='post', deptype=('link', 'run') ): env_mods.extend( - spack.user_environment.environment_modifications_for_spec(dep) + spack.user_environment.environment_modifications_for_spec( + dep, set_package_py_globals=False + ) ) cmd.add_default_envmod(env_mods) return cmd diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 11cc93a9bd..ac98b972a7 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -856,7 +856,9 @@ def _make_runnable(pkg, env): env.prepend_path('PATH', bin_dir) -def modifications_from_dependencies(spec, context, custom_mods_only=True): +def modifications_from_dependencies( + spec, context, custom_mods_only=True, set_package_py_globals=True +): """Returns the environment modifications that are required by the dependencies of a spec and also applies modifications to this spec's package at module scope, if need be. @@ -889,6 +891,11 @@ def modifications_from_dependencies(spec, context, custom_mods_only=True): spec (spack.spec.Spec): spec for which we want the modifications context (str): either 'build' for build-time modifications or 'run' for run-time modifications + custom_mods_only (bool): if True returns only custom modifications, if False + returns custom and default modifications + set_package_py_globals (bool): whether or not to set the global variables in the + package.py files (this may be problematic when using buildcaches that have + been built on a different but compatible OS) """ if context not in ['build', 'run', 'test']: raise ValueError( @@ -962,7 +969,8 @@ def modifications_from_dependencies(spec, context, custom_mods_only=True): # PKG_CONFIG_PATH) if dep in custom_mod_deps: dpkg = dep.package - set_module_variables_for_package(dpkg) + if set_package_py_globals: + set_module_variables_for_package(dpkg) # Allow dependencies to modify the module dpkg.setup_dependent_package(spec.package.module, spec) if context == 'build': diff --git a/lib/spack/spack/user_environment.py b/lib/spack/spack/user_environment.py index 55f516b732..9e854efa63 100644 --- a/lib/spack/spack/user_environment.py +++ b/lib/spack/spack/user_environment.py @@ -65,11 +65,19 @@ def unconditional_environment_modifications(view): return env -def environment_modifications_for_spec(spec, view=None): +def environment_modifications_for_spec(spec, view=None, set_package_py_globals=True): """List of environment (shell) modifications to be processed for spec. This list is specific to the location of the spec or its projection in - the view.""" + the view. + + Args: + spec (spack.spec.Spec): spec for which to list the environment modifications + view: view associated with the spec passed as first argument + set_package_py_globals (bool): whether or not to set the global variables in the + package.py files (this may be problematic when using buildcaches that have + been built on a different but compatible OS) + """ spec = spec.copy() if view and not spec.external: spec.prefix = prefix.Prefix(view.get_projection_for_spec(spec)) @@ -86,12 +94,13 @@ def environment_modifications_for_spec(spec, view=None): # before asking for package-specific modifications env.extend( spack.build_environment.modifications_from_dependencies( - spec, context='run' + spec, context='run', set_package_py_globals=set_package_py_globals ) ) - # Package specific modifications - spack.build_environment.set_module_variables_for_package(spec.package) + if set_package_py_globals: + spack.build_environment.set_module_variables_for_package(spec.package) + spec.package.setup_run_environment(env) return env -- cgit v1.2.3-70-g09d2