From fb2c3b348cd468db2a520c33d3ac4c6d07ea0407 Mon Sep 17 00:00:00 2001 From: MihailJP Date: Sat, 9 Nov 2024 22:12:38 +0900 Subject: [PATCH] make external_project work again on MinGW On Python 3.12, self.prefix.relative_to(self.prefix.drive) no longer works and raises error like: ``` ValueError: 'C:/msys64/mingw64' is not in the subpath of 'C:' ``` --- mesonbuild/modules/external_project.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesonbuild/modules/external_project.py b/mesonbuild/modules/external_project.py index 9e283e026..57a1819a3 100644 --- a/mesonbuild/modules/external_project.py +++ b/mesonbuild/modules/external_project.py @@ -19,7 +19,7 @@ from ..interpreterbase import FeatureNew from ..interpreter.type_checking import ENV_KW, DEPENDS_KW from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, typed_kwargs, typed_pos_args from ..mesonlib import (EnvironmentException, MesonException, Popen_safe, MachineChoice, - get_variable_regex, do_replacement, join_args) + get_variable_regex, do_replacement, join_args, relpath) from ..options import OptionKey if T.TYPE_CHECKING: @@ -93,10 +93,10 @@ class ExternalProject(NewExtensionModule): # will install files into "c:/bar/c:/foo" which is an invalid path. # Work around that issue by removing the drive from prefix. if self.prefix.drive: - self.prefix = self.prefix.relative_to(self.prefix.drive) + self.prefix = Path(relpath(self.prefix, self.prefix.drive)) # self.prefix is an absolute path, so we cannot append it to another path. - self.rel_prefix = self.prefix.relative_to(self.prefix.root) + self.rel_prefix = Path(relpath(self.prefix, self.prefix.root)) self._configure(state)