spack.package / builtin repo: fix exports/imports (#47617)

Add various missing imports in packages.
Remove redundant imports
Export NoLibrariesError, NoHeadersError, which_string in spack.package
This commit is contained in:
Harmen Stoppels
2024-11-17 09:02:04 +01:00
committed by GitHub
parent f05cbfbf44
commit 4d3b85c4d4
101 changed files with 125 additions and 49 deletions

View File

@@ -11,7 +11,7 @@
from os import chdir, environ, getcwd, makedirs, mkdir, remove, removedirs
from shutil import move, rmtree
from spack.error import InstallError
from spack.error import InstallError, NoHeadersError, NoLibrariesError
# Emulate some shell commands for convenience
env = environ

View File

@@ -12,9 +12,9 @@
import llnl.util.tty as tty
import spack.error
from spack.util.environment import EnvironmentModifications
import spack.util.environment
__all__ = ["Executable", "which", "ProcessError"]
__all__ = ["Executable", "which", "which_string", "ProcessError"]
class Executable:
@@ -29,7 +29,7 @@ def __init__(self, name):
self.default_env = {}
self.default_envmod = EnvironmentModifications()
self.default_envmod = spack.util.environment.EnvironmentModifications()
self.returncode = None
self.ignore_quotes = False
@@ -168,17 +168,15 @@ def process_cmd_output(out, err):
self.default_envmod.apply_modifications(env)
env.update(self.default_env)
from spack.util.environment import EnvironmentModifications # no cycle
# Apply env argument
if isinstance(env_arg, EnvironmentModifications):
if isinstance(env_arg, spack.util.environment.EnvironmentModifications):
env_arg.apply_modifications(env)
elif env_arg:
env.update(env_arg)
# Apply extra env
extra_env = kwargs.get("extra_env", {})
if isinstance(extra_env, EnvironmentModifications):
if isinstance(extra_env, spack.util.environment.EnvironmentModifications):
extra_env.apply_modifications(env)
else:
env.update(extra_env)

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import spack.platforms
from spack.package import *
_os_map_before_23 = {

View File

@@ -5,6 +5,7 @@
import os
import spack.platforms
from spack.package import *
_versions = {

View File

@@ -5,6 +5,8 @@
import os
import spack.error
import spack.platforms
from spack.package import *
_os_map_before_23 = {

View File

@@ -9,7 +9,6 @@
from os.path import join as pjoin
from spack.package import *
from spack.util.executable import which_string
def get_spec_path(spec, package_name, path_replacements={}, use_bin=False):

View File

@@ -5,6 +5,8 @@
import os
import spack.compilers
import spack.spec
from spack.package import *

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.generic
from spack.package import *

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.cmake
from spack.package import *
from spack.pkg.builtin.boost import Boost

View File

@@ -7,9 +7,7 @@
import os.path
import sys
import spack.platforms
import spack.util.environment
import spack.util.executable
from spack.build_environment import dso_suffix
from spack.build_systems import cmake, makefile
from spack.package import *

View File

@@ -5,6 +5,8 @@
import os
import spack.compilers
import spack.spec
from spack.package import *

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -302,7 +302,7 @@ def libs(self):
return libs
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)

View File

@@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os.path
from spack.error import NoHeadersError
from spack.package import *

View File

@@ -6,6 +6,9 @@
import os
import sys
import spack.build_systems.makefile
import spack.build_systems.python
import spack.compiler
from spack.build_environment import dso_suffix, stat_suffix
from spack.package import *

View File

@@ -5,7 +5,6 @@
import os
import spack.util.executable
from spack.package import *
@@ -156,7 +155,7 @@ def setup(self):
git("fetch", "--unshallow")
git("config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
git("fetch", "origin")
except spack.util.executable.ProcessError:
except ProcessError:
git("fetch")
def autoreconf(self, spec, prefix):

View File

@@ -5,7 +5,6 @@
import os
import spack.util.executable
from spack.build_systems.autotools import AutotoolsBuilder
from spack.build_systems.cmake import CMakeBuilder
from spack.package import *
@@ -139,7 +138,7 @@ def setup(self):
git("fetch", "--unshallow")
git("config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
git("fetch", "origin")
except spack.util.executable.ProcessError:
except ProcessError:
git("fetch")
def autoreconf(self, spec, prefix):

View File

@@ -5,7 +5,6 @@
import os
import spack.util.executable
from spack.package import *
@@ -54,7 +53,7 @@ def setup(self):
git("fetch", "--unshallow")
git("config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
git("fetch", "origin")
except spack.util.executable.ProcessError:
except ProcessError:
git("fetch")
def autoreconf(self, spec, prefix):

View File

@@ -6,6 +6,7 @@
import glob
import os
import spack.util.environment
from spack.package import *
from spack.util.environment import EnvironmentModifications

View File

@@ -5,6 +5,7 @@
import os
import spack.main
from spack.package import *
@@ -145,7 +146,7 @@ def install(self, spec, prefix):
try:
git = which("git")
git("describe", "--long", "--always", output="version.git")
except spack.util.executable.ProcessError:
except ProcessError:
spack.main.send_warning_to_tty("Omitting version stamp due to git error")
# The GASNet-EX library has a highly multi-dimensional configure space,

View File

@@ -8,6 +8,7 @@
import llnl.util.tty as tty
import spack.tengine
from spack.package import *

View File

@@ -11,8 +11,8 @@
import llnl.util.tty as tty
from llnl.util.symlink import readlink
import spack.compiler
import spack.platforms
import spack.util.executable
import spack.util.libc
from spack.operating_systems.mac_os import macos_sdk_path, macos_version
from spack.package import *

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.config
from spack.package import *

View File

@@ -6,6 +6,7 @@
import os
import re
import spack.fetch_strategy
from spack.package import *
from spack.util.environment import is_system_path

View File

@@ -5,6 +5,8 @@
import os.path
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *
from spack.util.environment import is_system_path

View File

@@ -7,6 +7,7 @@
import llnl.util.filesystem as fs
import spack.build_systems.cmake
from spack.package import *

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -127,7 +127,7 @@ def libs(self):
if not libs:
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)

View File

@@ -6,6 +6,7 @@
import os
import re
import spack.build_environment
from spack.hooks.sbang import filter_shebang
from spack.package import *
from spack.util.prefix import Prefix

View File

@@ -5,6 +5,7 @@
import re
import spack.variant
from spack.package import *

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.variant
from spack.package import *

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.variant
from spack.package import *

View File

@@ -5,6 +5,7 @@
import re
import spack.variant
from spack.package import *

View File

@@ -6,6 +6,7 @@
import os
import re
import spack.variant
from spack.package import *

View File

@@ -5,6 +5,7 @@
import re
import spack.variant
from spack.package import *

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.variant
from spack.package import *

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
import spack.build_systems.makefile
from spack.package import *

View File

@@ -9,6 +9,8 @@
import llnl.util.tty as tty
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -5,6 +5,8 @@
import pathlib
import spack.build_systems.autotools
import spack.build_systems.msbuild
from spack.package import *

View File

@@ -284,7 +284,7 @@ def _find_mkl_libs(self, shared):
try:
if self.spec.satisfies("+cluster ^mpi"):
resolved_libs = resolved_libs + self.spec["mpi"].libs
except spack.error.NoLibrariesError:
except NoLibrariesError:
pass
if self.spec.satisfies("threads=openmp"):

View File

@@ -6,6 +6,7 @@
import llnl.util.tty as tty
import spack.compiler
from spack.package import *
@@ -240,7 +241,7 @@ def determine_version(cls, exe):
match = version_regex.search(output)
if match:
return match.group(1)
except spack.util.executable.ProcessError:
except ProcessError:
pass
except Exception as e:
tty.debug(str(e))

View File

@@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
from spack.util.executable import Executable
class Ipm(AutotoolsPackage):

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
import spack.build_systems.meson
from spack.package import *

View File

@@ -6,6 +6,7 @@
import llnl.util.lang as lang
import spack.build_systems.cmake
from spack.package import *

View File

@@ -5,6 +5,7 @@
import pathlib
import spack.build_systems.msbuild
from spack.package import *

View File

@@ -48,7 +48,7 @@ def libs(self):
if not libs:
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)
return libs

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -6,6 +6,8 @@
import os
import sys
import spack.build_systems.cmake
import spack.build_systems.generic
from spack.package import *
# Only build certain parts of dwarf because the other ones break.

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -5,6 +5,7 @@
import sys
import spack.build_systems.cmake
from spack.package import *

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.cmake
from spack.package import *

View File

@@ -34,7 +34,7 @@ def libs(self):
if not libs:
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)
return libs

View File

@@ -5,6 +5,7 @@
import sys
import spack.build_systems
import spack.build_systems.autotools
from spack.package import *

View File

@@ -8,6 +8,7 @@
import llnl.util.tty as tty
import spack.tengine
from spack.package import *

View File

@@ -9,7 +9,6 @@
import llnl.util.tty as tty
import spack.util.executable
from spack.build_systems.cmake import get_cmake_prefix_path
from spack.package import *
@@ -258,7 +257,7 @@ def determine_version(cls, exe):
match = version_regex.search(output)
if match:
return match.group(match.lastindex)
except spack.util.executable.ProcessError:
except ProcessError:
pass
except Exception as e:
tty.debug(e)

View File

@@ -10,7 +10,7 @@
import llnl.util.tty as tty
from llnl.util.lang import classproperty
import spack.util.executable
import spack.compilers
from spack.build_systems.cmake import get_cmake_prefix_path
from spack.package import *
from spack.package_base import PackageBase
@@ -687,7 +687,7 @@ def determine_version(cls, exe):
match = re.search(cls.compiler_version_regex, output)
if match:
return match.group(match.lastindex)
except spack.util.executable.ProcessError:
except ProcessError:
pass
except Exception as e:
tty.debug(e)

View File

@@ -10,7 +10,6 @@
import spack.build_environment
from spack.package import *
from spack.util.executable import Executable
# This is the template for a pkgconfig file for rpm
# https://github.com/guix-mirror/guix/raw/dcaf70897a0bad38a4638a2905aaa3c46b1f1402/gnu/packages/patches/lua-pkgconfig.patch

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.util.environment
from spack.package import *

View File

@@ -5,6 +5,7 @@
import subprocess
import spack.compiler
from spack.package import *

View File

@@ -5,6 +5,7 @@
import sys
import spack.build_systems.meson
import spack.variant
from spack.package import *

View File

@@ -7,7 +7,6 @@
import spack.build_systems.cmake
from spack.package import *
from spack.util.executable import which
class Mmg(CMakePackage):

View File

@@ -5,7 +5,6 @@
import os
from spack.package import *
from spack.util.executable import Executable
class MpasModel(MakefilePackage):

View File

@@ -7,6 +7,7 @@
import re
import sys
import spack.compilers
from spack.build_environment import dso_suffix
from spack.package import *

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
import spack.compiler
from spack.package import *

View File

@@ -7,6 +7,7 @@
import re
import sys
import spack.compilers
from spack.package import *

View File

@@ -5,6 +5,7 @@
import glob
import os
import spack.build_systems.generic
from spack.package import *

View File

@@ -57,7 +57,7 @@ def libs(self):
return libs
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)

View File

@@ -112,7 +112,7 @@ def libs(self):
return libs
msg = "Unable to recursively locate {0} {1} libraries in {2}"
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
msg.format("shared" if shared else "static", self.spec.name, self.spec.prefix)
)

View File

@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.version
from spack.package import *
from spack.util.executable import which_string
class NinjaFortran(Package):

View File

@@ -5,7 +5,6 @@
import sys
from spack.package import *
from spack.util.executable import which_string
class Ninja(Package):

View File

@@ -11,6 +11,8 @@
import llnl.util.tty as tty
import spack.compilers
import spack.version
from spack.package import *

View File

@@ -9,6 +9,7 @@
import llnl.util.filesystem as fs
import spack.util.environment
from spack.package import *

View File

@@ -105,7 +105,7 @@ def libs(self):
msg = f"Unable to recursively locate {'shared' if shared else 'static'} \
{self.spec.name} libraries in {self.spec.prefix}"
raise spack.error.NoLibrariesError(msg)
raise NoLibrariesError(msg)
@when("@master")
def autoreconf(self, spec, prefix):

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.cmake
from spack.package import *

View File

@@ -264,7 +264,7 @@ def patch(self):
@classmethod
def determine_version(cls, exe):
perl = spack.util.executable.Executable(exe)
perl = Executable(exe)
output = perl("--version", output=str, error=str)
if output:
match = re.search(r"perl.*\(v([0-9.]+)\)", output)
@@ -275,7 +275,7 @@ def determine_version(cls, exe):
@classmethod
def determine_variants(cls, exes, version):
for exe in exes:
perl = spack.util.executable.Executable(exe)
perl = Executable(exe)
output = perl("-V", output=str, error=str)
variants = ""
if output:

View File

@@ -323,7 +323,7 @@ def check(self):
tty.warn("========================== %s =======================" % hint)
try:
make("check")
except spack.util.executable.ProcessError:
except ProcessError:
raise InstallError("run-test of phist ^mpich: Hint: " + hint)
else:
make("check")

View File

@@ -5,6 +5,8 @@
import sys
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *

View File

@@ -332,7 +332,7 @@ def setup_build_environment(self, env):
include.extend(query.headers.directories)
try:
library.extend(query.libs.directories)
except spack.error.NoLibrariesError:
except NoLibrariesError:
pass
# Build uses a mix of Spack's compiler wrapper and the actual compiler,

View File

@@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
from spack.build_systems.python import PythonPipBuilder
from spack.package import *

View File

@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
from spack.build_systems.python import PythonPipBuilder
from spack.package import *

View File

@@ -16,6 +16,7 @@
import llnl.util.tty as tty
from llnl.util.lang import dedupe
import spack.paths
from spack.build_environment import dso_suffix, stat_suffix
from spack.package import *
from spack.util.prefix import Prefix
@@ -1088,7 +1089,7 @@ def libs(self):
if lib:
return lib
raise spack.error.NoLibrariesError(
raise NoLibrariesError(
"Unable to find {} libraries with the following names:\n\n* ".format(self.name)
+ "\n* ".join(candidates)
)
@@ -1114,7 +1115,7 @@ def headers(self):
config_h = headers[0]
break
else:
raise spack.error.NoHeadersError(
raise NoHeadersError(
"Unable to locate {} headers in any of these locations:\n\n* ".format(self.name)
+ "\n* ".join(candidates)
)

View File

@@ -7,6 +7,7 @@
import os
import sys
import spack.util.environment
from spack.operating_systems.mac_os import macos_version
from spack.package import *
from spack.util.environment import is_system_path

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.paths
from spack.package import *

View File

@@ -7,6 +7,7 @@
import re
import spack.build_systems
import spack.build_systems.cargo
from spack.package import *

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.go
from spack.package import *

View File

@@ -131,7 +131,7 @@ def libs(self):
return libs
msg = "Unable to recursively locate {0} libraries in {1}"
raise spack.error.NoLibrariesError(msg.format(self.spec.name, self.spec.prefix))
raise NoLibrariesError(msg.format(self.spec.name, self.spec.prefix))
def flag_handler(self, name, flags):
cmake_flags = []

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.cmake
from spack.package import *

View File

@@ -5,6 +5,7 @@
import os
import spack.version
from spack.package import *

View File

@@ -8,6 +8,7 @@
import llnl.util.tty as tty
import spack.tengine
from spack.package import *

View File

@@ -5,6 +5,7 @@
import os
import re
import spack.compilers
from spack.package import *

View File

@@ -7,6 +7,8 @@
import sys
from tempfile import NamedTemporaryFile
import spack.build_systems.autotools
import spack.build_systems.nmake
import spack.platforms
from spack.package import *

View File

@@ -9,7 +9,6 @@
from spack.package import *
from spack.util.environment import set_env
from spack.util.executable import ProcessError
class Strumpack(CMakePackage, CudaPackage, ROCmPackage):

View File

@@ -2,6 +2,8 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.autotools
import spack.build_systems.cmake
from spack.package import *

View File

@@ -8,6 +8,8 @@
from llnl.util.filesystem import find_first
import spack.build_systems.autotools
import spack.build_systems.nmake
from spack.package import *
from spack.util.environment import is_system_path

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
import spack.build_systems.generic
from spack.package import *

View File

@@ -9,7 +9,6 @@
import sys
from spack.build_environment import dso_suffix
from spack.error import NoHeadersError
from spack.operating_systems.mac_os import macos_version
from spack.package import *
from spack.pkg.builtin.kokkos import Kokkos

View File

@@ -6,6 +6,7 @@
import os
import re
import spack.platforms
from spack.package import *

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.url
from spack.package import *

View File

@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.meson
from spack.package import *

View File

@@ -6,6 +6,7 @@
import os
import re
import spack.compiler
from spack.package import *

Some files were not shown because too many files have changed in this diff Show More