Skip to content
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

Wrong dependencies resolving for SQLAlchemy[postgresql_asyncpg] #5429

Closed
3 tasks done
evgen231 opened this issue Apr 8, 2022 · 14 comments · Fixed by #7175
Closed
3 tasks done

Wrong dependencies resolving for SQLAlchemy[postgresql_asyncpg] #5429

evgen231 opened this issue Apr 8, 2022 · 14 comments · Fixed by #7175
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@evgen231
Copy link

evgen231 commented Apr 8, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

After installing SQLAlchemy with postgresql_asyncpg extra there is no greenlet dependency.

# poetry update
Creating virtualenv example-OWA4dUH3-py3.9 in /Users/.../Library/Caches/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing asyncpg (0.25.0)
  • Installing sqlalchemy (1.4.35)
# poetry run pip freeze
asyncpg @ .../asyncpg-0.25.0.tar.gz
SQLAlchemy @ .../SQLAlchemy-1.4.35.tar.gz

Using pip:

# python -m pip install 'sqlalchemy[postgresql_asyncpg]'
...
# python -m pip freeze
asyncpg==0.25.0
greenlet==1.1.2
SQLAlchemy==1.4.35
@evgen231 evgen231 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 8, 2022
@evgen231
Copy link
Author

evgen231 commented Apr 8, 2022

Same thing with poetry 1.2.0b1.

@finswimmer
Copy link
Member

Hey @evgen231,

sqlalchemy has this marker for greenlet:

greenlet != 0.4.17;python_version>='3' and (platform_machine=='aarch64' or (platform_machine=='ppc64le' or (platform_machine=='x86_64' or (platform_machine=='amd64' or (platform_machine=='AMD64' or (platform_machine=='win32' or platform_machine=='WIN32'))))))

So my guess is, that your platform is not included here and it is intended that greenlet should not be installed.

fin swimmer

@evgen231
Copy link
Author

evgen231 commented Apr 8, 2022

But pip does. So it's a bug in the pip and SQLAlchemy dependencies?

@dimbleby
Copy link
Contributor

sqlalchemy[postgresql_asyncpg] has an unconditional dependency on greenlet, so it's a poetry bug.

@dimbleby
Copy link
Contributor

cf sqlalchemy/sqlalchemy#7714

@lebovic
Copy link

lebovic commented Aug 9, 2022

I'm seeing the same with sqlalchemy[asyncio], which also includes greenlet (PrefectHQ/prefect#6310).

The poetry.lock includes:

[[package]]
name = "sqlalchemy"

[package.dependencies]
greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"}

[package.extras]
asyncio = ["greenlet (!=0.4.17)"]

poetry show lists greenlet as a dependency:

❯ poetry show sqlalchemy
name         : sqlalchemy
version      : 1.4.40
description  : Database Abstraction Library

dependencies
 - greenlet !=0.4.17

Within a Poetry shell for the environment above, pip does not show the dependency:

❯ pip show sqlalchemy
Name: SQLAlchemy
Version: 1.4.40
Summary: Database Abstraction Library
Home-page: https://www.sqlalchemy.org
Author: Mike Bayer
Author-email: [email protected]
License: MIT
Location: /Users/lebovic/Library/Caches/pypoetry/virtualenvs/test-project-GQM6Mw9q-py3.8/lib/python3.8/site-packages
Requires: 
Required-by: alembic, prefect

But when installed with pip instead of Poetry (via sqlalchemy[asyncio]), the greenlet dependency is installed:

❯ pip show sqlalchemy
Name: SQLAlchemy
Version: 1.4.40
Summary: Database Abstraction Library
Home-page: https://www.sqlalchemy.org
Author: Mike Bayer
Author-email: [email protected]
License: MIT
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: greenlet
Required-by: alembic, prefect

@anentropic
Copy link

I have exact same problem with sqlalchemy[asyncio] and missing greenlet dependency, Poetry on M1

@neersighted
Copy link
Member

This is a currently unhandled edge case where an extra specifies an unconditional dependency that is excluded by 'base' markers.

sqlalchemy[asyncio] should be sufficient to work around this (or, manually specifying greenlet) until Poetry gains support.

@anentropic
Copy link

I already have sqlalchemy[asyncio] ... I see greenlet in the lock file as a dependency but it does not get installed - this is the part that's not working

but explicitly adding greenlet via poetry add greenlet does fix it for me

@neersighted
Copy link
Member

PTAL @radoering @dimbleby when you have time, to confirm if my diagnosis is correct or not.

@dimbleby
Copy link
Contributor

dimbleby commented Oct 2, 2022

I don't see anything much to agree or disagree with...

Per this comment I do believe that it's a bug. I've a half-memory of taking a closer look back then and deciding that it was likely to be painful. But I haven't tried again and, you never know, maybe it'll turn out to be easy.

@radoering
Copy link
Member

I'm quite sure that #7175 fixes this issue, but it wouldn't hurt if someone with a platform where the issue occurs could verify this.

@phillipuniverse
Copy link

@radoering issue does not appear to be resolved for me:

Poetry version: 1.6.1
Python version: 3.11.4
OS version and name: macOS Ventura 13.5.1

It is failing. ValueError: the greenlet library is required to use this function. No module named 'greenlet'

I have SQLALchemy specified like this in my pyproject.toml:

sqlalchemy = { version = "1.4.49", extras = ["postgresql_asyncpg"] }

I also tried with:

sqlalchemy = { version = "1.4.49", extras = ["asyncio"] }

Seems like this only works when I explicitly add greenlet as a dependency in pyproject.toml.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants