Fix spack.repo.is_package_module (#50464)
This commit is contained in:
parent
abcef565a8
commit
abcc641373
@ -55,7 +55,9 @@
|
||||
|
||||
def is_package_module(fullname: str) -> bool:
|
||||
"""Check if the given module is a package module."""
|
||||
return fullname.startswith(PKG_MODULE_PREFIX_V1) or fullname.startswith(PKG_MODULE_PREFIX_V2)
|
||||
return fullname.startswith(PKG_MODULE_PREFIX_V1) or (
|
||||
fullname.startswith(PKG_MODULE_PREFIX_V2) and fullname.endswith(".package")
|
||||
)
|
||||
|
||||
|
||||
def namespace_from_fullname(fullname: str) -> str:
|
||||
|
@ -523,3 +523,10 @@ def test_subdir_in_v2():
|
||||
|
||||
with pytest.raises(spack.repo.BadRepoError, match="Must be a valid Python module name"):
|
||||
spack.repo._validate_and_normalize_subdir(subdir="123", root="root", package_api=(2, 0))
|
||||
|
||||
|
||||
def test_is_package_module():
|
||||
assert spack.repo.is_package_module("spack.pkg.something.something")
|
||||
assert spack.repo.is_package_module("spack_repo.foo.bar.baz.package")
|
||||
assert not spack.repo.is_package_module("spack_repo.builtin.build_systems.cmake")
|
||||
assert not spack.repo.is_package_module("spack.something.else")
|
||||
|
Loading…
Reference in New Issue
Block a user