https://github.com/python/cpython/commit/625470a7d2c6aa79b5e60ffe17785ccc2547a090
commit: 625470a7d2c6aa79b5e60ffe17785ccc2547a090
branch: main
author: Russell Keith-Magee <[email protected]>
committer: freakboy3742 <[email protected]>
date: 2025-02-13T14:03:43+08:00
summary:
gh-130025: Correct handling of symlinks during iOS testbed framework
installation. (#130026)
Correct handling of symlinks during iOS testbed framework installation.
files:
A Misc/NEWS.d/next/Tools-Demos/2025-02-12-14-58-54.gh-issue-130025._-mp5K.rst
M iOS/testbed/__main__.py
diff --git
a/Misc/NEWS.d/next/Tools-Demos/2025-02-12-14-58-54.gh-issue-130025._-mp5K.rst
b/Misc/NEWS.d/next/Tools-Demos/2025-02-12-14-58-54.gh-issue-130025._-mp5K.rst
new file mode 100644
index 00000000000000..ec011fe35697d9
--- /dev/null
+++
b/Misc/NEWS.d/next/Tools-Demos/2025-02-12-14-58-54.gh-issue-130025._-mp5K.rst
@@ -0,0 +1,2 @@
+The iOS testbed now correctly handles symlinks used as Python framework
+references.
diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py
index b4499f5ac171a8..08fbe90a1c6aef 100644
--- a/iOS/testbed/__main__.py
+++ b/iOS/testbed/__main__.py
@@ -230,33 +230,69 @@ def clone_testbed(
shutil.copytree(source, target, symlinks=True)
print(" done")
+ xc_framework_path = target / "Python.xcframework"
+ sim_framework_path = xc_framework_path / "ios-arm64_x86_64-simulator"
if framework is not None:
if framework.suffix == ".xcframework":
print(" Installing XCFramework...", end="", flush=True)
- xc_framework_path = (target / "Python.xcframework").resolve()
if xc_framework_path.is_dir():
shutil.rmtree(xc_framework_path)
else:
- xc_framework_path.unlink()
+ xc_framework_path.unlink(missing_ok=True)
xc_framework_path.symlink_to(
framework.relative_to(xc_framework_path.parent, walk_up=True)
)
print(" done")
else:
print(" Installing simulator framework...", end="", flush=True)
- sim_framework_path = (
- target / "Python.xcframework" / "ios-arm64_x86_64-simulator"
- ).resolve()
if sim_framework_path.is_dir():
shutil.rmtree(sim_framework_path)
else:
- sim_framework_path.unlink()
+ sim_framework_path.unlink(missing_ok=True)
sim_framework_path.symlink_to(
framework.relative_to(sim_framework_path.parent, walk_up=True)
)
print(" done")
else:
- print(" Using pre-existing iOS framework.")
+ if (
+ xc_framework_path.is_symlink()
+ and not xc_framework_path.readlink().is_absolute()
+ ):
+ # XCFramework is a relative symlink. Rewrite the symlink relative
+ # to the new location.
+ print(" Rewriting symlink to XCframework...", end="", flush=True)
+ orig_xc_framework_path = (
+ source
+ / xc_framework_path.readlink()
+ ).resolve()
+ xc_framework_path.unlink()
+ xc_framework_path.symlink_to(
+ orig_xc_framework_path.relative_to(
+ xc_framework_path.parent, walk_up=True
+ )
+ )
+ print(" done")
+ elif (
+ sim_framework_path.is_symlink()
+ and not sim_framework_path.readlink().is_absolute()
+ ):
+ print(" Rewriting symlink to simulator framework...", end="",
flush=True)
+ # Simulator framework is a relative symlink. Rewrite the symlink
+ # relative to the new location.
+ orig_sim_framework_path = (
+ source
+ / "Python.XCframework"
+ / sim_framework_path.readlink()
+ ).resolve()
+ sim_framework_path.unlink()
+ sim_framework_path.symlink_to(
+ orig_sim_framework_path.relative_to(
+ sim_framework_path.parent, walk_up=True
+ )
+ )
+ print(" done")
+ else:
+ print(" Using pre-existing iOS framework.")
for app_src in apps:
print(f" Installing app {app_src.name!r}...", end="", flush=True)
@@ -372,8 +408,8 @@ def main():
if context.subcommand == "clone":
clone_testbed(
- source=Path(__file__).parent,
- target=Path(context.location),
+ source=Path(__file__).parent.resolve(),
+ target=Path(context.location).resolve(),
framework=Path(context.framework).resolve() if context.framework
else None,
apps=[Path(app) for app in context.apps],
)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]