Use isolated virtual environments for app builds. - #2967
Conversation
What kinds of influence have you seen?
This causes a significant slowdown in reinstalling requirements, for example The vast majority of this is from installing pip into the new environment, and then updating it to its current version. However, there's a way to avoid this:
|
The main way I see this manifest: If I have a environment with an editable install of Briefcase and Toga installed, and I create an app that lists
That's correct. I agree this performance isn't great; but it's also a case where I think correctness trumps performance. That said - it's also an area where
Interesting... and that has the added benefit that pip won't be in the installed app environment. I'll tinker with this and see if I can make it work. |
Well... that was really straightforward, and works incredibly well. The environment creation step is now near-instantaneous, in both |
| requires = [ | ||
| "pillow==9.1.0", | ||
| "--no-binary", "pillow", | ||
| "--no-binary", | ||
| "pillow", |
There was a problem hiding this comment.
Suggest changing this example to userequirement_installer_args, and moving it to that option's section, because it doesn't currently have any examples except for those involving path transformation.
There was a problem hiding this comment.
Agreed this example needs to be updated; I was planning to tweak these docs as part of the uv update (since that's the point where requires strictly stops being a "you can pass in any installer arg" option.
|
|
||
|
|
||
| class WindowsCreateCommand(CreateCommand): | ||
| require_binary_installs = True |
There was a problem hiding this comment.
Why require this on Windows? If there's a good reason, then it should be explained in a comment, and a removal change note should be included.
There was a problem hiding this comment.
The reason is similar, but not identical to macOS - a combination of security (so app builders aren't running code to do an install), and protection against the lack of a compiler by default on Windows.
I've reworked how this is set up so that "require = True" is the default (migrating the documentation from the macOS version), with Linux getting a specific opt-out.
Part of series of changes extracted from #2917.
Use fully isolated environments for app builds. This ensures that the environment running Briefcase has no influence on how apps are constructed, and allows the installation of requirements to be fully abstracted as an environment behaviour.
Adds tooling to create a virtual environment as part of app creation, and that virtual environment is used to install requirements into the app. The app environment is re-created whenever requirements are installed (or re-installed)
During update, the support package is now installed before installing requirements. This matches the order of the create command.
Moves app verification to before the installation of the support package but after template generation.
As part of this change,
install_requirements()and_install_requirements()have been required so that the latter just does the requirements install; this allows platforms like iOS and macOS to override that to do 2-pass and/or merged installs.PR Checklist: