Skip to content
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/3072.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Briefcase will now use the support package that is downloaded as part of the build to construct cross-platform environments, instead of attempting to use the xbuild cache.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies = [
"pip >= 24.3",
"setuptools >= 60",
"wheel >= 0.37",
"xbuild >= 0.3.0",
"xbuild >= 0.4.0",
#
# For the remaining packages: We set the lower version limit to the lowest possible
# version that satisfies our API needs. If the package uses semver, we set a limit
Expand Down
10 changes: 5 additions & 5 deletions src/briefcase/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,17 +1010,17 @@ def create_app(self, app: FinalizedAppConfig, **options):
prefix=app.app_name,
)
else:
venv_class = self.tools.virtual_environment[app.env_manager]
if not venv_class.provides_python:
self.console.info("Installing support package...", prefix=app.app_name)
self.install_app_support_package(app=app)

self.console.info("Creating app environment...", prefix=app.app_name)
venv = self.create_app_environment(
app=app,
platform=self.platform,
arch=self.tools.host_arch,
)

if not venv.provides_python:
self.console.info("Installing support package...", prefix=app.app_name)
self.install_app_support_package(app=app)

try:
# If the platform uses a stub binary, the template will define a binary
# revision. If this template configuration item doesn't exist, no stub
Expand Down
19 changes: 10 additions & 9 deletions src/briefcase/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,26 @@ def update_app(
self.console.info("Updating application code...", prefix=app.app_name)
self.install_app_code(app=app)

venv = self.create_app_environment(
app=app,
platform=self.platform,
arch=self.tools.host_arch,
recreate=update_requirements or update_support,
)

# If support has been updated and the environment provides Python,
# we need to re-install requirements because requirements are stored
# in the managed environmebnt.
if update_support and venv.provides_python:
venv_class = self.tools.virtual_environment[app.env_manager]
if update_support and venv_class.provides_python:
update_requirements = True

# If the environment provides python, support is provided by the environment
if update_support and not venv.provides_python:
if update_support and not venv_class.provides_python:
self.console.info("Updating application support...", prefix=app.app_name)
self.cleanup_app_support_package(app=app)
self.install_app_support_package(app=app)

venv = self.create_app_environment(
app=app,
platform=self.platform,
arch=self.tools.host_arch,
recreate=update_requirements or update_support,
)

if update_requirements:
self.console.info("Updating requirements...", prefix=app.app_name)
self.install_app_requirements(app=app, venv=venv)
Expand Down
14 changes: 3 additions & 11 deletions src/briefcase/integrations/virtual_environment/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
*,
platform: str | None = None,
arch: str | None = None,
platform_path: Path | None = None,
support_path: Path | None = None,
):
"""Initialise the virtual environment on a specific path.

Expand All @@ -39,15 +39,15 @@ def __init__(
:param arch: The architecture for the environment. If this isn't the
host OS architecture, the environment will be a cross build
environment.
:param platform_path: The path where cross-platform details are stored.
:param support_path: The path where the support package is stored.
"""
self.name = name
self.app = app
self.tools = tools
self.base_path = base_path
self.platform = platform
self.arch = arch
self.platform_path = platform_path
self.support_path = support_path

@property
def venv_path(self):
Expand Down Expand Up @@ -179,13 +179,6 @@ def install_requirements(
]
)

# Add include the platform extensions vendored with with the
# support package so that pip will resolve transitive binary
# platform dependencies.
env = {"PYTHONPATH": str(self.platform_path)}
else:
env = None

