-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add universal2 builds of Python to actions/setup-python #4133
Comments
Hi @bwoodsend!
We can't do anything with the one from brew but we can probably try to re-build the pre-cached one with the arm64 support. Unfortunately, it may take some time so if you have a chance you can submit a PR to the python-version repo modifying the macos-python-builder script https://github.com/actions/python-versions/blob/main/builders/macos-python-builder.psm1 |
OK, I'll do a PR for option 2. The python-versions source code looks a lot less intimidating than I expected so this shouldn't be too hard. Do you have any thoughts on whether all Python versions that are capable of |
What is the difference in size? If it's just a few megabytes then we should be good to go with the universal by default |
We would avoid adding additional parameters on actions/setup-python side so rebuilding existing binaries with universal2 support is more preferable. Of course, in case if it is not a breaking changes |
They're effectively two copies in one so the binaries about double the size of a single arch Python. But they compress down well when you archive them.
|
I've opened actions/python-versions#114 which assumes universal2 by default. |
Just as an FYI I use The documentation for |
Apparently there is zero support for |
Hmm, I don't blame GitHub for lack of support for anything Apple's Despite being the one to raise this issue in the first place and having submitted a PR to address it, I'm rather leaning towards recommending that GitHub rejects it mostly due to it encouraging developers to release untested binaries but also because it only partially solves the problem of building - plenty of C/C++ projects aren't cross compile friendly, and you've still got to encourage every one of your non pure Python dependencies to do likewise. |
Let me put it in a different angle: there is not arm64 platform even for linux inside the versions-manifest.json either. I recently reproduced https://marcin.juszkiewicz.com.pl/2022/05/06/installed-top5000-python-packages-on-aarch64/ tests on M1 and discovered 4711/5000 did build and install and many of those failures were only caused by missing header files, so the situation on I am inclined to believe that enabled universal would be less maintenance than keeping separated aarm64 versions. It does not need a lot of time to realise how brilliant are the universal binaries when you look at how the things are working on Windows side. Just one example from today experience where Windows support asked me use sysinternals procdump. The archive contained 3 executables, none of them for current architecture as I happened to be on Windows 11 ARM. I had to google to find another archive with some ports of systernals for ARM which contained two executables for procdump. Basically for one utility 5 executables. And in the end, none of them worked, but that is another story. I mentioned this only to raise awareness about costs of diverging. We clearly know what is the future on MacOS, so trying to avoid universal2 build, seems only a waste of time to me. I personally doubt there are many python developers that would not want to produce universal2 wheels when running on macos. Lack of support from |
What would you do with it if there was? The only reason you should ever need to use aarch64 Linux is to build/test for that platform and to do that safely you need to run in minimal environment with carefully controlled old versions of glibc and core system libraries or downstream users will . Since the easiest way to do that is via Docker and a controlled docker container is unlikely to be able to run a Python environment compiled from the latest Ubuntu images on GitHub Action, you'd never actually use the Python environment provided by
So the solution for Windows is a single >5 slice fat executable? And Linux, which supports literally 100s of architectures, should use fat binaries with 100s of slices despite having thrived quite successfully using virtualisation instead of cross compiling or fat binaries?
You'll have to fight me on that one. I'd say that any developer who values not doubling their file sizes and the time it takes for gatekeeper to verify that engorged binary, the simplicity of knowing that build platform == runtime platform and the knowledge that the test suite has been ran on every supported platform will turn their nose up at fat binaries given a viable alternative. That post you link only shows that most packages build OK but certainly doesn't show that they actually work. |
Considering actions/python-versions#114 changes got reverted, I guess this issue should be re-opened? |
actions/python-versions#175 reverted the change for this issue. Is there a way to have a universal2 Python version in the GHA image? Otherwise I think this should be reopened. The reasons stated in the original issue are still valid today. |
@albertosottile I am also curious about this because that revert was bit weird, with an army of reviewers approving it but the explanation was extremely vague "breaking changes for some customers". No mention of those customers and the nature of the breakage. On the bright side, it was mentioned as "temporary", even if there was no timeline regarding when it would be restored. As Clearly this ticket should have being reopened when the revert was made. |
Should we create a new issue? I am afraid we will not get much visibility here... |
@vsafonkin Can you please reopen this issue because it was undone? |
@albertosottile, Please create a new issue for visibility in actions/setup-python repo |
@al-cheb I wanted to create a new issue, but then I found this actions/setup-python#271. Should I still create essentially a duplicate? |
Not a maintainer but I'd say go for it. Strictly speaking actions/setup-python#271 should have been closed at the same time this was closed. |
Hi, @bwoodsend, @ssbarnea, @albertosottile 👋 |
@IvanZosimov A big thank you! When I will visit Belgrade again, I will ping you to have a beer! |
In theory this workflow should generate binaries for Windows, macOS and Linux. The universal2 target for macOS might not work with Python 3.9 See: - actions/runner-images#4133 (comment) - pyinstaller/pyinstaller#5315 (comment)
What's a way to prevent I've tried I've written about this problem much more extensively here, including different solutions which were attempted which I will post here:
What to do? |
Tool name
universal2 builds of Python for macOS
Tool license
Python software foundation
Add or update?
Desired version
latest (3.9.6)
Approximate size
40MB in .pkg form. 150MB installed
Brief description of tool
As you're probably aware, Apple are transitioning from
x86_64
toarm64
. Whilstx86_64
machines are still around, Apple are encouraging software authors to ship universal2 applications which are executables for bothx86_64
andarm64
glued together into one file and the OS is able to select the right half of the executable to run at runtime. The latest versions of Python on https://python.org/downloads now have amacOS 64-bit universal2 installer
download option.Given that the CI/CD servers are all
x86_64
, you're probably wondering why any of the above matters. Well... Python package authors are now also required to build their C extensions for macOS universal2 too. On the plus side, Python does this all automatically if the Python installation itself is compiled universal2. On the down side, there is no other way to build universal2 Python packages.So long story short, without trying to do some
wget https://www.python.org/ftp/python/3.9.6/python-3.9.6-macos11.pkg; sudo installer -pkg python-3.9.6-macos11.pkg -target /
scariness to install Python directly from python.org, it is impossible to build Python packages from macOS arm64 on Github Actions.One thing to note, building universal2 Pythons does not require access to
arm64
machines - rather they can be cross compiled provided you have XCode >= 12.2 installed.URL for tool's homepage
No response
Provide a basic test case to validate the tool's functionality.
Virtual environments affected
Can this tool be installed during the build?
No response
Tool installation time in runtime
No response
Are you willing to submit a PR?
I can try...
The text was updated successfully, but these errors were encountered: