@@ -230,33 +230,69 @@ def clone_testbed( |
230 | 230 | shutil.copytree(source, target, symlinks=True) |
231 | 231 | print(" done") |
232 | 232 |
|
| 233 | + xc_framework_path = target / "Python.xcframework" |
| 234 | + sim_framework_path = xc_framework_path / "ios-arm64_x86_64-simulator" |
233 | 235 | if framework is not None: |
234 | 236 | if framework.suffix == ".xcframework": |
235 | 237 | print(" Installing XCFramework...", end="", flush=True) |
236 | | - xc_framework_path = (target / "Python.xcframework").resolve() |
237 | 238 | if xc_framework_path.is_dir(): |
238 | 239 | shutil.rmtree(xc_framework_path) |
239 | 240 | else: |
240 | | - xc_framework_path.unlink() |
| 241 | + xc_framework_path.unlink(missing_ok=True) |
241 | 242 | xc_framework_path.symlink_to( |
242 | 243 | framework.relative_to(xc_framework_path.parent, walk_up=True) |
243 | 244 | ) |
244 | 245 | print(" done") |
245 | 246 | else: |
246 | 247 | print(" Installing simulator framework...", end="", flush=True) |
247 | | - sim_framework_path = ( |
248 | | - target / "Python.xcframework" / "ios-arm64_x86_64-simulator" |
249 | | - ).resolve() |
250 | 248 | if sim_framework_path.is_dir(): |
251 | 249 | shutil.rmtree(sim_framework_path) |
252 | 250 | else: |
253 | | - sim_framework_path.unlink() |
| 251 | + sim_framework_path.unlink(missing_ok=True) |
254 | 252 | sim_framework_path.symlink_to( |
255 | 253 | framework.relative_to(sim_framework_path.parent, walk_up=True) |
256 | 254 | ) |
257 | 255 | print(" done") |
258 | 256 | else: |
259 | | - print(" Using pre-existing iOS framework.") |
| 257 | + if ( |
| 258 | + xc_framework_path.is_symlink() |
| 259 | + and not xc_framework_path.readlink().is_absolute() |
| 260 | + ): |
| 261 | + # XCFramework is a relative symlink. Rewrite the symlink relative |
| 262 | + # to the new location. |
| 263 | + print(" Rewriting symlink to XCframework...", end="", flush=True) |
| 264 | + orig_xc_framework_path = ( |
| 265 | + source |
| 266 | + / xc_framework_path.readlink() |
| 267 | + ).resolve() |
| 268 | + xc_framework_path.unlink() |
| 269 | + xc_framework_path.symlink_to( |
| 270 | + orig_xc_framework_path.relative_to( |
| 271 | + xc_framework_path.parent, walk_up=True |
| 272 | + ) |
| 273 | + ) |
| 274 | + print(" done") |
| 275 | + elif ( |
| 276 | + sim_framework_path.is_symlink() |
| 277 | + and not sim_framework_path.readlink().is_absolute() |
| 278 | + ): |
| 279 | + print(" Rewriting symlink to simulator framework...", end="", flush=True) |
| 280 | + # Simulator framework is a relative symlink. Rewrite the symlink |
| 281 | + # relative to the new location. |
| 282 | + orig_sim_framework_path = ( |
| 283 | + source |
| 284 | + / "Python.XCframework" |
| 285 | + / sim_framework_path.readlink() |
| 286 | + ).resolve() |
| 287 | + sim_framework_path.unlink() |
| 288 | + sim_framework_path.symlink_to( |
| 289 | + orig_sim_framework_path.relative_to( |
| 290 | + sim_framework_path.parent, walk_up=True |
| 291 | + ) |
| 292 | + ) |
| 293 | + print(" done") |
| 294 | + else: |
| 295 | + print(" Using pre-existing iOS framework.") |
260 | 296 |
|
261 | 297 | for app_src in apps: |
262 | 298 | print(f" Installing app {app_src.name!r}...", end="", flush=True) |
@@ -372,8 +408,8 @@ def main(): |
372 | 408 |
|
373 | 409 | if context.subcommand == "clone": |
374 | 410 | clone_testbed( |
375 | | - source=Path(__file__).parent, |
376 | | - target=Path(context.location), |
| 411 | + source=Path(__file__).parent.resolve(), |
| 412 | + target=Path(context.location).resolve(), |
377 | 413 | framework=Path(context.framework).resolve() if context.framework else None, |
378 | 414 | apps=[Path(app) for app in context.apps], |
379 | 415 | ) |
|