builtin: fix a few imports (#50570)

This commit is contained in:
Harmen Stoppels 2025-05-20 12:11:27 +02:00 committed by GitHub
parent 4316c4fb00
commit f07789febf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 21 deletions

View File

@ -2,12 +2,9 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from typing import List
import llnl.util.lang
from typing import Callable, List
import spack.relocate
import spack.store
from spack.package import Builder, InstallError, Spec, run_after
@ -22,24 +19,28 @@ def sanity_check_prefix(builder: Builder):
"""
pkg = builder.pkg
def check_paths(path_list, filetype, predicate):
def check_paths(path_list: List[str], filetype: str, predicate: Callable[[str], bool]) -> None:
if isinstance(path_list, str):
path_list = [path_list]
for path in path_list:
abs_path = os.path.join(pkg.prefix, path)
if not predicate(abs_path):
msg = "Install failed for {0}. No such {1} in prefix: {2}"
msg = msg.format(pkg.name, filetype, path)
raise InstallError(msg)
if not predicate(os.path.join(pkg.prefix, path)):
raise InstallError(
f"Install failed for {pkg.name}. No such {filetype} in prefix: {path}"
)
check_paths(pkg.sanity_check_is_file, "file", os.path.isfile)
check_paths(pkg.sanity_check_is_dir, "directory", os.path.isdir)
ignore_file = llnl.util.lang.match_predicate(spack.store.STORE.layout.hidden_file_regexes)
if all(map(ignore_file, os.listdir(pkg.prefix))):
msg = "Install failed for {0}. Nothing was installed!"
raise InstallError(msg.format(pkg.name))
# Check that the prefix is not empty apart from the .spack/ directory
with os.scandir(pkg.prefix) as entries:
f = next(
(f for f in entries if not (f.name == ".spack" and f.is_dir(follow_symlinks=False))),
None,
)
if f is None:
raise InstallError(f"Install failed for {pkg.name}. Nothing was installed!")
def apply_macos_rpath_fixups(builder: Builder):

View File

@ -7,7 +7,6 @@
from typing import Callable, List, Optional, Set, Tuple, Union
import llnl.util.filesystem as fs
import llnl.util.tty as tty
import spack.build_environment
import spack.builder
@ -34,6 +33,7 @@
register_builder,
run_after,
run_before,
tty,
when,
working_dir,
)

View File

@ -3,8 +3,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from llnl.util.filesystem import find
from spack.package import (
Builder,
EnvironmentModifications,
@ -15,6 +13,7 @@
build_system,
depends_on,
extends,
find,
register_builder,
when,
)

View File

@ -1,8 +1,6 @@
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from llnl.util.filesystem import working_dir
from spack.package import (
PackageBase,
Prefix,
@ -11,6 +9,7 @@
depends_on,
register_builder,
run_after,
working_dir,
)
from ._checks import BuilderWithDefaults, execute_build_time_tests

View File

@ -1,8 +1,6 @@
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from llnl.util.filesystem import working_dir
from spack.package import (
PackageBase,
Prefix,
@ -11,6 +9,7 @@
depends_on,
register_builder,
run_after,
working_dir,
)
from ._checks import BuilderWithDefaults, execute_build_time_tests, execute_install_time_tests