summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/psycopg/ctypes.patch
blob: 2863c9bfbfc2333c95333c588bb8039e79b31b3b (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
diff --git a/psycopg/psycopg/pq/_pq_ctypes.py b/psycopg/psycopg/pq/_pq_ctypes.py
index 99e49357..3827d6dd 100644
--- a/psycopg/psycopg/pq/_pq_ctypes.py
+++ b/psycopg/psycopg/pq/_pq_ctypes.py
@@ -13,13 +13,10 @@ from ctypes import CFUNCTYPE, POINTER, Structure, c_char, c_char_p, c_int, c_siz
 from ctypes import c_ubyte, c_uint, c_void_p
 from typing import Any, NoReturn
 
-from .misc import find_libpq_full_path, version_pretty
+from .misc import version_pretty
 from ..errors import NotSupportedError
 
-if not (libname := find_libpq_full_path()):
-    raise ImportError("libpq library not found")
-
-pq = ctypes.cdll.LoadLibrary(libname)
+pq = ctypes.cdll.LoadLibrary("@libpq@")
 
 
 class FILE(Structure):
@@ -29,11 +26,7 @@ class FILE(Structure):
 FILE_ptr = POINTER(FILE)
 
 if sys.platform == "linux":
-    if not (libcname := ctypes.util.find_library("c")):
-        # Likely this is a system using musl libc, see the following bug:
-        # https://github.com/python/cpython/issues/65821
-        libcname = "libc.so"
-    libc = ctypes.cdll.LoadLibrary(libcname)
+    libc = ctypes.cdll.LoadLibrary("@libc@")
 
     fdopen = libc.fdopen
     fdopen.argtypes = (c_int, c_char_p)
diff --git a/tests/fix_pq.py b/tests/fix_pq.py
index 8d7e9ae6..074be456 100644
--- a/tests/fix_pq.py
+++ b/tests/fix_pq.py
@@ -50,18 +50,7 @@ def pytest_runtest_setup(item):
 @pytest.fixture
 def libpq():
     """Return a ctypes wrapper to access the libpq."""
-    try:
-        from psycopg.pq.misc import find_libpq_full_path
-
-        # Not available when testing the binary package
-        libname = find_libpq_full_path()
-        assert libname, "libpq libname not found"
-        return ctypes.cdll.LoadLibrary(libname)
-    except Exception as e:
-        if pq.__impl__ == "binary":
-            pytest.skip(f"can't load libpq for testing: {e}")
-        else:
-            raise
+    return ctypes.cdll.LoadLibrary("@libpq@")
 
 
 @pytest.fixture