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

Issues on PyPy #650

Open
ns-cweber opened this issue Feb 6, 2020 · 1 comment
Open

Issues on PyPy #650

ns-cweber opened this issue Feb 6, 2020 · 1 comment

Comments

@ns-cweber
Copy link

ns-cweber commented Feb 6, 2020

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?

@davidmcnabnz
Copy link

davidmcnabnz commented Jul 29, 2022

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)

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