black: Packaging bug causes an x86_64 regex to be installed on an Apple Silicon (M1) device
Hello everyone!
We’ve been made aware that the M1 wheel for regex 2021.10.8 seems to be non-functional. Pinning regex to 2021.9.30 should work for the time being. There’s also a very recent release of regex that may fix the issue, but it hasn’t been confirmed.
~ originally @pradyunsg, reposted by @ichard26 (9AM EST, 21 October, 2021)
Describe the bug
black panics on Apple Silicon
Traceback (most recent call last):
File "/opt/homebrew/bin/black", line 5, in <module>
from black import patched_main
File "/opt/homebrew/lib/python3.8/site-packages/black/__init__.py", line 13, in <module>
import regex as re
File "/opt/homebrew/lib/python3.8/site-packages/regex/__init__.py", line 1, in <module>
from .regex import *
File "/opt/homebrew/lib/python3.8/site-packages/regex/regex.py", line 419, in <module>
import regex._regex_core as _regex_core
File "/opt/homebrew/lib/python3.8/site-packages/regex/_regex_core.py", line 21, in <module>
import regex._regex as _regex
ImportError: dlopen(/opt/homebrew/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so, 2): no suitable image found. Did find
:
/opt/homebrew/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so: mach-o, but wrong architecture
/opt/homebrew/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so: mach-o, but wrong architecture
To Reproduce
$ black --version
Expected behavior
See version
Environment (please complete the following information):
- Version: I cannot find the version info coz this issue.
- OS and Python version:
OS:
$ uname -prsv
Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101 arm
Python:
- Python 3.8.12
- Python 3.9.7
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 15 (3 by maintainers)
It seems to me that the issue is that regex has uploaded an
arm64wheel, that’s actually not functional. 😦Using
regex == 2021.9.30works and that’s probably a reasonable stopgap solution for users.For anyone using the black pre-commit hook, here’s a workaround
try with
regex==2021.10.21Can confirm my initial report is fixed.
I’ve stated this on multiple other issues, black supports and works in aarch64 / M1 environments. Black is native python, but here you have installed a non aarch64 mach-o compiled regex .so. Regex is a C dependency, so is compiled and you’ve somehow got the wrong architecture compiled binary. The error clearly states that via “but wrong architecture”.
How did you get to this? Is this an issue with homebrew? Did you manually copy things from a non M1 Mac? I think we need to workout how you ended up here to see if we can fix a packaging bug somewhere.
Get an aarch64 build of regex (https://pypi.org/project/regex/) into your python environment and you’ll work. Latest pip will do this correctly. Maybe use a venv:
(
--upgrade-depsis >= 3.9 - It ensures latest setuptools + pip)Probably related … https://bitbucket.org/mrabarnett/mrab-regex/issues/399/missing-wheel-for-macosx-and-the-new-m1