MagicStack / asyncpg

A fast PostgreSQL Database Client Library for Python/asyncio.
Apache License 2.0
6.99k stars 404 forks source link

RFE: please provide cython 3.x support #1083

Closed kloczek closed 12 months ago

kloczek commented 1 year ago

https://github.com/MagicStack/asyncpg/blob/master/pyproject.toml#L45-L49

befeleme commented 12 months ago

We've built asyncpg in Fedora Linux with Cython 3.0.5 successfully, although with quite a few warnings.

Build warnings

  asyncpg/pgproto/pgproto.c: In function ‘__Pyx_PyLong_AbsNeg’:
  asyncpg/pgproto/pgproto.c:46832:97: warning: unsigned conversion from ‘int’ to ‘uintptr_t’ {aka ‘long unsigned int’} changes value from ‘-4’ to ‘18446744073709551612’ [-Wsign-conversion]
  46832 |             ((PyLongObject*)copy)->long_value.lv_tag = ((PyLongObject*)copy)->long_value.lv_tag & ~_PyLong_SIGN_MASK;
        |                                                                                                 ^
  In file included from /usr/include/python3.12/internal/pycore_frame.h:9,
                   from asyncpg/pgproto/pgproto.c:49619:
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_varint’:
  /usr/include/python3.12/internal/pycore_code.h:362:12: warning: conversion from ‘unsigned int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
    362 |     *ptr = val;
        |            ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_signed_varint’:
  /usr/include/python3.12/internal/pycore_code.h:375:30: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
    375 |     return write_varint(ptr, val);
        |                              ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_location_entry_start’:
  /usr/include/python3.12/internal/pycore_code.h:382:12: warning: conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
    382 |     *ptr = 128 | (code << 3) | (length - 1);
        |            ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘adaptive_counter_bits’:
  /usr/include/python3.12/internal/pycore_code.h:423:45: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
    423 |     return (value << ADAPTIVE_BACKOFF_BITS) |
        |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    424 |         (backoff & ((1<

  asyncpg/protocol/protocol.c: In function ‘__Pyx_PyUnicode_AsDouble_WithSpaces’:
  asyncpg/protocol/protocol.c:4194:58: warning: conversion to ‘long unsigned int’ from ‘Py_ssize_t’ {aka ‘long int’} may change the sign of the result [-Wsign-conversion]
   4194 |         char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char));
        |                                                          ^
  In file included from /usr/include/python3.12/internal/pycore_frame.h:9,
                   from asyncpg/protocol/protocol.c:105482:
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_varint’:
  /usr/include/python3.12/internal/pycore_code.h:362:12: warning: conversion from ‘unsigned int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
    362 |     *ptr = val;
        |            ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_signed_varint’:
  /usr/include/python3.12/internal/pycore_code.h:375:30: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
    375 |     return write_varint(ptr, val);
        |                              ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘write_location_entry_start’:
  /usr/include/python3.12/internal/pycore_code.h:382:12: warning: conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
    382 |     *ptr = 128 | (code << 3) | (length - 1);
        |            ^~~
  /usr/include/python3.12/internal/pycore_code.h: In function ‘adaptive_counter_bits’:
  /usr/include/python3.12/internal/pycore_code.h:423:45: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
    423 |     return (value << ADAPTIVE_BACKOFF_BITS) |
        |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    424 |         (backoff & ((1<
kloczek commented 12 months ago

After trimming build dependencies using below patch

--- a/pyproject.toml
+++ b/pyproject.toml
@@ -50,7 +50,7 @@
     "setuptools>=60",
     "wheel",

-    "Cython(>=0.29.24,<3.0.0)"
+    "Cython(>=3.0.0)"
 ]
 build-backend = "setuptools.build_meta"

--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@
 from setuptools.command import build_ext as setuptools_build_ext

-CYTHON_DEPENDENCY = 'Cython(>=0.29.24,<0.30.0)'
+CYTHON_DEPENDENCY = 'Cython(>=0.30.0)'

 CFLAGS = ['-O2']
 LDFLAGS = []

Looks like build is OK.

Closing.

musicinmybrain commented 7 months ago