Subject: python-fastbencode does not build the C extensions

From: Dariqq <[email-masked]>
Date: Thu, 23 Jan 2025 15:00:46 +0000

Hello,
while troubleshooting some python things i got the following warning 
UserWarning: failed to load compiled extension: No module named 
'fastbencode._bencode_pyx'

Reason seems to be that something goes wrong during building:
Snippet of build log at 4241a5a4688e8a118b2f66423abd3ef8baae98fc

running build_ext
cythoning fastbencode/_bencode_pyx.pyx to fastbencode/_bencode_pyx.c

Error compiling Cython file:
------------------------------------------------------------
...
from cpython.mem cimport (
     PyMem_Free,
     PyMem_Malloc,
     PyMem_Realloc,
     )
from cpython.unicode cimport (
^
------------------------------------------------------------

fastbencode/_bencode_pyx.pyx:49:0: 
'cpython/unicode/PyUnicode_FromStringAndSize.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
             raise ValueError('string size below zero: %d' % n)

         if self._bytestring_encoding == NULL:
             result = PyBytes_FromStringAndSize(self.tail, n)
         elif self._bytestring_encoding == b'utf-8':
             result = PyUnicode_FromStringAndSize(self.tail, n)
                     ^
------------------------------------------------------------

fastbencode/_bencode_pyx.pyx:201:21: 'PyUnicode_FromStringAndSize' is 
not a constant, variable or function identifier
building 'fastbencode._bencode_pyx' extension
creating build/temp.linux-x86_64-cpython-310
creating build/temp.linux-x86_64-cpython-310/fastbencode
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-fno-semantic-interposition -fPIC -Ifastbencode 
-I/gnu/store/kayi1a27qjbizw1870vgpwd6mzcdggql-python-3.10.7/include/python3.10 
-c fastbencode/_bencode_pyx.c -o 
build/temp.linux-x86_64-cpython-310/fastbencode/_bencode_pyx.o
fastbencode/_bencode_pyx.c:1:2: error: #error Do not use this file, it 
is the result of a failed Cython compilation.
     1 | #error Do not use this file, it is the result of a failed 
Cython compilation.
       |  ^~~~~
warning: old_build_ext: building extension "fastbencode._bencode_pyx" 
failed: command 
'/gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/bin/gcc' failed 
with exit code 1