-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-114099 - Add iOS framework loading machinery. #116454
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e907723
Add iOS framework loading machinery.
freakboy3742 1359bc8
Removed a stray character.
freakboy3742 5e0659e
Simplify logic for dylib extensions.
freakboy3742 d5fda7e
Clarified docstrings and implementation on iOS Loader/Finder, and add…
freakboy3742 284e225
Add iOS to the list of platforms known by documentation.
freakboy3742 9f42faa
Improvements to documentation.
freakboy3742 8308611
Modify loader to do more processing in the finder.
freakboy3742 fa3ffbb
Switch to a FileLoader-based approach for Apple framework loading.
freakboy3742 dbf818d
Merge branch 'main' into ios-framework-loader
freakboy3742 e66aee1
Add the ability to reverse a framework back to it's origin location.
freakboy3742 04d1c79
Ensure CFBundleShortVersionString meets App Store guidelines.
freakboy3742 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 | ||||
---|---|---|---|---|---|---|
|
@@ -1241,6 +1241,74 @@ find and load modules. | |||||
and how the module's :attr:`__file__` is populated. | ||||||
|
||||||
|
||||||
.. class:: AppleFrameworkLoader(fullname, dylib_path, parent_paths=None) | ||||||
|
||||||
A specialization of :class:`importlib.machinery.ExtensionFileLoader` that | ||||||
is able to load extension modules in Framework format. | ||||||
|
||||||
For compatibility with the iOS App Store, *all* binary modules in an iOS app | ||||||
must be ``.dylib objects``, contained in a framework with appropriate | ||||||
metadata, stored in the ``Frameworks`` folder of the packaged app. There can | ||||||
be only a single binary per framework, and there can be no executable binary | ||||||
material outside the Frameworks folder. | ||||||
|
||||||
If you're trying to run ``from foo.bar import _whiz``, and ``_whiz`` is | ||||||
implemented with the binary module ``foo/bar/_whiz.abi3.dylib`` (or any | ||||||
other ABI .dylib extension), this loader will look for | ||||||
``{sys.executable}/Frameworks/foo.bar._whiz.framework/_whiz.abi3.dylib`` | ||||||
(forming the package name by taking the full import path of the library, | ||||||
and replacing ``/`` with ``.``). | ||||||
|
||||||
However, this loader will re-write the ``__file__`` attribute of the | ||||||
``_whiz`` module will report as the original location inside the ``foo/bar`` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've reworked this sentence, so the suggestion no longer applies. |
||||||
subdirectory. This so that code that depends on walking directory trees will | ||||||
continue to work as expected based on the *original* file location. | ||||||
|
||||||
The *fullname* argument specifies the name of the module the loader is to | ||||||
support. The *dylib_path* argument is the path to the framework's ``.dylib`` | ||||||
file. The ``parent_paths`` is the path or paths that was searched to find | ||||||
the extension module. | ||||||
|
||||||
.. versionadded:: 3.13 | ||||||
|
||||||
.. availability:: iOS. | ||||||
|
||||||
.. attribute:: fullname | ||||||
|
||||||
Name of the module the loader supports. | ||||||
|
||||||
.. attribute:: dylib_path | ||||||
|
||||||
Path to the ``.dylib`` file in the framework. | ||||||
|
||||||
.. attribute:: parent_paths | ||||||
|
||||||
The parent paths that were originally searched to find the module. | ||||||
|
||||||
.. class:: AppleFrameworkFinder(framework_path) | ||||||
|
||||||
An extension module finder which is able to load extension modules packaged | ||||||
as frameworks in an iOS app. | ||||||
|
||||||
See the documentation for :class:`AppleFrameworkLoader` for details on the | ||||||
requirements of binary extension modules on iOS. | ||||||
|
||||||
The *framework_path* argument is the Frameworks directory for the app. | ||||||
|
||||||
.. versionadded:: 3.13 | ||||||
|
||||||
.. availability:: iOS. | ||||||
|
||||||
.. attribute:: framework_path | ||||||
|
||||||
The path the finder will search for frameworks. | ||||||
|
||||||
.. method:: find_spec(fullname, paths, target=None) | ||||||
|
||||||
Attempt to find the spec to handle ``fullname``, imported from one | ||||||
of the filesystem locations described by ``paths``. | ||||||
|
||||||
|
||||||
:mod:`importlib.util` -- Utility code for importers | ||||||
--------------------------------------------------- | ||||||
|
||||||
|
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.