if extra_installer_args:
install_args.extend(
self.tools.file.resolve_relative_args(
Expand Down Expand Up @@ -218,7 +211,6 @@ def install_requirements(
],
check=True,
encoding="UTF-8",
env=env,
)
except subprocess.CalledProcessError as e:
raise RequirementsInstallError(install_hint=install_hint) from e
Expand Down
10 changes: 9 additions & 1 deletion src/briefcase/integrations/virtual_environment/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ def prepare(self, recreate=False) -> bool:
else:
arch = f"{self.arch}-{self.platform}"

args = ["xvenv", "--platform", "ios", "--arch", arch]
args = [
"xvenv",
"--platform",
"ios",
"--arch",
arch,
"--archive",
self.support_path,
]
else:
args = ["venv"]
self.tools.subprocess.run(
Expand Down
12 changes: 1 addition & 11 deletions src/briefcase/platforms/iOS/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,24 +408,14 @@ def create_app_environment(
# Interpret that as the device; interpret all others as simulators.
if platform == "iOS":
platform = "iphoneos"
platform_path = (
self.support_path(app)
/ "Python.xcframework/ios-arm64/platform-config/arm64-iphoneos"
)
else:
platform_path = (
self.support_path(app)
/ "Python.xcframework/ios-arm64_x86_64-simulator/platform-config"
/ f"{arch}-iphonesimulator"
)

return super().create_app_environment(
app=app,
platform=platform,
arch=arch,
env_manager=env_manager,
recreate=recreate,
platform_path=platform_path,
support_path=self.support_path(app),
)

def _install_app_requirements(
Expand Down
10 changes: 5 additions & 5 deletions tests/commands/create/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_create(tracking_create_command, tmp_path):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand All @@ -47,8 +47,8 @@ def test_create(tracking_create_command, tmp_path):
("generate", "second"),
("verify-app-template", "second"),
("verify-app-tools", "second"),
("create-app-env", "second", "Tester", "gothic", "default", True),
("support", "second"),
("create-app-env", "second", "Tester", "gothic", "default", True),
("code", "second", False),
("requirements", "Tester-gothic", "second", False, False),
("resources", "second"),
Expand Down Expand Up @@ -80,8 +80,8 @@ def test_create_single(tracking_create_command, tmp_path):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand Down Expand Up @@ -119,8 +119,8 @@ def test_create_app_single(tracking_create_command, app_flags):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand Down Expand Up @@ -184,8 +184,8 @@ def test_create_app_all_flags(tracking_create_command):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/create/test_create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def test_create_app(tracking_create_command, tmp_path):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand Down Expand Up @@ -62,8 +62,8 @@ def test_create_existing_app_overwrite(tracking_create_command, tmp_path):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
Expand Down Expand Up @@ -203,8 +203,8 @@ def test_create_app_with_stub(tracking_create_command, tmp_path):
("generate", "first"),
("verify-app-template", "first"),
("verify-app-tools", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("stub", "first"),
("code", "first", False),
("requirements", "Tester-gothic", "first", False, False),
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/update/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ def test_update_with_support(update_command, first_app, second_app):
("verify-app-template", "first"),
("verify-app-tools", "first"),
("code", "first", False),
("create-app-env", "first", "Tester", "gothic", "default", True),
("cleanup-support", "first"),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("cleanup", "first"),
# Update the second app
("verify-app-template", "second"),
("verify-app-tools", "second"),
("code", "second", False),
("create-app-env", "second", "Tester", "gothic", "default", True),
("cleanup-support", "second"),
("support", "second"),
("create-app-env", "second", "Tester", "gothic", "default", True),
("cleanup", "second"),
]

Expand Down Expand Up @@ -273,9 +273,9 @@ def test_update_app_all_flags(update_command, first_app, second_app):
("verify-app-template", "first"),
("verify-app-tools", "first"),
("code", "first", False),
("create-app-env", "first", "Tester", "gothic", "default", True),
("cleanup-support", "first"),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("requirements", "Tester-gothic", "first", False, False),
("resources", "first"),
("cleanup", "first"),
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/update/test_update_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def test_update_app_with_support_package(update_command, first_app, tmp_path):
("verify-app-template", "first"),
("verify-app-tools", "first"),
("code", "first", False),
("create-app-env", "first", "Tester", "gothic", "default", True),
("cleanup-support", "first"),
("support", "first"),
("create-app-env", "first", "Tester", "gothic", "default", True),
("cleanup", "first"),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_create(first_app, mock_tools, base_path, tmp_path):
base_path=base_path,
platform="different",
arch="gothic",
platform_path=tmp_path / "support",
support_path=tmp_path / "support",
)

assert not venv.exists()
Expand All @@ -20,6 +20,6 @@ def test_create(first_app, mock_tools, base_path, tmp_path):
assert venv.name == "forest"
assert venv.base_path == base_path
assert venv.venv_path == base_path / ".briefcase/first-app/mock_venv-forest"
assert venv.platform_path == tmp_path / "support"
assert venv.support_path == tmp_path / "support"
assert venv.arch == "gothic"
assert venv.platform == "different"
Loading
Loading