aiopg
aiopg copied to clipboard
Issues on PyPy
trafficstars
I'm trying to use this in a PyPy environment with psycopg2cffi installed; however, I get this error:
File "project/lib/foo/src/foo/foo.py", line 5, in <module>
from aiopg.sa.engine import Engine
File "/usr/local/site-packages/aiopg/__init__.py", line 6, in <module>
from .connection import connect, Connection, TIMEOUT as DEFAULT_TIMEOUT
File "/usr/local/site-packages/aiopg/connection.py", line 12, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
If I try to do the psycopg2cffi.compat.register() monkeypatch thing, I get this error:
Fatal error on aiopg connection: POLL_ERROR from underlying .poll() call\nconnection: <aiopg.connection.Connection object at 0x00000000085ce4f0>
Are there instructions for installing into PyPy (if so, apologies for missing them)? Am I doing something wrong? Or maybe this simply isn't supported?
There's a workaround for this.
Pip setup shell commands:
PYPY=/path/to/pypy
PYPY_PIP=/path/to/pypy/pip
$PYPY -m ensurepip
$PYPY -m pip install --upgrade pip
$PYPY_PIP install psycopg2cffi
$PYPY_PIP install aiopg # succeeds, even though it installs a broken psycopg2-binary
Then, on pypy program startup:
import sys
import psycopg2cffi as psycopg2
sys.modules['psycopg2'] = psycopg2
import aiopg # this imports psycopg2cffi masquerading as psycopg2, and now works
(update -- this is tested and working in PyPy 3.9)