Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for in-framework platform-config folders. #2155

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/2155.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Briefcase will now default to using the ``platform-config`` folders that were added to the iOS support package as part of supporting cibuildwheel on iOS.
34 changes: 24 additions & 10 deletions src/briefcase/platforms/iOS/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ def _install_app_requirements(
)
ios_min_tag = versions.get("Min iOS version", "13.0").replace(".", "_")

# Feb 2025: The platform-site was moved into the xcframework as
# `platform-config`. Look for the new location; fall back to the old location.
device_platform_site = (
self.support_path(app)
/ "Python.xcframework/ios-arm64/platform-config/arm64-iphoneos"
)
simulator_platform_site = (
self.support_path(app)
/ "Python.xcframework/ios-arm64_x86_64-simulator"
/ f"platform-config/{self.tools.host_arch}-iphonesimulator"
)
if not device_platform_site.exists():
device_platform_site = (
self.support_path(app) / "platform-site/iphoneos.arm64"
)
simulator_platform_site = (
self.support_path(app)
/ f"platform-site/iphonesimulator.{self.tools.host_arch}"
)

# Perform the initial install pass targeting the "iphoneos" platform
super()._install_app_requirements(
app,
Expand All @@ -340,10 +360,8 @@ def _install_app_requirements(
],
pip_kwargs={
"env": {
"PYTHONPATH": str(
self.support_path(app) / "platform-site/iphoneos.arm64"
)
}
"PYTHONPATH": str(device_platform_site),
},
},
)

Expand All @@ -359,12 +377,8 @@ def _install_app_requirements(
],
pip_kwargs={
"env": {
"PYTHONPATH": str(
self.support_path(app)
/ "platform-site"
/ f"iphonesimulator.{self.tools.host_arch}"
)
}
"PYTHONPATH": str(simulator_platform_site),
},
},
)

Expand Down
14 changes: 14 additions & 0 deletions tests/platforms/iOS/xcode/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,18 @@ def first_app_generated(first_app_config, tmp_path):
]
),
)
# Create the package-config folders for each platform.
# We don't need anything in them; they just need to exist.
xcframework_path = (
tmp_path / "base_path/build/first-app/ios/xcode/Support/Python.xcframework"
)
(xcframework_path / "ios-arm64/platform-config/arm64-iphoneos").mkdir(parents=True)
(
xcframework_path
/ "ios-arm64_x86_64-simulator/platform-config/arm64-iphonesimulator"
).mkdir(parents=True)
(
xcframework_path
/ "ios-arm64_x86_64-simulator/platform-config/x86_64-iphonesimulator"
).mkdir(parents=True)
return first_app_config
52 changes: 35 additions & 17 deletions tests/platforms/iOS/xcode/test_create.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import sys
from unittest.mock import MagicMock, call

Expand Down Expand Up @@ -30,8 +31,37 @@ def test_unsupported_host_os(create_command, host_os):
create_command()


def test_extra_pip_args(create_command, first_app_generated, tmp_path):
@pytest.mark.parametrize(
"old_config, device_config_path, sim_config_path",
[
(
False,
"Python.xcframework/ios-arm64/platform-config/arm64-iphoneos",
"Python.xcframework/ios-arm64_x86_64-simulator/platform-config/wonky-iphonesimulator",
),
(
True,
"platform-site/iphoneos.arm64",
"platform-site/iphonesimulator.wonky",
),
],
)
def test_extra_pip_args(
create_command,
first_app_generated,
old_config,
device_config_path,
sim_config_path,
tmp_path,
):
"""Extra iOS-specific args are included in calls to pip during update."""
# If we're testing an old config, delete the xcframework. This deletes the platform
# config folders, forcing a fallback to the older locations.
if old_config:
shutil.rmtree(
tmp_path / "base_path/build/first-app/ios/xcode/Support/Python.xcframework"
)

# Hard code the current architecture for testing. We only install simulator
# requirements for the current platform.
create_command.tools.host_arch = "wonky"
Expand Down Expand Up @@ -71,14 +101,8 @@ def test_extra_pip_args(create_command, first_app_generated, tmp_path):
env={
"PYTHONPATH": str(
tmp_path
/ "base_path"
/ "build"
/ "first-app"
/ "ios"
/ "xcode"
/ "Support"
/ "platform-site"
/ "iphoneos.arm64"
/ "base_path/build/first-app/ios/xcode/Support"
/ device_config_path
)
},
),
Expand Down Expand Up @@ -107,14 +131,8 @@ def test_extra_pip_args(create_command, first_app_generated, tmp_path):
env={
"PYTHONPATH": str(
tmp_path
/ "base_path"
/ "build"
/ "first-app"
/ "ios"
/ "xcode"
/ "Support"
/ "platform-site"
/ "iphonesimulator.wonky"
/ "base_path/build/first-app/ios/xcode/Support"
/ sim_config_path
)
},
),
Expand Down
52 changes: 35 additions & 17 deletions tests/platforms/iOS/xcode/test_update.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import sys
from unittest.mock import MagicMock, call

Expand All @@ -17,8 +18,37 @@ def update_command(tmp_path):
)


def test_extra_pip_args(update_command, first_app_generated, tmp_path):
@pytest.mark.parametrize(
"old_config, device_config_path, sim_config_path",
[
(
False,
"Python.xcframework/ios-arm64/platform-config/arm64-iphoneos",
"Python.xcframework/ios-arm64_x86_64-simulator/platform-config/wonky-iphonesimulator",
),
(
True,
"platform-site/iphoneos.arm64",
"platform-site/iphonesimulator.wonky",
),
],
)
def test_extra_pip_args(
update_command,
first_app_generated,
old_config,
device_config_path,
sim_config_path,
tmp_path,
):
"""Extra iOS-specific args are included in calls to pip during update."""
# If we're testing an old config, delete the xcframework. This deletes the platform
# config folders, forcing a fallback to the older locations.
if old_config:
shutil.rmtree(
tmp_path / "base_path/build/first-app/ios/xcode/Support/Python.xcframework"
)

# Hard code the current architecture for testing. We only install simulator
# requirements for the current platform.
update_command.tools.host_arch = "wonky"
Expand Down Expand Up @@ -58,14 +88,8 @@ def test_extra_pip_args(update_command, first_app_generated, tmp_path):
env={
"PYTHONPATH": str(
tmp_path
/ "base_path"
/ "build"
/ "first-app"
/ "ios"
/ "xcode"
/ "Support"
/ "platform-site"
/ "iphoneos.arm64"
/ "base_path/build/first-app/ios/xcode/Support"
/ device_config_path
)
},
),
Expand Down Expand Up @@ -94,14 +118,8 @@ def test_extra_pip_args(update_command, first_app_generated, tmp_path):
env={
"PYTHONPATH": str(
tmp_path
/ "base_path"
/ "build"
/ "first-app"
/ "ios"
/ "xcode"
/ "Support"
/ "platform-site"
/ "iphonesimulator.wonky"
/ "base_path/build/first-app/ios/xcode/Support"
/ sim_config_path
)
},
),
Expand Down
Loading