From e9a1d0a1576264a56de430213530f26e71b9b4af Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Tue, 4 Apr 2023 09:45:43 +0200 Subject: filter __spack_path_placeholder__ in generated module files after buildcache install (#36611) * filter __spack_path_placeholder__ in generated module files after buildcache install * fix windows --- lib/spack/spack/modules/common.py | 2 +- lib/spack/spack/util/path.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index 66fe145f35..b5e084bc0c 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -703,7 +703,7 @@ class BaseContext(tengine.Context): if os.path.exists(pkg.install_configure_args_path): with open(pkg.install_configure_args_path, "r") as args_file: - return args_file.read() + return spack.util.path.padding_filter(args_file.read()) # Returning a false-like value makes the default templates skip # the configure option section diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py index 124e8efec6..f894f6f3d8 100644 --- a/lib/spack/spack/util/path.py +++ b/lib/spack/spack/util/path.py @@ -444,7 +444,7 @@ def padding_filter(string): r"(/{pad})+" # the padding string repeated one or more times r"(/{longest_prefix})?(?=/)" # trailing prefix of padding as path component ) - regex = regex.replace("/", os.sep) + regex = regex.replace("/", re.escape(os.sep)) regex = regex.format(pad=pad, longest_prefix=longest_prefix) _filter_re = re.compile(regex) -- cgit v1.2.3-60-g2f50