-
Notifications
You must be signed in to change notification settings - Fork 239
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
BLD: issues while making macosx_arm64 natively on cirrus-ci (scipy) #1278
Comments
After trying lots of CI debugging I decided to try and build the package on cirrus-ci outside of cibuildwheel, using the Python@3.9 installed by homebrew. https://cirrus-ci.com/task/5623569559322624 This leads me to believe something is broken in the way cibuildwheel sets up its Python environment for Python 3.8/3.9. |
I've found the smoking gun. In this run I use
in the
The Python that cibuildwheel is installing to do the build is reporting |
Over on scipy/scipy#17077 (where I also asked this question) @rgommers pointed out that the official Python 3.8 installer doesn't have arm64 support. So perhaps it's not possible to build arm64 wheels on 3.8 using cibuildwheel? |
If I correctly remember it is possible by cross compilation but it is not possible to test it in test phase. |
If it's only possible to build on 3.8 by cross-compilation, then this should be outlined in the documentation somewhere because the are probably a lot of projects that require a bunch of extra stuff for cross-compilation. e.g. scipy requires a gfortran cross compiler. (Please forgive me if it is in the documentation, I didn't see it.) |
If I'm reading the linked issue right, it seems that this problem is localised to CPython 3.8? In a way, I'm not surprised. The universal2/arm64 support in that installer has always been janky from my perspective. I think that CPython 3.8 always runs in Rosetta. So that's why your numpy download is wrong. At least, we should probably warn when users are building 3.8 on an arm64 host. I'm actually leaning towards removing that from cibuildwheel, as we get a lot of bug reports about it and I don't think many people will be consuming those wheels. I might look at PyPI download stats to see what the numbers really are. |
I think a clear error for a naive 3.8 arm64 build is preferred over what cibuildwheel is doing currently. That said, projects probably cannot drop 3.8 arm64 wheels before they drop 3.8 completely. Otherwise 3.8 users are going to get from-source builds, which are going to fail a lot. So if the docs could be updated to point to the cross-compiling method, that'd be great. |
If I correctly read log there is also problem for python 3.9? |
The last message on the issue says that that was fine, and checking this log file shows:
|
I think it is localised to 3.8. However, there's several errors that are clouding things, so I'm trying to work through those first. If it is localised to 3.8 I'll close this issue. |
It's localised to 3.8, not present for 3.9. |
This was tricky to add, but it was extremely important - 3.8 was the default version of Python on macOS 11! So anyone using the system Python on macOS 11 needs 3.8 ARM wheels. It might not / probably won't work on an ARM runner, though, since the official support was adding the ability to cross compile from Intel, and I don't think there ever was an ARM runner. You can use Apple's custom macOS 11 copy, of course, but that will be OS dependent - macOS 12 has 3.9. |
Now that CirrusCI is a thing (it offers free arm64 runners for open source projects), that will likely quickly get popular. Can this issue be reopened? There are two things to do here:
|
I believe you can technically build on ARM, you just can't install non pure Python dependencies on ARM while building? (In other words, you can't run Python, since that will be Intel not ARM). |
If that's true, I'd say we should raise an error unless the tests are explicitly skipped. That would make this a clear opt-in. |
When I try to build scipy using a naive cibuildwheel call on cirrus-ci for a target of I think in order to make them all the correct architecture I'll probably have to specify a cross-file for meson (the build backend). I was hoping to get away with not doing that because it'll involve more fiddling. Given that I can already build |
Thanks for the reminder, I had forgotten this. Indeed PyPI download stats do confirm that it's used pretty regularly: |
One thing you can try if you want to natively build This installer was marked as experimental but recommended for Apple Silicon. cibuildwheel always use the Intel installer, even on AppleSilicon, because the universal2 installer restricted building wheels for macOS 11+ only whereas the Intel installer can be used for macOS 10.9+. It could be an issue when building x86_64 or universal2 wheels on an AppleSilicon machine but in your case, when only targeting an arm64 build, it's not. However, even if you get the native build to pass, you won't be able to get cibuildwheel to run the tests for |
I was thinking we could improve this, so here are my thoughts:
Given the above, the ideal situation would be for the AS on AS to use the AS installer, and for U2 on AS to pick one of the two (the current Intel is probably the better default), but have some emergency back-door to allow using the AS. (The 11+ limit would make U2 wheels pretty useless IMO - so this back-door is a very low priority). A much better way to build U2 wheels would be to fuze Intel (10.9) + AS (11) wheels anyway. It would be nice if we had better support or docs for doing that. :) Testing on AS should probably always use the U2 installer - you are on 11+ anyway. Also, for implementing a solution, an important thing to note is this is temporary. Once we drop 3.8 support, this will all go away. The URLs here should never change - new binary packages are not being released. So a solution could be hardcoded, and introducing new complexity in the url listing or new configuration options is not ideal. The problem is that you can't install both (AFAICT), and you can run multiple identifiers at any time (AS + U2, for example), or target different macOS versions via overrides, etc. So trying to figure this out and do the right thing without user input is trickier than I thought. Ideally, building AS on AS would replace the Intel installer with a U2 one. Targeting 11+ could even replace the U2 one as well. I think we could start by checking to see if the resolved macOS archetectures includes U2. If not, then we replace the Intel URL with the U2 URL. This would address point 1 above. If we wanted to, we could provide a backdoor envvar or maybe even full config setting to allow the same replacement even if U2 is included (with the caveat being targeting macOS 11+ is required, which maybe we could even check, or include in the envvar name) - but this is lower priority and a followup if requested, I think. If you ran cibuildwheel twice, this would cause issues in the same run, but they are the same issues you'd get if you pre-install Python, so don't think that's too bad. But that's one reason I'm writing this before trying (very hard) to implement anything. :) |
It would be ideal if there was a separate tool for this. It could then be used inside |
Thanks for the analysis @henryiii
This would be a good minimum. Though it's worth noting that functionally, as a workaround it's no different than the user manually curl'ing and installing the u2 pkg manually. Though I suppose it would become an officially supported mode of operation.
If we're going to the trouble of adding a feature, do we know if installing the u2 pkg over a x86_64 installation would work? I know from experience that you can upgrade Python that way. Globally installed packages with native code might break but I don't think we install anything besides pip (and perhaps virtualenv?). If that does, we can have an option |
I'm getting the same error here, Upgrading to cp39-macos-arm64 fixed it. |
Commenting on this issue to notify that I am receiving a slightly similar problem too, of sorts, with using Outside of and without on a macOS M1 runner, with
|
I am hitting this too where I wonder if this can be fixed by changing
|
I think because Python 3.8 never provided an architecture-specific arm64 installer (https://www.python.org/downloads/release/python-3810/), something seems to be off on that regard from /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import platform;print(platform.python_version());print(platform.system());print(platform.machine())' to receive
which should be correct, so using this to run To provide an example for the above, https://github.com/indygreg/python-build-standalone/releases/tag/20240224 (unofficial releases) could be quite useful. However, I don't know if they are supposed to be used in CI and especially to build wheels to publish to PyPI, because there is a bit of nuance in setting |
@larsoner, thanks for the info. However numpy and scipy now have minimum python versions of 3.10 in main, so this issue isn't a concern for those projects any more. |
Description
I'm trying to build scipy wheels for
macosx_arm64
natively on cirrus-ci (in anticipation of scipy/scipy#17029, linux_aarch64 being merged). The work is being done in andyfaff/scipy#33.Two matrix entries are for cp38 and cp39, see the build log here. For each of the builds meson thinks its doing a native build for x86_64, even though the CI is an arm64 machine:
The cibuildwheel infrastructure thinks the build machine is arm64:
Prior to the cibuildwheel step I also query the machine (with a different Python interpreter installed using brew):
At the start of the build process (before meson runs) pip is trying to install numpy-1.19.5-cp38-cp38-macosx_10_9_x86_64.whl. This leads me to think there is something fishy going on with cibuildwheel/python setup/pip (that then causes the meson issue). Why would pip be trying to install an x86_64 wheel onto an arm64 machine?
pip gives the following output whilst considering pyproject.toml:
Given that ostensibly the python version installed by cibuildwheel is
3.8.10
, the machine should bearm64
, and the platform should be Darwin, I don't know why the specific numpy requirement (1.21.0) isn't being obeyed.I should note that in other matrix entry I build for 3.10 and 3.11. There the correct numpy for machine is installed, i.e.
macosx_arm64
.Build log
https://api.cirrus-ci.com/v1/task/4544934911934464/logs/cibuildwheel.log
CI config
https://github.com/andyfaff/scipy/blob/cirrus2/.cirrus.yml
The text was updated successfully, but these errors were encountered: