sqlalchemy: greenlet is not installed on Apple M1
Describe the bug
When installing SQLAlchemy 1.4.x with the asyncio extra on a Apple M1 machine the greenlet package is not installed even if it’s listed in the requirements and for aarch64 architectures.
To Reproduce
# On a Apple M1, inside a Docker container running Python in a linux distro
$ docker run --rm -it python:3.10 /bin/bash
root@afbf52f73731:/# pip install sqlalchemy==1.4.31
root@afbf52f73731:/# pip list | grep greenlet
greenlet 1.1.2
# On a Apple M1, in the local environment
$ pip install sqlalchemy==1.4.31
$ pip list | grep greenlet
# no output
Error
.venv/lib/python3.10/site-packages/alembic/command.py:320: in upgrade
script.run_env()
.venv/lib/python3.10/site-packages/alembic/script/base.py:563: in run_env
util.load_python_file(self.dir, "env.py")
.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py:92: in load_python_file
module = load_module_py(module_id, path)
.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py:108: in load_module_py
spec.loader.exec_module(module) # type: ignore
migrations/env.py:86: in <module>
asyncio.run(run_migrations_online())
../../../.pyenv/versions/3.10.2/lib/python3.10/asyncio/runners.py:44: in run
return loop.run_until_complete(main)
../../../.pyenv/versions/3.10.2/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
return future.result()
migrations/env.py:71: in run_migrations_online
engine_from_config(
.venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py:755: in engine_from_config
return create_engine(url, **options)
.venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:309: in warned
return fn(*args, **kwargs)
.venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py:672: in create_engine
event.listen(pool, "connect", on_connect)
.venv/lib/python3.10/site-packages/sqlalchemy/event/api.py:115: in listen
_event_key(target, identifier, fn).listen(*args, **kw)
.venv/lib/python3.10/site-packages/sqlalchemy/event/registry.py:232: in listen
self.dispatch_target.dispatch._listen(self, *args, **kw)
.venv/lib/python3.10/site-packages/sqlalchemy/pool/events.py:63: in _listen
event_key.base_listen(**kw)
.venv/lib/python3.10/site-packages/sqlalchemy/event/registry.py:270: in base_listen
for_modify._set_asyncio()
.venv/lib/python3.10/site-packages/sqlalchemy/event/attr.py:274: in _set_asyncio
self._exec_once_mutex = AsyncAdaptedLock()
.venv/lib/python3.10/site-packages/sqlalchemy/util/concurrency.py:67: in AsyncAdaptedLock
_not_implemented()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _not_implemented():
# this conditional is to prevent pylance from considering
# greenlet_spawn() etc as "no return" and dimming out code below it
if have_greenlet:
return None
if not compat.py3k:
raise ValueError("Cannot use this function in py2.")
else:
> raise ValueError(
"the greenlet library is required to use this function."
" %s" % greenlet_error
if greenlet_error
else ""
)
E ValueError: the greenlet library is required to use this function. No module named 'greenlet'
.venv/lib/python3.10/site-packages/sqlalchemy/util/concurrency.py:47: ValueError
Versions
- OS: OS X 12.2
- Python: 3.10
- SQLAlchemy: 1.4.31
- Database: not applicable
- DBAPI not applicable
Additional context
The issue seems related to the way platform.machine() reports the underlying architecture, on Linux it reports aarch64 and on OS X reports arm64, but the requirements contains only aarch64 for greenlet https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4_31/setup.cfg#L44
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 17 (12 by maintainers)
Commits related to this issue
- Add arm64 to the list of supported architectures. Fixes: #7714 — committed to expobrain/sqlalchemy by expobrain 5 years ago
- explicitly refer to Apple M1 for greenlet issue As developers are now buying lots of Apple M1 machines, and AFAWK greenlet is still not able to provide a pre-built wheel, we are going to get a lot of... — committed to sqlalchemy/sqlalchemy by zzzeek 5 years ago
- explicitly refer to Apple M1 for greenlet issue As developers are now buying lots of Apple M1 machines, and AFAWK greenlet is still not able to provide a pre-built wheel, we are going to get a lot of... — committed to sqlalchemy/sqlalchemy by zzzeek 5 years ago
- Require sqlalchemy[asyncio] This forces installation of greenlet on arm64 machines (Mac OS X on Apple silicon) allowing 'tiled serve directory ...' to build a catalog when run See https://github... — committed to padraic-shafer/tiled by padraic-shafer 3 years ago
- Require sqlalchemy[asyncio] (#550) This forces installation of greenlet on arm64 machines (Mac OS X on Apple silicon) allowing 'tiled serve directory ...' to build a catalog when run See htt... — committed to bluesky/tiled by padraic-shafer 3 years ago
- ci: make local docker build work uninstall repository-cli which is incompatible in some way, dependency conflict install greenlet which is an extra for sqlalchemy that doesn't get installed see https... — committed to cca/cca_invenio by phette23 3 years ago
@CaselIT that’s a nice solution, but works only with Pip and not on Poetry (and of course we use Poetry in our projects 😃 )
OK, there’s an arm64 wheel format, such as seen here: https://pypi.org/project/numpy/#files
numpy-1.22.2-cp310-cp310-macosx_11_0_arm64.whl. greenlet does not publish arm64 right now on pypi. This is the criteria that we use to determine what goes in those requirements; that there’s a wheel already available for greenlet. So for the moment we would not add arm64 to this list until greenlet supplies a build.@CaselIT I mean, it does and this is the resulting entry in
pyproject.toml:However in the
poetry.lockit adds this line (which I reckon is coming from SQLAlchemy’ssetup.cfg):which prevents
greenletto be installed.How nice of python to be consistent…
Thanks for reporting.
As a workaround you can install
sqlalchemy[asyncio]that marks greenlet as required without conditions