Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
e907723
Add iOS framework loading machinery.
freakboy37421359bc8
Removed a stray character.
freakboy37425e0659e
Simplify logic for dylib extensions.
freakboy3742d5fda7e
Clarified docstrings and implementation on iOS Loader/Finder, and add…
freakboy3742284e225
Add iOS to the list of platforms known by documentation.
freakboy37429f42faa
Improvements to documentation.
freakboy37428308611
Modify loader to do more processing in the finder.
freakboy3742fa3ffbb
Switch to a FileLoader-based approach for Apple framework loading.
freakboy3742dbf818d
Merge branch 'main' into ios-framework-loader
freakboy3742e66aee1
Add the ability to reverse a framework back to it's origin location.
freakboy374204d1c79
Ensure CFBundleShortVersionString meets App Store guidelines.
freakboy3742File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion.gitignore
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
11 changes: 11 additions & 0 deletionsLib/ctypes/__init__.py
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
2 changes: 1 addition & 1 deletionLib/ctypes/util.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -52,7 +52,7 @@ | ||
# Bootstrap-related code ###################################################### | ||
_CASE_INSENSITIVE_PLATFORMS_STR_KEY = 'win', | ||
_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY = 'cygwin', 'darwin', 'ios', 'tvos', 'watchos' | ||
_CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY | ||
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY) | ||
@@ -1711,6 +1711,46 @@ def __repr__(self): | ||
return f'FileFinder({self.path!r})' | ||
class AppleFrameworkLoader(ExtensionFileLoader): | ||
"""A loader for modules that have been packaged as frameworks for | ||
compatibility with Apple's iOS App Store policies. | ||
""" | ||
def create_module(self, spec): | ||
# If the ModuleSpec has been created by the FileFinder, it will have | ||
# been created with an origin pointing to the .fwork file. We need to | ||
# redirect this to the location in the Frameworks folder, using the | ||
# content of the .fwork file. | ||
if spec.origin.endswith(".fwork"): | ||
with _io.FileIO(spec.origin, 'r') as file: | ||
framework_binary = file.read().decode().strip() | ||
bundle_path = _path_split(sys.executable)[0] | ||
spec.origin = _path_join(bundle_path, framework_binary) | ||
# If the loader is created based on the spec for a loaded module, the | ||
# path will be pointing at the Framework location. If this occurs, | ||
# get the original .fwork location to use as the module's __file__. | ||
if self.path.endswith(".fwork"): | ||
path = self.path | ||
else: | ||
with _io.FileIO(self.path + ".origin", 'r') as file: | ||
origin = file.read().decode().strip() | ||
bundle_path = _path_split(sys.executable)[0] | ||
path = _path_join(bundle_path, origin) | ||
module = _bootstrap._call_with_frames_removed(_imp.create_dynamic, spec) | ||
_bootstrap._verbose_message( | ||
"Apple framework extension module {!r} loaded from {!r} (path {!r})", | ||
spec.name, | ||
spec.origin, | ||
path, | ||
) | ||
# Ensure that the __file__ points at the .fwork location | ||
module.__file__ = path | ||
return module | ||
# Import setup ############################################################### | ||
def _fix_up_module(ns, name, pathname, cpathname=None): | ||
@@ -1743,10 +1783,17 @@ def _get_supported_file_loaders(): | ||
Each item is a tuple (loader, suffixes). | ||
""" | ||
if sys.platform in {"ios", "tvos", "watchos"}: | ||
extension_loaders = [(AppleFrameworkLoader, [ | ||
suffix.replace(".so", ".fwork") | ||
for suffix in _imp.extension_suffixes() | ||
])] | ||
ericsnowcurrently marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
else: | ||
extension_loaders = [] | ||
extension_loaders.append((ExtensionFileLoader, _imp.extension_suffixes())) | ||
source = SourceFileLoader, SOURCE_SUFFIXES | ||
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES | ||
returnextension_loaders + [source, bytecode] | ||
def _set_bootstrap_module(_bootstrap_module): | ||
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
7 changes: 6 additions & 1 deletionLib/inspect.py
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.