-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
sqlalchemy 1.4.x: re-optionalize 'greenlet' dependency #6136
Comments
hi - I agree it would be nice to not have greenlet as a required dependency, but then we would be flooded with bug reports of people eager to use asyncio and then confused why it doesnt work, or frustrated that it raises errors and that they need to run some separate step for it to work. What we can do instead is have greenlet only install if the Python environment is not a so-called "pure python" environment. Can you identify what this means exactly? |
The usual culprit here is alpine linux that's somewhat popular as a docker base image. That cannot use the |
That's precisely it in this case, yep.
Thanks! - that gives me something to search about to see whether I can track this down further (or think of workarounds). |
If you could find a way I think we could add it in the install requirements. As a side note, consider using |
Thank you - I also just discovered https://pythonspeed.com/articles/alpine-docker-python/ while reading about this, and it draws similar conclusions about increased build times (and image sizes!) |
It feels like |
I'm not sure if it's possible with the environment makers. Testing them all on python:3.9-alpine and python:3.9-slim I get pretty much equal results. Test stript: import os
import platform
import sys
print(os.name)
print(sys.platform)
print(platform.machine())
print(platform.python_implementation())
print(platform.release())
print(platform.system())
print(platform.version())
print('.'.join(platform.python_version_tuple()[:2]))
print(platform.python_version())
print(sys.implementation.name)
def format_full_version(info):
version = '{0.major}.{0.minor}.{0.micro}'.format(info)
kind = info.releaselevel
if kind != 'final':
version += kind[0] + str(info.serial)
return version
if hasattr(sys, 'implementation'):
implementation_version = format_full_version(sys.implementation.version)
else:
implementation_version = "0"
print(implementation_version) On
on
I'm not sure I tested them all. Maybe these is some other way of getting that info? |
Another part of the problem is that greenlet has very limited platform support. For example, it is known not to work at all on hppa or ia64 platforms. |
I wanted to make the test suite skip tests requiring greenlet when it's not installed but the complexity of wrappers used in the test suite is above my pay grade. |
this should work already if you run pytest directly. I'm able to run the test suite from a virtualenv that does not have greenlet installed. all greenlet tests are skipped as well. if this is not automatic then we need to see what's happening. in the tox file it looks like greenlet is a dependency, so we'd need to add a tox option or command of some kind. however for now, just do "pytest" and it should work |
It doesn't work — we get around a dozen test errors like the following: _____________________________________________ TestAsyncAdaptedQueue.test_error_other_loop _____________________________________________
Traceback (most recent call last):
File "/tmp/sqlalchemy/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py", line 772, in decorate
asyncio._run_coroutine_function(fn, *args, **kwargs)
File "/tmp/sqlalchemy/test/../lib/sqlalchemy/testing/asyncio.py", line 33, in _run_coroutine_function
return _util_async_run_coroutine_function(fn, *args, **kwargs)
File "/tmp/sqlalchemy/test/../lib/sqlalchemy/util/concurrency.py", line 59, in _util_async_run_coroutine_function
_not_implemented()
File "/tmp/sqlalchemy/test/../lib/sqlalchemy/util/concurrency.py", line 36, in _not_implemented
raise ValueError(
ValueError: the greenlet library is required to use this function. This seems to be directly caused by the |
im fixing those but can you define "greenlet doesnt work on hppa", meaning it doesnt install? or just doesnt work correctly ? this cant be done in the tox file very well unless i can get appropriate environment flags: https://www.python.org/dev/peps/pep-0496/ |
Mike Bayer referenced this issue: allow pytest to run if greenlet isnt installed https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2981 |
It doesn't install at all:
Overall, greenlet seems to rely on very ugly platform-specific hacks. |
OK we have to list unsupported platforms in tox.ini. what targets do you need excluded? e.g. uname value or:
|
if you try out the patch at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2981 pytest should run completely, or let me know. working on "tox" |
On our testing hppa machine, I get:
though I suspect it might depend on the actual CPU. On ia64 it's predictably That said, I'm only the messenger here, I don't do hppa/ia64 myself. But I can test on amd64 without greenlet installed. |
The patch seems to resolve the test failure I've referenced above. However, there are more failing tests due to missing greenlet:
|
so the solution I'm going to put up will be based on the platform_machine limiter. Right now the exclude list will be: "platform_machine not in 'ia64 hppa parisc'" however we can add as many architectures as we want here. |
Mike Bayer has proposed a fix for this issue in the master branch: allow pytest to run if greenlet isnt installed https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2981 |
this will be merged soon and the current platform exclusion list is:
there's likely a lot more we can add here i will ask greenlet devs if there's a better way to get this. |
Mike Bayer has proposed a fix for this issue in the master branch: limit greenlet dependency against non-supported platforms https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2981 |
OK, change. new idea, i will make supported platforms default to that which we see already have a binary at https://pypi.org/project/greenlet/#files . anyone else wants asyncio they have to specify the |
Thank you @zzzeek! |
Hi @zzzeek, I would like to report a compatibility issue with poetry Error when installing sqlalchemy 1.4.23 via poetry:
Reproduce steps:
Based on the error message, my guess is that poetry is not able to handle |
the syntax here is part of https://www.python.org/dev/peps/pep-0508/ so please report that to poetry. |
they have an issue opened at python-poetry/poetry#4398. |
it's more or less a requirement for asyncio, cf https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#asynchronous-io-support-for-core-and-orm its been debated to make it optional in sqlalchemy/sqlalchemy#6136 but my experience with buildbot was that the daemon didnt start at all if greenlet was not present, and setup.cfg adds the requirement.
with asyncio now well established we will consider this for 2.1 in #10197 |
This is a reopen of #6136 essentially that repaired the test suite to run without greenlet but now this has regressed. add a tox target that explicitly uninstalls greenlet, will add to CI. This also changes 2.0 in that the full tox target will omit dbdrivers that require greenlet. Fixes: #10747 Change-Id: Ia7d786d781e591539a388bfbe17b00a59f0e86d9
This is a reopen of #6136 essentially that repaired the test suite to run without greenlet but now this has regressed. add a tox target that explicitly uninstalls greenlet, will add to CI. This also changes 2.0 in that the full tox target will omit dbdrivers that require greenlet. Fixes: #10747 Change-Id: Ia7d786d781e591539a388bfbe17b00a59f0e86d9 (cherry picked from commit 0bd686df43f572cec658c586082f299ab2cd756f)
Is your feature request related to a problem? Please describe.
The
greenlet
dependency was restored to the defaultsqlalchemy
package dependencies in 1.4, and that's understandable since many users will want and benefit from the async functionality provided bygreenlet
without having to specifyextras
(specificallyasyncio
) in their requirements files.That said it does make it challenging (impossible?) to use
sqlalchemy
in pure-python deployment environments currently. If no binary package ofgreenlet
nor a compiler toolchain forgreenlet
to build with are available at install-time, thensqlalchemy
package installation will fail.Describe the solution you'd like
Suggestions from people more familiar with the Python packaging ecosystem than I am would be appreciated :)
The text was updated successfully, but these errors were encountered: