From: Daniele Varrazzo Date: Mon, 21 Dec 2020 00:49:06 +0000 (+0100) Subject: psycopg3_c packages moved closer to where they are used X-Git-Tag: 3.0.dev0~252^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1c3797c11d0cee1d5d507b22f98b24494269abe;p=thirdparty%2Fpsycopg.git psycopg3_c packages moved closer to where they are used Things were compiling well because everything goes into the same namespace. --- diff --git a/psycopg3_c/psycopg3_c/pq/conninfo.pyx b/psycopg3_c/psycopg3_c/pq/conninfo.pyx index fbb5ff4d9..2fc29c45e 100644 --- a/psycopg3_c/psycopg3_c/pq/conninfo.pyx +++ b/psycopg3_c/psycopg3_c/pq/conninfo.pyx @@ -4,6 +4,8 @@ psycopg3_c.pq_cython.Conninfo object implementation. # Copyright (C) 2020 The Psycopg Team +from psycopg3.pq.misc import ConninfoOption + class Conninfo: @classmethod @@ -33,3 +35,27 @@ class Conninfo: def __repr__(self): return f"<{type(self).__name__} ({self.keyword.decode('ascii')})>" + + +cdef _options_from_array(impl.PQconninfoOption *opts): + rv = [] + cdef int i = 0 + cdef impl.PQconninfoOption* opt + while 1: + opt = opts + i + if opt.keyword is NULL: + break + rv.append( + ConninfoOption( + keyword=opt.keyword, + envvar=opt.envvar if opt.envvar is not NULL else None, + compiled=opt.compiled if opt.compiled is not NULL else None, + val=opt.val if opt.val is not NULL else None, + label=opt.label if opt.label is not NULL else None, + dispchar=opt.dispchar if opt.dispchar is not NULL else None, + dispsize=opt.dispsize, + ) + ) + i += 1 + + return rv diff --git a/psycopg3_c/psycopg3_c/pq/escaping.pyx b/psycopg3_c/psycopg3_c/pq/escaping.pyx index cec866337..7938c6491 100644 --- a/psycopg3_c/psycopg3_c/pq/escaping.pyx +++ b/psycopg3_c/psycopg3_c/pq/escaping.pyx @@ -4,6 +4,10 @@ psycopg3_c.pq_cython.Escaping object implementation. # Copyright (C) 2020 The Psycopg Team +from libc.string cimport strlen +from cpython.bytearray cimport PyByteArray_FromStringAndSize, PyByteArray_Resize +from cpython.bytearray cimport PyByteArray_AS_STRING + cdef class Escaping: def __init__(self, PGconn conn = None): diff --git a/psycopg3_c/psycopg3_c/pq/pgconn.pyx b/psycopg3_c/psycopg3_c/pq/pgconn.pyx index c3bca6238..cd367024d 100644 --- a/psycopg3_c/psycopg3_c/pq/pgconn.pyx +++ b/psycopg3_c/psycopg3_c/pq/pgconn.pyx @@ -4,6 +4,17 @@ psycopg3_c.pq_cython.PGconn object implementation. # Copyright (C) 2020 The Psycopg Team +from posix.unistd cimport getpid +from cpython.mem cimport PyMem_Malloc, PyMem_Free +from cpython.bytes cimport PyBytes_AsString + +import logging + +from psycopg3_c.pq.libpq cimport Oid +from psycopg3.pq.misc import PGnotify + +logger = logging.getLogger('psycopg3') + cdef class PGconn: @staticmethod @@ -544,27 +555,3 @@ cdef void _clear_query_params( PyMem_Free(cvalues) PyMem_Free(clenghts) PyMem_Free(cformats) - - -cdef _options_from_array(impl.PQconninfoOption *opts): - rv = [] - cdef int i = 0 - cdef impl.PQconninfoOption* opt - while 1: - opt = opts + i - if opt.keyword is NULL: - break - rv.append( - ConninfoOption( - keyword=opt.keyword, - envvar=opt.envvar if opt.envvar is not NULL else None, - compiled=opt.compiled if opt.compiled is not NULL else None, - val=opt.val if opt.val is not NULL else None, - label=opt.label if opt.label is not NULL else None, - dispchar=opt.dispchar if opt.dispchar is not NULL else None, - dispsize=opt.dispsize, - ) - ) - i += 1 - - return rv diff --git a/psycopg3_c/psycopg3_c/pq/pgresult.pyx b/psycopg3_c/psycopg3_c/pq/pgresult.pyx index 470df1efd..7deb7012e 100644 --- a/psycopg3_c/psycopg3_c/pq/pgresult.pyx +++ b/psycopg3_c/psycopg3_c/pq/pgresult.pyx @@ -4,6 +4,10 @@ psycopg3_c.pq_cython.PGresult object implementation. # Copyright (C) 2020 The Psycopg Team +from cpython.mem cimport PyMem_Malloc, PyMem_Free + +from psycopg3.pq.misc import PGresAttDesc + cdef class PGresult: def __cinit__(self): diff --git a/psycopg3_c/psycopg3_c/pq/pqbuffer.pyx b/psycopg3_c/psycopg3_c/pq/pqbuffer.pyx index b4048a3df..93f1942bb 100644 --- a/psycopg3_c/psycopg3_c/pq/pqbuffer.pyx +++ b/psycopg3_c/psycopg3_c/pq/pqbuffer.pyx @@ -4,6 +4,10 @@ PQbuffer object implementation. # Copyright (C) 2020 The Psycopg Team +from cpython.bytes cimport PyBytes_AsStringAndSize +from cpython.buffer cimport PyObject_CheckBuffer, PyBUF_SIMPLE +from cpython.buffer cimport PyObject_GetBuffer, PyBuffer_Release + cdef class PQBuffer: """ diff --git a/psycopg3_c/psycopg3_c/pq_cython.pyx b/psycopg3_c/psycopg3_c/pq_cython.pyx index 5d1dfe44c..761bcd5c2 100644 --- a/psycopg3_c/psycopg3_c/pq_cython.pyx +++ b/psycopg3_c/psycopg3_c/pq_cython.pyx @@ -4,41 +4,19 @@ libpq Python wrapper using cython bindings. # Copyright (C) 2020 The Psycopg Team -from libc.string cimport strlen -from posix.unistd cimport getpid -from cpython.mem cimport PyMem_Malloc, PyMem_Free -from cpython.bytes cimport PyBytes_AsString, PyBytes_AsStringAndSize -from cpython.buffer cimport PyObject_CheckBuffer, PyBUF_SIMPLE -from cpython.buffer cimport PyObject_GetBuffer, PyBuffer_Release -from cpython.bytearray cimport PyByteArray_FromStringAndSize, PyByteArray_Resize -from cpython.bytearray cimport PyByteArray_AS_STRING - -import logging -from typing import List, Optional, Sequence, Tuple - -from psycopg3_c.pq cimport libpq as impl -from psycopg3_c.pq.libpq cimport Oid - -from psycopg3.pq.misc import PGnotify, ConninfoOption, PQerror, PGresAttDesc -from psycopg3.pq.misc import error_message -from psycopg3.pq import ( - ConnStatus, - PollingStatus, - ExecStatus, - TransactionStatus, - Ping, - DiagnosticField, - Format, -) +from psycopg3_c.pq cimport libpq +from psycopg3.pq.misc import PQerror, error_message + +from psycopg3.pq import ConnStatus, PollingStatus, ExecStatus +from psycopg3.pq import TransactionStatus, Ping, DiagnosticField, Format -__impl__ = 'c' -logger = logging.getLogger('psycopg3') +__impl__ = 'c' def version(): - return impl.PQlibVersion() + return libpq.PQlibVersion() include "pq/pgconn.pyx"