-
-
Notifications
You must be signed in to change notification settings - Fork 473
Create Kivy bootstrap #2430
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
Draft
kengoon
wants to merge
3
commits into
beeware:main
Choose a base branch
from
kengoon:kivy-bootstrap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Create Kivy bootstrap #2430
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Create Kivy Bootstrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something like this is needed, it needs to either be a generic feature, or refactored into being feature of the backend, rather than being part of the generic create command.
However, I'd be a lot more interested in understanding why this is required at all. Why does the install work for Kivy "by default", but not for Briefcase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freakboy3742 Kivy works by default because, when installed without the --target flag, it places its core dependencies in the share directory (on Windows only). If you check the metadata for Kivy’s core dependencies, you’ll see binaries like
../../share/glew/bin/glew32.dll,sha256=mkzO8kYHqSwXhGhQjbKXKCnvjfO94EsWyv5ZEr9TZTM,464896are located there. In Kivy, the following code:looks for these dependencies in the .venv directory, not in
.venv/Lib/site-packages. Here, .venv corresponds to sys.prefix. However, in Briefcase, sys.prefix points to<app-name>/build/<app-name>/windows/app/src. When the --target flag is used, the share folder ends up in app_package instead of src (which is Briefcase’s default sys.prefix), causing the difference in behavior.Please can you explain more about the backend. I'm a little bit confused and I'm new to briefcase codebase structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue this is a bug in Kivy, and how it's packaging its dependencies. There's no guarantee that
../../shareexists, is writable, or that../../shareis guaranteed to be equivalent to{sys.prefix}/share. It will be if you're installing into a full Python install, or as part of a virtual environment - but that's not a hard guarantee that Python makes. Kivy is missing an edge case of PEP 376 interpretation.PEP 376 defines the entries in RECORD as:
The base location is defined as "the path defined by the --install-lib option, which defaults to the site-packages directory."; the installation prefix is defined as "path defined by the --prefix option, which defaults to sys.prefix."
Kivy is leaning on the second definition. In a standard Windows virtual environment, the installation prefix (
sys.prefix) is the venv directory, and the base location isLib/site-packagesrelative to that path, so it works, and it's legal.However, there's no requirement that the base location is a subpath of the installation prefix - and when you use
--targetto install, it won't be.Unfortunately, the PEP doesn't specify the fallback behavior in this case; evidently pip is stripping the relative path portions if the base location isn't a subpath of the installation prefix.
That said - there are evidently other packages that make a similar assumption -
pywin32, for example. So - it would appear Briefcase needs to make a change here.One possible workaround would be to restructure the Windows app template so that Briefcase uses
Lib/app_packagesrather than a bareapp_packagesfolder. That would ensure that../../sharewould resolve to a consistent location - but would also require us to redirectsys.prefixat time of installation to ensure thatpipbelieves the base location is a subpath of the installation prefix.The point I'm trying to make is that we're not going to add code to Briefcase that makes a special case of one specific package on one specific platform. Either we add a feature that can be used by all packages, based on a clearly documented standard (or, at least, commonly understood convention in the Python ecosystem), or the feature that is added needs to be isolated into a context where it only applies where it is needed (in this case, windows, when building a Kivy app).