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
building: macOS: limit binaries' architecture validation to extensions #6587
Conversation
As demonstrated by scipy 1.8.0, the multi-arch universal2 extensions may have their individual arch slices linked against distinct single-arch thin shared libraries. Such thin shared libraries will fail the current strict architecture validation, either by virtue of being single-arch (whereas the target architecture is universal2) or by virtue of at least one single-arch thin shared library being of incompatible architecture (e.g., arm64 thin shared library will be flagged as incompatible for x86_64 target, and x86_64 thin shared library will be flagged as incompatible for arm64 target). Therefore, limit the architecture validation only to python extension modules, which do need to be fully compatible with the target arch (at least until someone decides to ship distinct, arch-specific modules. But if that does happen, we can probably prevent the collection of incompatible module via hooks). The extension validation should hopefully still catch the attempts at using incompatible single-arch packages when trying to build a universal2 application or a single-arch application for architecture that's different from the running one.
(Not so) fun fact: despite |
Also, this PR does not address the underlying issue, which is that both single-arch While we could try to explicitly ignore shared libraries of incompatible architecture at collection stage, this poses a conceptually similar problem as with the original validation issue; we cannot be certain that the binary should not be collected. For example, a package ( So I think the proper approach is to add |
The whole point on PyPA adopting |
I can't say I'm comfortable with not validating shared libraries. Anything brew provides is single arch. Would it make sense to only skip validation for shared libraries provided by Python packages? I'm honestly tempted to scrap |
I think in this regard, brew is the least of our problems, precisely because it is predictably single-arch. Meaning that if someone tries to create a
We could do something like that - did you have any specific mechanism in mind, or just checking if the shared library comes from
I wouldn't object to that. The less I have to deal with macOS and its oddities, the better... :) |
Only if they install Python from brew too, right? If they use a
I'd probably go for a big _py_dist_files = set()
for distribution in importlib_metadata.distributions():
for file in distribution.files:
_py_dist_files.add(os.path.normpath(os.path.realpath(file.locate())))
def is_python_distribution_file(path):
return os.path.normpath(os.path.realpath(path)) in _py_dist_files
|
Do we have any idea what the performance implications are (e.g., in a conda environment with an assortment of deep learning and GUI frameworks installed)? |
Hmm, takes about 2 seconds to crunch through the ~200 packages I have in my default Python environment. I believe that full Conda ships about 250 by default so it shouldn't be much worse - especially against the several minutes PyInstaller would likely take to do everything else in such a large environment. |
I'm fairly clueless when it comes to macOS's many architectures, I trust you guys. |
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.
Hmm, let's just go for it. I'm rather low on patience for Apple's self inflicted quirks.
OK. We can revisit this and tighten the check later, if necessary (FWIW, |
As demonstrated by
scipy
1.8.0, the multi-archuniversal2
extensions may have their individual arch slices linked against distinct single-arch thin shared libraries.Such thin shared libraries will fail the current strict architecture validation, either by virtue of being single-arch (whereas the target architecture is
universal2
) or by virtue of at least one single-arch thin shared library being of incompatible architecture (e.g.,arm64
thin shared library will be flagged as incompatible forx86_64
target, andx86_64
thin shared library will be flagged as incompatible forarm64
target).Therefore, limit the architecture validation only to python extension modules, which do need to be fully compatible with the target arch (at least until someone decides to ship distinct, arch-specific modules. But if that does happen, we can probably prevent the collection of incompatible module via hooks). The extension validation should hopefully still catch the attempts at using incompatible single-arch packages when trying to build a
universal2
application or a single-arch application for architecture that's different from the running one.