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

Missing psycopg 'binary' implementation extra since 0.30.0? #880

Closed
ashleyheath opened this issue Dec 27, 2023 · 3 comments · Fixed by #881
Closed

Missing psycopg 'binary' implementation extra since 0.30.0? #880

ashleyheath opened this issue Dec 27, 2023 · 3 comments · Fixed by #881

Comments

@ashleyheath
Copy link
Contributor

Traceback (most recent call last):
<trimmed>
2023-12-27T14:52:56.489748780Z     import procrastinate
2023-12-27T14:52:56.489765680Z   File "/code/.venv/lib/python3.11/site-packages/procrastinate/__init__.py", line 8, in <module>
2023-12-27T14:52:56.489772822Z     from procrastinate.psycopg_connector import PsycopgConnector
2023-12-27T14:52:56.489825630Z   File "/code/.venv/lib/python3.11/site-packages/procrastinate/psycopg_connector.py", line 6, in <module>
2023-12-27T14:52:56.489846036Z     import psycopg
2023-12-27T14:52:56.489930920Z   File "/code/.venv/lib/python3.11/site-packages/psycopg/__init__.py", line 9, in <module>
2023-12-27T14:52:56.490090247Z     from . import pq  # noqa: F401 import early to stabilize side effects
2023-12-27T14:52:56.490108558Z     ^^^^^^^^^^^^^^^^
2023-12-27T14:52:56.490116210Z   File "/code/.venv/lib/python3.11/site-packages/psycopg/pq/__init__.py", line 114, in <module>
2023-12-27T14:52:56.490339001Z     import_from_libpq()
2023-12-27T14:52:56.490353415Z   File "/code/.venv/lib/python3.11/site-packages/psycopg/pq/__init__.py", line 106, in import_from_libpq
2023-12-27T14:52:56.490515846Z     raise ImportError(
2023-12-27T14:52:56.490529522Z ImportError: no pq wrapper available.
2023-12-27T14:52:56.490535698Z Attempts made:
2023-12-27T14:52:56.490541408Z - couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
2023-12-27T14:52:56.490547388Z - couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
2023-12-27T14:52:56.490553206Z - couldn't import psycopg 'python' implementation: libpq library not found

Looking at #863, psycopg = {extras = ["pool"], version = "^3.1.13"} was added but without the "binary" extra package. This causes an import error for existing users who don't currently declare the depdendency directly.

Easily worked around but probably a question for @aleksandr-shtaub as to whether the omission was deliberate (i.e. to allow users of procrastinate which of the 3 implementations they use) or should we add the dependency explicitly (which would be consistent as "psycopg2-binary" is alreay there).

@ewjoachim
Copy link
Member

That might be my fault, I reworked the commits quite a bit.

I'll add it, sorry for the noise !

@ewjoachim
Copy link
Member

According to https://www.psycopg.org/psycopg3/docs/basic/install.html#handling-dependencies, we should not add a dependency to a specific implementation and let the end user choose.

I think the reason we didn't do that for psycopg2 was that we were relying on aiopg that was depending on psycopg2-binary anyway.

I think the right way of solving this is to just make sure that as long as we don't use the PsycopgConnector, it doesn't crash the rest of the lib.

@ewjoachim
Copy link
Member

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 a pull request may close this issue.

2 participants