27def change_root(new_root: str, pathname: str) -> str:
28 """Return 'pathname' with 'new_root' prepended.
29
30 If 'pathname' is relative, this is equivalent to os.path.join(new_root, pathname).
31 Otherwise, it requires making 'pathname' relative and then joining the
32 two, which is tricky on DOS/Windows and Mac OS.
33
34 This is borrowed from Python's standard library's distutils module.
35 """
39 else:
41
44 if path[0] == "\\":
45 path = path[1:]
47
48 else:
49 raise InstallationError(
50 f"Unknown platform: {os.name}\n"
51 "Can not change root path prefix on unknown platform."
52 )
53
54