File: enable-pypy-usage.patch

package info (click to toggle)
psycopg3 3.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,620 kB
  • sloc: python: 43,743; sh: 507; ansic: 171; makefile: 73
file content (35 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Tomasz Rybak <serpent@debian.org>
Date: Tue, 24 Sep 2024 21:12:38 +0200
Subject: Allow for using module by PyPy

Forwarded: not-needed
Last-Update: 2024-09-24

Prevent psycopg from loading of binary module (psycpog_c) when running
under PyPy.
===================================================================
---
 psycopg/psycopg/pq/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/psycopg/psycopg/pq/__init__.py b/psycopg/psycopg/pq/__init__.py
index 4f24298..32bf53e 100644
--- a/psycopg/psycopg/pq/__init__.py
+++ b/psycopg/psycopg/pq/__init__.py
@@ -13,6 +13,7 @@ from __future__ import annotations
 
 import os
 import logging
+import platform
 from typing import Callable
 
 from . import abc
@@ -71,7 +72,7 @@ def import_from_libpq() -> None:
             raise ImportError(msg) from e
 
     # The best implementation: fast but requires the system libpq installed
-    if not impl or impl == "c":
+    if (not impl or impl == "c") and platform.python_implementation() == 'CPython':
         try:
             from psycopg_c import pq as module  # type: ignore
         except Exception as e: