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

ImportWarning on PooledPostgresqlExtDatabase #2296

Closed
alecgerona opened this issue Nov 10, 2020 · 10 comments
Closed

ImportWarning on PooledPostgresqlExtDatabase #2296

alecgerona opened this issue Nov 10, 2020 · 10 comments

Comments

@alecgerona
Copy link

Hi all so we're using the query builder feature (not the ORM at all) of peewee and it's been great so far. Been using it with fastapi and it's been working great until the 3.14.0 update. Now we're getting the following issue:

tests/test_lib/integration/test_pagination.py:3: in <module>
    from app.user.models import User, UserPagination
app/user/models.py:45: in <module>
    User = __User()
lib/table.py:54: in __init__
    from app.database import db
app/database.py:2: in <module>
    from lib.database import RetryableDatabase
lib/database.py:17: in <module>
    from playhouse.pool import PooledPostgresqlExtDatabase
venv/lib/python3.8/site-packages/playhouse/pool.py:305: in <module>
    from playhouse.sqlite_ext import SqliteExtDatabase
venv/lib/python3.8/site-packages/playhouse/sqlite_ext.py:19: in <module>
    from playhouse._sqlite_ext import (
playhouse/_sqlite_ext.pyx:1: in init playhouse._sqlite_ext
    ???
E   ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

Can anyone shed light on this? Rolling back to 3.13 fixes the issue.

@alecgerona alecgerona changed the title ImportError on PooledPostgresqlExtDatabase ImportWarning on PooledPostgresqlExtDatabase Nov 10, 2020
@coleifer
Copy link
Owner

coleifer commented Nov 10, 2020

That's odd. The line you're referencing, 305, is wrapped in a try/except on ImportError, as is the code in sqlite_ext.py which attempts to import from the C extension. This doesn't seem to be an error, but rather a warning?

The pyx file is the cython source file, which gets compiled into a C extension. Is your code trying to read the pyx file, or what is going on there?

@alecgerona
Copy link
Author

Okay so for more context the error only happens when pytest is run since the file in question that imports PooledPostgresqlExtDatabase is imported in pytest's conftest.py. Running it through uvicorn works otherwise.

@coleifer
Copy link
Owner

I think this may be the related issue cython/cython#1720 - I'm not sure why this occurs only for 3.14 but not 3.13.3, though?

@alecgerona
Copy link
Author

Probably? What should be a workaround for this?

@coleifer
Copy link
Owner

I don't see anything in the diff that seems relevant to this issue: 3.13.3...3.14.0

Also, as far as I can tell this isn't a bug, but rather you're receiving a warning during testing. You might try recompiling, or upgrading cython and rebuilding?

@alecgerona
Copy link
Author

Hmm. This happens on a fresh install/run on a CI though. Still a cython issue?

@coleifer
Copy link
Owner

I don't know, honestly. I don't see the issue running the peewee tests https://travis-ci.org/github/coleifer/peewee and I really don't see anything between versions 3.13.3 and 3.14.0 that seems relevant.

@alecgerona
Copy link
Author

@coleifer found an issue related to this: pytest-dev/pytest#4423 and it seems like it is Cython issue that and he ended up building it with a newer version of Cython to get it working. Might help.

@alecgerona
Copy link
Author

@coleifer more info: when I install peewee 3.14.0 from source, it works no problem. So maybe something else happened when 3.14.0 was released in pypi?

@alecgerona
Copy link
Author

Final context to those who might stumble upon this: [email protected] works in Python 3.9 and not on 3.8. I haven't tested for lower versions. However, 3.14.1 and 3.14.2 works on both 3.9 and 3.8. I still think that there was something wrong with how 3.14.0 was built.

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

No branches or pull requests

2 participants