diff --git a/distutils/command/install.py b/distutils/command/install.py index 8421d54e..76861d5a 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -19,7 +19,13 @@ from ..errors import DistutilsOptionError, DistutilsPlatformError from ..file_util import write_file from ..sysconfig import get_config_vars -from ..util import change_root, convert_path, get_platform, subst_vars +from ..util import ( + change_root, + convert_path, + escape_curly_brackets, + get_platform, + subst_vars, +) from . import _framework_compat as fw HAS_USER_SITE = True @@ -562,8 +568,14 @@ def finalize_unix(self) -> None: # Allow Fedora to add components to the prefix _prefix_addition = getattr(sysconfig, '_prefix_addition', "") - self.prefix = os.path.normpath(sys.prefix) + _prefix_addition - self.exec_prefix = os.path.normpath(sys.exec_prefix) + _prefix_addition + self.prefix = ( + escape_curly_brackets(os.path.normpath(sys.prefix)) + + _prefix_addition + ) + self.exec_prefix = ( + escape_curly_brackets(os.path.normpath(sys.exec_prefix)) + + _prefix_addition + ) else: if self.exec_prefix is None: @@ -585,7 +597,7 @@ def finalize_other(self) -> None: self.select_scheme("posix_home") else: if self.prefix is None: - self.prefix = os.path.normpath(sys.prefix) + self.prefix = escape_curly_brackets(os.path.normpath(sys.prefix)) self.install_base = self.install_platbase = self.prefix try: diff --git a/distutils/util.py b/distutils/util.py index be4953f9..5146d880 100644 --- a/distutils/util.py +++ b/distutils/util.py @@ -185,6 +185,13 @@ def check_environ() -> None: os.environ['PLAT'] = get_platform() +def escape_curly_brackets(s): + """ + Escape curly brackets in string for format_map + """ + return s.translate(str.maketrans({'{': '{{', '}': '}}'})) + + def subst_vars(s, local_vars: Mapping[str, object]) -> str: """ Perform variable substitution on 'string'.