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

Set max pymongo version #1027

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Set max pymongo version #1027

wants to merge 2 commits into from

Conversation

kewldan
Copy link

@kewldan kewldan commented Sep 18, 2024

Temporary solution:

A new version of pymongo has been released. Beanie doesn't support it yet. When installing motor, the new version 4.9 will be picked up. There will be an ImportError when running the application:

Traceback (most recent call last):
  File "/usr/app/src/main.py", line 1, in <module>
    from beanie import init_beanie
  File "/usr/local/lib/python3.12/site-packages/beanie/__init__.py", line 1, in <module>
    from beanie.migrations.controllers.free_fall import free_fall_migration
  File "/usr/local/lib/python3.12/site-packages/beanie/migrations/controllers/free_fall.py", line 4, in <module>
    from beanie.migrations.controllers.base import BaseMigrationController
  File "/usr/local/lib/python3.12/site-packages/beanie/migrations/controllers/base.py", line 4, in <module>
    from beanie.odm.documents import Document
  File "/usr/local/lib/python3.12/site-packages/beanie/odm/documents.py", line 69, in <module>
    from beanie.odm.interfaces.aggregate import AggregateInterface
  File "/usr/local/lib/python3.12/site-packages/beanie/odm/interfaces/aggregate.py", line 7, in <module>
    from beanie.odm.queries.aggregation import AggregationQuery
  File "/usr/local/lib/python3.12/site-packages/beanie/odm/queries/aggregation.py", line 12, in <module>
    from motor.core import AgnosticCommandCursor
  File "/usr/local/lib/python3.12/site-packages/motor/core.py", line 30, in <module>
    from pymongo.cursor import _QUERY_OPTIONS, Cursor, RawBatchCursor
ImportError: cannot import name '_QUERY_OPTIONS' from 'pymongo.cursor' (/usr/local/lib/python3.12/site-packages/pymongo/cursor.py)

What I did:
Wrote pymongo<4.9 as a library dependency in pyproject.toml

Copy link
Contributor

@adeelsohailahmed adeelsohailahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks!

Copy link
Member

@07pepa 07pepa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pymongo 4.9.1 seems to work can you try pymongo!=4.9 ?

@kewldan
Copy link
Author

kewldan commented Sep 19, 2024

No, motor 3.5.1 doesnt support 4.9.1. BUT motor has released a 3.6.0 which added a support for pymongo 4.9. So problem is solved. Upgrade your motor library to 3.6.0

@adeelsohailahmed
Copy link
Contributor

adeelsohailahmed commented Sep 19, 2024

No, motor 3.5.1 doesnt support 4.9.1. BUT motor has released a 3.6.0 which added a support for pymongo 4.9. So problem is solved. Upgrade your motor library to 3.6.0

Should we pin the motor to 3.6.0 then? I'm fine with either/or.

@kewldan
Copy link
Author

kewldan commented Sep 20, 2024

No, motor 3.5.1 doesnt support 4.9.1. BUT motor has released a 3.6.0 which added a support for pymongo 4.9. So problem is solved. Upgrade your motor library to 3.6.0

Should we pin the motor to 3.6.0 then? I'm fine with either/or.

Good question, it seems to me that yes, you should also specify pymongo~=4.9.1 since such mishaps happen. I would still mark all current used versions as supported, so that a developer who uses beanie can be sure that these dependency versions will work correctly. I'll make the changes now

@kewldan
Copy link
Author

kewldan commented Sep 20, 2024

Interesting situation, motor latest version supports Python >= 3.8. Although support for Python 3.8 will end in 10 days (full, even security updates), so is it worth the effort and time to support it? This is more of a question for you here, since even the problem with pymongo is related to motor dependencies, not beanie dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants