diff options
Diffstat (limited to 'lib')
22 files changed, 62 insertions, 97 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 6e91b17bdc..e807bf6fd0 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -1553,21 +1553,21 @@ class ModuleChangePropagator: _PROTECTED_NAMES = ("package", "current_module", "modules_in_mro", "_set_attributes") - def __init__(self, package): + def __init__(self, package: spack.package_base.PackageBase) -> None: self._set_self_attributes("package", package) self._set_self_attributes("current_module", package.module) #: Modules for the classes in the MRO up to PackageBase modules_in_mro = [] - for cls in type(package).__mro__: - module = cls.module + for cls in package.__class__.__mro__: + module = getattr(cls, "module", None) - if module == self.current_module: - continue - - if module == spack.package_base: + if module is None or module is spack.package_base: break + if module is self.current_module: + continue + modules_in_mro.append(module) self._set_self_attributes("modules_in_mro", modules_in_mro) self._set_self_attributes("_set_attributes", {}) diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index ce4d6bc279..b9b9ee2f2e 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect import os import os.path import stat @@ -549,13 +548,12 @@ To resolve this problem, please try the following: tty.warn("* a custom AUTORECONF phase in the package *") tty.warn("*********************************************************") with fs.working_dir(self.configure_directory): - m = inspect.getmodule(self.pkg) # This line is what is needed most of the time # --install, --verbose, --force autoreconf_args = ["-ivf"] autoreconf_args += self.autoreconf_search_path_args autoreconf_args += self.autoreconf_extra_args - m.autoreconf(*autoreconf_args) + self.pkg.module.autoreconf(*autoreconf_args) @property def autoreconf_search_path_args(self): @@ -579,7 +577,9 @@ To resolve this problem, please try the following: raise RuntimeError(msg.format(self.configure_directory)) # Monkey-patch the configure script in the corresponding module - inspect.getmodule(self.pkg).configure = Executable(self.configure_abs_path) + globals_for_pkg = spack.build_environment.ModuleChangePropagator(self.pkg) + globals_for_pkg.configure = Executable(self.configure_abs_path) + globals_for_pkg.propagate_changes_to_mro() def configure_args(self): """Return the list of all the arguments that must be passed to configure, @@ -596,7 +596,7 @@ To resolve this problem, please try the following: options += self.configure_args() with fs.working_dir(self.build_directory, create=True): - inspect.getmodule(self.pkg).configure(*options) + pkg.module.configure(*options) def build(self, pkg, spec, prefix): """Run "make" on the build targets specified by the builder.""" @@ -604,12 +604,12 @@ To resolve this problem, please try the following: params = ["V=1"] params += self.build_targets with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).make(*params) + pkg.module.make(*params) def install(self, pkg, spec, prefix): """Run "make" on the install targets specified by the builder.""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).make(*self.install_targets) + pkg.module.make(*self.install_targets) spack.builder.run_after("build")(execute_build_time_tests) diff --git a/lib/spack/spack/build_systems/cargo.py b/lib/spack/spack/build_systems/cargo.py index 2fd952d8c2..4dded46559 100644 --- a/lib/spack/spack/build_systems/cargo.py +++ b/lib/spack/spack/build_systems/cargo.py @@ -3,8 +3,6 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - import llnl.util.filesystem as fs import spack.builder @@ -72,9 +70,7 @@ class CargoBuilder(BaseBuilder): def build(self, pkg, spec, prefix): """Runs ``cargo install`` in the source directory""" with fs.working_dir(self.build_directory): - inspect.getmodule(pkg).cargo( - "install", "--root", "out", "--path", ".", *self.build_args - ) + pkg.module.cargo("install", "--root", "out", "--path", ".", *self.build_args) def install(self, pkg, spec, prefix): """Copy build files into package prefix.""" @@ -86,4 +82,4 @@ class CargoBuilder(BaseBuilder): def check(self): """Run "cargo test".""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).cargo("test", *self.check_args) + self.pkg.module.cargo("test", *self.check_args) diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index 10949e7949..d638a3e50b 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections.abc -import inspect import os import pathlib import platform @@ -544,24 +543,24 @@ class CMakeBuilder(BaseBuilder): options += self.cmake_args() options.append(os.path.abspath(self.root_cmakelists_dir)) with fs.working_dir(self.build_directory, create=True): - inspect.getmodule(self.pkg).cmake(*options) + pkg.module.cmake(*options) def build(self, pkg, spec, prefix): """Make the build targets""" with fs.working_dir(self.build_directory): if self.generator == "Unix Makefiles": - inspect.getmodule(self.pkg).make(*self.build_targets) + pkg.module.make(*self.build_targets) elif self.generator == "Ninja": self.build_targets.append("-v") - inspect.getmodule(self.pkg).ninja(*self.build_targets) + pkg.module.ninja(*self.build_targets) def install(self, pkg, spec, prefix): """Make the install targets""" with fs.working_dir(self.build_directory): if self.generator == "Unix Makefiles": - inspect.getmodule(self.pkg).make(*self.install_targets) + pkg.module.make(*self.install_targets) elif self.generator == "Ninja": - inspect.getmodule(self.pkg).ninja(*self.install_targets) + pkg.module.ninja(*self.install_targets) spack.builder.run_after("build")(execute_build_time_tests) diff --git a/lib/spack/spack/build_systems/go.py b/lib/spack/spack/build_systems/go.py index a22d3922e8..8bddd7548e 100644 --- a/lib/spack/spack/build_systems/go.py +++ b/lib/spack/spack/build_systems/go.py @@ -3,8 +3,6 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - import llnl.util.filesystem as fs import spack.builder @@ -82,7 +80,7 @@ class GoBuilder(BaseBuilder): def build(self, pkg, spec, prefix): """Runs ``go build`` in the source directory""" with fs.working_dir(self.build_directory): - inspect.getmodule(pkg).go("build", *self.build_args) + pkg.module.go("build", *self.build_args) def install(self, pkg, spec, prefix): """Install built binaries into prefix bin.""" @@ -95,4 +93,4 @@ class GoBuilder(BaseBuilder): def check(self): """Run ``go test .`` in the source directory""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).go("test", *self.check_args) + self.pkg.module.go("test", *self.check_args) diff --git a/lib/spack/spack/build_systems/makefile.py b/lib/spack/spack/build_systems/makefile.py index 915f71d332..25f25adfe3 100644 --- a/lib/spack/spack/build_systems/makefile.py +++ b/lib/spack/spack/build_systems/makefile.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect from typing import List import llnl.util.filesystem as fs @@ -103,12 +102,12 @@ class MakefileBuilder(BaseBuilder): def build(self, pkg, spec, prefix): """Run "make" on the build targets specified by the builder.""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).make(*self.build_targets) + pkg.module.make(*self.build_targets) def install(self, pkg, spec, prefix): """Run "make" on the install targets specified by the builder.""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).make(*self.install_targets) + pkg.module.make(*self.install_targets) spack.builder.run_after("build")(execute_build_time_tests) diff --git a/lib/spack/spack/build_systems/meson.py b/lib/spack/spack/build_systems/meson.py index 2c2bc0d1a0..cf3cd24e20 100644 --- a/lib/spack/spack/build_systems/meson.py +++ b/lib/spack/spack/build_systems/meson.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect import os from typing import List @@ -195,19 +194,19 @@ class MesonBuilder(BaseBuilder): options += self.std_meson_args options += self.meson_args() with fs.working_dir(self.build_directory, create=True): - inspect.getmodule(self.pkg).meson(*options) + pkg.module.meson(*options) def build(self, pkg, spec, prefix): """Make the build targets""" options = ["-v"] options += self.build_targets with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).ninja(*options) + pkg.module.ninja(*options) def install(self, pkg, spec, prefix): """Make the install targets""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).ninja(*self.install_targets) + pkg.module.ninja(*self.install_targets) spack.builder.run_after("build")(execute_build_time_tests) diff --git a/lib/spack/spack/build_systems/msbuild.py b/lib/spack/spack/build_systems/msbuild.py index 0edc49b880..8fb4ef936e 100644 --- a/lib/spack/spack/build_systems/msbuild.py +++ b/lib/spack/spack/build_systems/msbuild.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect from typing import List # novm import llnl.util.filesystem as fs @@ -104,7 +103,7 @@ class MSBuildBuilder(BaseBuilder): def build(self, pkg, spec, prefix): """Run "msbuild" on the build targets specified by the builder.""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).msbuild( + pkg.module.msbuild( *self.std_msbuild_args, *self.msbuild_args(), self.define_targets(*self.build_targets), @@ -114,6 +113,6 @@ class MSBuildBuilder(BaseBuilder): """Run "msbuild" on the install targets specified by the builder. This is INSTALL by default""" with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).msbuild( + pkg.module.msbuild( *self.msbuild_install_args(), self.define_targets(*self.install_targets) ) diff --git a/lib/spack/spack/build_systems/nmake.py b/lib/spack/spack/build_systems/nmake.py index d378d62336..50232f3e2d 100644 --- a/lib/spack/spack/build_systems/nmake.py +++ b/lib/spack/spack/build_systems/nmake.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect from typing import List # novm import llnl.util.filesystem as fs @@ -132,9 +131,7 @@ class NMakeBuilder(BaseBuilder): if self.makefile_name: opts.append("/F{}".format(self.makefile_name)) with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).nmake( - *opts, *self.build_targets, ignore_quotes=self.ignore_quotes - ) + pkg.module.nmake(*opts, *self.build_targets, ignore_quotes=self.ignore_quotes) def install(self, pkg, spec, prefix): """Run "nmake" on the install targets specified by the builder. @@ -146,6 +143,4 @@ class NMakeBuilder(BaseBuilder): opts.append("/F{}".format(self.makefile_name)) opts.append(self.define("PREFIX", fs.windows_sfn(prefix))) with fs.working_dir(self.build_directory): - inspect.getmodule(self.pkg).nmake( - *opts, *self.install_targets, ignore_quotes=self.ignore_quotes - ) + pkg.module.nmake(*opts, *self.install_targets, ignore_quotes=self.ignore_quotes) diff --git a/lib/spack/spack/build_systems/octave.py b/lib/spack/spack/build_systems/octave.py index 64958ce941..1b0a88c6e7 100644 --- a/lib/spack/spack/build_systems/octave.py +++ b/lib/spack/spack/build_systems/octave.py @@ -2,8 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - import spack.builder import spack.package_base from spack.directives import build_system, extends @@ -47,7 +45,7 @@ class OctaveBuilder(BaseBuilder): def install(self, pkg, spec, prefix): """Install the package from the archive file""" - inspect.getmodule(self.pkg).octave( + pkg.module.octave( "--quiet", "--norc", "--built-in-docstrings-file=/dev/null", diff --git a/lib/spack/spack/build_systems/perl.py b/lib/spack/spack/build_systems/perl.py index 773a6a98e6..4caab7131b 100644 --- a/lib/spack/spack/build_systems/perl.py +++ b/lib/spack/spack/build_systems/perl.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect import os from typing import Iterable @@ -134,7 +133,7 @@ class PerlBuilder(BaseBuilder): def build_executable(self): """Returns the executable method to build the perl package""" if self.build_method == "Makefile.PL": - build_executable = inspect.getmodule(self.pkg).make + build_executable = self.pkg.module.make elif self.build_method == "Build.PL": build_executable = Executable(os.path.join(self.pkg.stage.source_path, "Build")) return build_executable @@ -158,7 +157,7 @@ class PerlBuilder(BaseBuilder): options = ["Build.PL", "--install_base", prefix] options += self.configure_args() - inspect.getmodule(self.pkg).perl(*options) + pkg.module.perl(*options) # It is possible that the shebang in the Build script that is created from # Build.PL may be too long causing the build to fail. Patching the shebang diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index 969d5f5b03..bd0c57520c 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import functools -import inspect import operator import os import re @@ -228,7 +227,7 @@ class PythonExtension(spack.package_base.PackageBase): # Make sure we are importing the installed modules, # not the ones in the source directory - python = inspect.getmodule(self).python # type: ignore[union-attr] + python = self.module.python for module in self.import_modules: with test_part( self, diff --git a/lib/spack/spack/build_systems/qmake.py b/lib/spack/spack/build_systems/qmake.py index a1e679b50c..75ad3860b4 100644 --- a/lib/spack/spack/build_systems/qmake.py +++ b/lib/spack/spack/build_systems/qmake.py @@ -2,8 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - from llnl.util.filesystem import working_dir import spack.builder @@ -66,17 +64,17 @@ class QMakeBuilder(BaseBuilder): def qmake(self, pkg, spec, prefix): """Run ``qmake`` to configure the project and generate a Makefile.""" with working_dir(self.build_directory): - inspect.getmodule(self.pkg).qmake(*self.qmake_args()) + pkg.module.qmake(*self.qmake_args()) def build(self, pkg, spec, prefix): """Make the build targets""" with working_dir(self.build_directory): - inspect.getmodule(self.pkg).make() + pkg.module.make() def install(self, pkg, spec, prefix): """Make the install targets""" with working_dir(self.build_directory): - inspect.getmodule(self.pkg).make("install") + pkg.module.make("install") def check(self): """Search the Makefile for a ``check:`` target and runs it if found.""" diff --git a/lib/spack/spack/build_systems/r.py b/lib/spack/spack/build_systems/r.py index 5154f5a42d..9950d67048 100644 --- a/lib/spack/spack/build_systems/r.py +++ b/lib/spack/spack/build_systems/r.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect from typing import Optional, Tuple import llnl.util.lang as lang @@ -51,7 +50,7 @@ class RBuilder(GenericBuilder): args.extend(["--library={0}".format(self.pkg.module.r_lib_dir), self.stage.source_path]) - inspect.getmodule(self.pkg).R(*args) + pkg.module.R(*args) class RPackage(Package): diff --git a/lib/spack/spack/build_systems/ruby.py b/lib/spack/spack/build_systems/ruby.py index 0f069e99f2..77d7ef289c 100644 --- a/lib/spack/spack/build_systems/ruby.py +++ b/lib/spack/spack/build_systems/ruby.py @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import glob -import inspect import spack.builder import spack.package_base @@ -52,10 +51,10 @@ class RubyBuilder(BaseBuilder): gemspecs = glob.glob("*.gemspec") rakefiles = glob.glob("Rakefile") if gemspecs: - inspect.getmodule(self.pkg).gem("build", "--norc", gemspecs[0]) + pkg.module.gem("build", "--norc", gemspecs[0]) elif rakefiles: - jobs = inspect.getmodule(self.pkg).make_jobs - inspect.getmodule(self.pkg).rake("package", "-j{0}".format(jobs)) + jobs = pkg.module.make_jobs + pkg.module.rake("package", "-j{0}".format(jobs)) else: # Some Ruby packages only ship `*.gem` files, so nothing to build pass @@ -70,6 +69,6 @@ class RubyBuilder(BaseBuilder): # if --install-dir is not used, GEM_PATH is deleted from the # environement, and Gems required to build native extensions will # not be found. Those extensions are built during `gem install`. - inspect.getmodule(self.pkg).gem( + pkg.module.gem( "install", "--norc", "--ignore-dependencies", "--install-dir", prefix, gems[0] ) diff --git a/lib/spack/spack/build_systems/scons.py b/lib/spack/spack/build_systems/scons.py index 0d2ea175a1..4a32b690f7 100644 --- a/lib/spack/spack/build_systems/scons.py +++ b/lib/spack/spack/build_systems/scons.py @@ -2,8 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - import spack.builder import spack.package_base from spack.directives import build_system, depends_on @@ -63,8 +61,7 @@ class SConsBuilder(BaseBuilder): def build(self, pkg, spec, prefix): """Build the package.""" - args = self.build_args(spec, prefix) - inspect.getmodule(self.pkg).scons(*args) + pkg.module.scons(*self.build_args(spec, prefix)) def install_args(self, spec, prefix): """Arguments to pass to install.""" @@ -72,9 +69,7 @@ class SConsBuilder(BaseBuilder): def install(self, pkg, spec, prefix): """Install the package.""" - args = self.install_args(spec, prefix) - - inspect.getmodule(self.pkg).scons("install", *args) + pkg.module.scons("install", *self.install_args(spec, prefix)) def build_test(self): """Run unit tests after build. diff --git a/lib/spack/spack/build_systems/sip.py b/lib/spack/spack/build_systems/sip.py index f1263c12a6..f297c59a00 100644 --- a/lib/spack/spack/build_systems/sip.py +++ b/lib/spack/spack/build_systems/sip.py @@ -2,7 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect import os import re @@ -86,14 +85,13 @@ class SIPPackage(spack.package_base.PackageBase): def python(self, *args, **kwargs): """The python ``Executable``.""" - inspect.getmodule(self).python(*args, **kwargs) + self.pkg.module.python(*args, **kwargs) def test_imports(self): """Attempts to import modules of the installed package.""" # Make sure we are importing the installed modules, # not the ones in the source directory - python = inspect.getmodule(self).python for module in self.import_modules: with spack.install_test.test_part( self, @@ -101,7 +99,7 @@ class SIPPackage(spack.package_base.PackageBase): purpose="checking import of {0}".format(module), work_dir="spack-test", ): - python("-c", "import {0}".format(module)) + self.python("-c", "import {0}".format(module)) @spack.builder.builder("sip") @@ -136,7 +134,7 @@ class SIPBuilder(BaseBuilder): """Configure the package.""" # https://www.riverbankcomputing.com/static/Docs/sip/command_line_tools.html - args = ["--verbose", "--target-dir", inspect.getmodule(self.pkg).python_platlib] + args = ["--verbose", "--target-dir", pkg.module.python_platlib] args.extend(self.configure_args()) # https://github.com/Python-SIP/sip/commit/cb0be6cb6e9b756b8b0db3136efb014f6fb9b766 @@ -155,7 +153,7 @@ class SIPBuilder(BaseBuilder): args = self.build_args() with working_dir(self.build_directory): - inspect.getmodule(self.pkg).make(*args) + pkg.module.make(*args) def build_args(self): """Arguments to pass to build.""" @@ -166,7 +164,7 @@ class SIPBuilder(BaseBuilder): args = self.install_args() with working_dir(self.build_directory): - inspect.getmodule(self.pkg).make("install", *args) + pkg.module.make("install", *args) def install_args(self): """Arguments to pass to install.""" diff --git a/lib/spack/spack/build_systems/waf.py b/lib/spack/spack/build_systems/waf.py index 0fd78d48da..a0110c5c34 100644 --- a/lib/spack/spack/build_systems/waf.py +++ b/lib/spack/spack/build_systems/waf.py @@ -2,8 +2,6 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import inspect - from llnl.util.filesystem import working_dir import spack.builder @@ -90,11 +88,11 @@ class WafBuilder(BaseBuilder): def python(self, *args, **kwargs): """The python ``Executable``.""" - inspect.getmodule(self.pkg).python(*args, **kwargs) + self.pkg.module.python(*args, **kwargs) def waf(self, *args, **kwargs): """Runs the waf ``Executable``.""" - jobs = inspect.getmodule(self.pkg).make_jobs + jobs = self.pkg.module.make_jobs with working_dir(self.build_directory): self.python("waf", "-j{0}".format(jobs), *args, **kwargs) diff --git a/lib/spack/spack/builder.py b/lib/spack/spack/builder.py index 2f947335a8..7590016c33 100644 --- a/lib/spack/spack/builder.py +++ b/lib/spack/spack/builder.py @@ -6,7 +6,6 @@ import collections import collections.abc import copy import functools -import inspect from typing import List, Optional, Tuple from llnl.util import lang @@ -97,11 +96,10 @@ def _create(pkg): Args: pkg (spack.package_base.PackageBase): package object for which we need a builder """ - package_module = inspect.getmodule(pkg) package_buildsystem = buildsystem_name(pkg) default_builder_cls = BUILDER_CLS[package_buildsystem] builder_cls_name = default_builder_cls.__name__ - builder_cls = getattr(package_module, builder_cls_name, None) + builder_cls = getattr(pkg.module, builder_cls_name, None) if builder_cls: return builder_cls(pkg) diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 681b079706..65c9e856bb 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -16,7 +16,6 @@ import functools import glob import hashlib import importlib -import inspect import io import os import re @@ -1744,7 +1743,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass bool: True if 'target' is found, else False """ # Prevent altering LC_ALL for 'make' outside this function - make = copy.deepcopy(inspect.getmodule(self).make) + make = copy.deepcopy(self.module.make) # Use English locale for missing target message comparison make.add_default_env("LC_ALL", "C") @@ -1794,7 +1793,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass """ if self._has_make_target(target): # Execute target - inspect.getmodule(self).make(target, *args, **kwargs) + self.module.make(target, *args, **kwargs) def _has_ninja_target(self, target): """Checks to see if 'target' is a valid target in a Ninja build script. @@ -1805,7 +1804,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass Returns: bool: True if 'target' is found, else False """ - ninja = inspect.getmodule(self).ninja + ninja = self.module.ninja # Check if we have a Ninja build script if not os.path.exists("build.ninja"): @@ -1834,7 +1833,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass """ if self._has_ninja_target(target): # Execute target - inspect.getmodule(self).ninja(target, *args, **kwargs) + self.module.ninja(target, *args, **kwargs) def _get_needed_resources(self): # We use intersects here cause it would also work if self.spec is abstract diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py index 3d3bbf27cd..3ae41acc9c 100644 --- a/lib/spack/spack/test/build_environment.py +++ b/lib/spack/spack/test/build_environment.py @@ -592,7 +592,7 @@ class TestModuleMonkeyPatcher: # We can also propagate the settings to classes in the MRO module_wrapper.propagate_changes_to_mro() - for cls in type(s.package).__mro__: + for cls in s.package.__class__.__mro__: current_module = cls.module if current_module == spack.package_base: break diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 66ae350bcd..eaef82930d 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -775,15 +775,15 @@ class TestConcretize: s = Spec("mpileaks") s.concretize() - assert llnl.util.lang.ObjectWrapper not in type(s).__mro__ + assert llnl.util.lang.ObjectWrapper not in s.__class__.__mro__ # Spec wrapped in a build interface build_interface = s["mpileaks"] - assert llnl.util.lang.ObjectWrapper in type(build_interface).__mro__ + assert llnl.util.lang.ObjectWrapper in build_interface.__class__.__mro__ # Mimics asking the build interface from a build interface build_interface = s["mpileaks"]["mpileaks"] - assert llnl.util.lang.ObjectWrapper in type(build_interface).__mro__ + assert llnl.util.lang.ObjectWrapper in build_interface.__class__.__mro__ @pytest.mark.regression("7705") def test_regression_issue_7705(self): |