pyerfa builds for x86 on Arm64 Mac with Python 3.10, but not for 3.9 and 3.8
mgiammar opened this issue · comments
I am building a library which uses Astropy, and therefore pyerfa, and attempting to build wheel files for M1 Mac on Python 3.8, 3.9 and 3.10. Python versions 3.8 and 3.9 build just fine, but for Python 3.10 I get the following error
../../Environments/py310/lib/python3.10/site-packages/astropy/utils/exceptions.py:11: in <module>
from erfa import ErfaError, ErfaWarning # noqa
../../Environments/py310/lib/python3.10/site-packages/erfa/__init__.py:5: in <module>
from .version import version as __version__ # noqa
../../Environments/py310/lib/python3.10/site-packages/erfa/version.py:25: in <module>
from . import ufunc
E ImportError: dlopen(/Users/mgiammar/Environments/py310/lib/python3.10/site-packages/erfa/ufunc.cpython-310-darwin.so, 0x0002): tried: '/Users/mgiammar/Environments/py310/lib/python3.10/site-packages/erfa/ufunc.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I've confirmed my terminal is using the Arm64 architecture and all my Python executables (3.8, 3.9, 3.10) are for arm64 via running
>>> import platform; print(platform.platform())
macOS-12.3-arm64-arm-64bit
The version of pyerfa installed when the error is thrown is 2.0.0.1, confirmed by
(py310) user@computer ~ % pip show pyerfa
Name: pyerfa
Version: 2.0.0.1
Summary: Python bindings for ERFA
Home-page: https://github.com/liberfa/pyerfa
Author: The PyERFA Developers
Author-email:
License: BSD 3-Clause License
Location: /Users/mgiammar/Environments/py310/lib/python3.10/site-packages
Requires: numpy
Required-by: astropy
Installing pyerfa 2.0.0 no longer causes the incompatible architecture error on import and pyerfa seems to be installed correctly for my arm64 M1 Mac. I suspect something in the build pipelines may have inadvertently changed when comparing v2.0.0 to v2.0.0.1 (see azure-pipelines.yml)
Although this bug doesn't adversely affect me or other users, it still would be useful to have fixed eventually. Let me know if I can be of any help while trying to address this issue.
@mgiammar thanks for reporting.
How pyerfa is installed? Are you installing from sources or just using something like pip
or conda
?
I think that we do not have builds for arm64 M1 Mac at the moment.
@avalentino It's installed via pip. Maybe one of the Linux versions is working for arm64 Mac M1, but I'm really not sure. Again, this isn't a pressing issue because I can use version 2.0.0.0 without any issue. Hope this helps!
I am running into similar problems with poliastro (which depends on astropy, which depends on pyerfa). Pyerfa is installed via pip as a dependency. Any update on providing arm64 M1 Mac builds on pypi?
PR #88 has been merged, so in principle we should have M1 Mac wheels (not universal wheels) for the next release (not planned at the moment).
For further information, I can confirm there is some nuanced detail about which pyerfa version can be installed from which source (i.e. cloned repo installed locally vs. pip installing from pypi) with which python on Mac M1 (Arm64).
I have two conda environments, one is 3.9 and the other is 3.10. Depending on which version of pyerfa I install from which source, I get the same error as @mgiammar; i.e. (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Here are the processes that worked to avoid this error:
- Python 3.9: clone pyerfa locally, checkout v2.0.0.1, and install from source
conda activate py39_env
git clone --recursive https://github.com/liberfa/pyerfa/
cd pyerfa
git fetch origin
git checkout v2.0.0.1
pip install .
- Python 3.10: install v2.0.0 from pypi
conda activate py310_env
pip install pyerfa==2.0.0
Sorry, I understand that it could be a problem the fact the we currently do not have wheels for arm based Mac, but please note that conda packages for that architecture are available on the conda-forge channel.
For this reason, if you use conda environments, I would recommend you to also use conda packages for pyerfa.
Do I miss something?
We're distributing a tool for macOS that installs supporting packages at run time via pip. We'd love to include some pacakges that need pyerfa, but we can't right now because of the missing ARM wheel. Is there anything we could do to help to get a new release out with the ARM wheel available?
I have a MacBook pro with M1 MAX and came across the same problem. I had python 3.9 installed, but I upgraded to python 3.11.1 and everything worked fine.
Thanks for all the comments here. It doesn't seem there is anything that we could improve the situation, but it also seems clear it is becoming less of a problem since things work for recent versions of python. So, I'm closing this issue - feel free to reopen if there is something actionable...