builtin: fix a few imports (#50570)
This commit is contained in:
parent
4316c4fb00
commit
f07789febf
@ -2,12 +2,9 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os
|
import os
|
||||||
from typing import List
|
from typing import Callable, List
|
||||||
|
|
||||||
import llnl.util.lang
|
|
||||||
|
|
||||||
import spack.relocate
|
import spack.relocate
|
||||||
import spack.store
|
|
||||||
from spack.package import Builder, InstallError, Spec, run_after
|
from spack.package import Builder, InstallError, Spec, run_after
|
||||||
|
|
||||||
|
|
||||||
@ -22,24 +19,28 @@ def sanity_check_prefix(builder: Builder):
|
|||||||
"""
|
"""
|
||||||
pkg = builder.pkg
|
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):
|
if isinstance(path_list, str):
|
||||||
path_list = [path_list]
|
path_list = [path_list]
|
||||||
|
|
||||||
for path in path_list:
|
for path in path_list:
|
||||||
abs_path = os.path.join(pkg.prefix, path)
|
if not predicate(os.path.join(pkg.prefix, path)):
|
||||||
if not predicate(abs_path):
|
raise InstallError(
|
||||||
msg = "Install failed for {0}. No such {1} in prefix: {2}"
|
f"Install failed for {pkg.name}. No such {filetype} in prefix: {path}"
|
||||||
msg = msg.format(pkg.name, filetype, path)
|
)
|
||||||
raise InstallError(msg)
|
|
||||||
|
|
||||||
check_paths(pkg.sanity_check_is_file, "file", os.path.isfile)
|
check_paths(pkg.sanity_check_is_file, "file", os.path.isfile)
|
||||||
check_paths(pkg.sanity_check_is_dir, "directory", os.path.isdir)
|
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)
|
# Check that the prefix is not empty apart from the .spack/ directory
|
||||||
if all(map(ignore_file, os.listdir(pkg.prefix))):
|
with os.scandir(pkg.prefix) as entries:
|
||||||
msg = "Install failed for {0}. Nothing was installed!"
|
f = next(
|
||||||
raise InstallError(msg.format(pkg.name))
|
(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):
|
def apply_macos_rpath_fixups(builder: Builder):
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
from typing import Callable, List, Optional, Set, Tuple, Union
|
from typing import Callable, List, Optional, Set, Tuple, Union
|
||||||
|
|
||||||
import llnl.util.filesystem as fs
|
import llnl.util.filesystem as fs
|
||||||
import llnl.util.tty as tty
|
|
||||||
|
|
||||||
import spack.build_environment
|
import spack.build_environment
|
||||||
import spack.builder
|
import spack.builder
|
||||||
@ -34,6 +33,7 @@
|
|||||||
register_builder,
|
register_builder,
|
||||||
run_after,
|
run_after,
|
||||||
run_before,
|
run_before,
|
||||||
|
tty,
|
||||||
when,
|
when,
|
||||||
working_dir,
|
working_dir,
|
||||||
)
|
)
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from llnl.util.filesystem import find
|
|
||||||
|
|
||||||
from spack.package import (
|
from spack.package import (
|
||||||
Builder,
|
Builder,
|
||||||
EnvironmentModifications,
|
EnvironmentModifications,
|
||||||
@ -15,6 +13,7 @@
|
|||||||
build_system,
|
build_system,
|
||||||
depends_on,
|
depends_on,
|
||||||
extends,
|
extends,
|
||||||
|
find,
|
||||||
register_builder,
|
register_builder,
|
||||||
when,
|
when,
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
from llnl.util.filesystem import working_dir
|
|
||||||
|
|
||||||
from spack.package import (
|
from spack.package import (
|
||||||
PackageBase,
|
PackageBase,
|
||||||
Prefix,
|
Prefix,
|
||||||
@ -11,6 +9,7 @@
|
|||||||
depends_on,
|
depends_on,
|
||||||
register_builder,
|
register_builder,
|
||||||
run_after,
|
run_after,
|
||||||
|
working_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ._checks import BuilderWithDefaults, execute_build_time_tests
|
from ._checks import BuilderWithDefaults, execute_build_time_tests
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
from llnl.util.filesystem import working_dir
|
|
||||||
|
|
||||||
from spack.package import (
|
from spack.package import (
|
||||||
PackageBase,
|
PackageBase,
|
||||||
Prefix,
|
Prefix,
|
||||||
@ -11,6 +9,7 @@
|
|||||||
depends_on,
|
depends_on,
|
||||||
register_builder,
|
register_builder,
|
||||||
run_after,
|
run_after,
|
||||||
|
working_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ._checks import BuilderWithDefaults, execute_build_time_tests, execute_install_time_tests
|
from ._checks import BuilderWithDefaults, execute_build_time_tests, execute_install_time_tests
|
||||||
|
Loading…
Reference in New Issue
Block a user