Cython compilation fail after separating code
Hello,
I am on SageMath version 9.8.beta2, Release Date: 2022-10-16, Using Python 3.10.5.
I am using an Intel i9-12900K on WSL version 1.0.0.0, WSL Kernel version 5.15.74.2.
The code in my master branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.
In the cleanup branch, I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module compiles without any problems. The metagraph module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log:
>sage --python3 setup.py build_ext --inplace
Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx
Error compiling Cython file:
------------------------------------------------------------
...
cdef mp_bitcnt_t extra
bits.size = size
if fused_bitset_t is bitset_t:
bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
^
------------------------------------------------------------
/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'
Error compiling Cython file:
------------------------------------------------------------
...
bits.size = size
if fused_bitset_t is bitset_t:
bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
else:
bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
^
------------------------------------------------------------
/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'
Error compiling Cython file:
------------------------------------------------------------
...
bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
bits.non_zero_chunks_are_initialized = False
bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
^
------------------------------------------------------------
/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'
Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas ๐
It would have been easier to debug with the name
cleanupof the branch you are working on rather than describing partially what you did.@vdelecroix I didn't want to be accused of not including enough information, so I included every step that I took along the way. I linked the
cleanupbranch in the links forfastqueue moduleandmetagraph module, but I will add an addendum to make it a bit more clear.