Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython Compilation Errors During Installation of ldpc on macOS with Python 3.12.3 and Numpy 2.0.1 #43

Open
beitom opened this issue Aug 26, 2024 · 1 comment

Comments

@beitom
Copy link

beitom commented Aug 26, 2024

Description:
When attempting to install the ldpc package on macOS with Python 3.12.3 and Numpy 2.0.1, the installation fails due to multiple Cython compilation errors. The errors occur specifically when the installation process attempts to build the wheel for ldpc.

Below is the relevant portion of the output:

pip install ldpc
Collecting ldpc
  Using cached ldpc-0.1.51.tar.gz (367 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [111 lines of output]
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      cdef char* numpy2char(np_array,char* char_array)
      cdef char* spmatrix2char(matrix,char* char_array)
      cdef double* numpy2double(np.ndarray[np.float_t, ndim=1] np_array,double* double_array)
      cdef np.ndarray[np.int_t, ndim=1] char2numpy(char* char_array, int n)
                         ^
      ------------------------------------------------------------
      
      src/ldpc/c_util.pxd:11:19: Invalid type.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      from ldpc.c_util cimport numpy2double,numpy2char,char2numpy,double2numpy
      ^
      ------------------------------------------------------------
      
      src/ldpc/mod2sparse.pxd:6:0: 'ldpc/c_util/char2numpy.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      from ldpc.c_util cimport numpy2double,numpy2char,char2numpy,double2numpy
      ^
      ------------------------------------------------------------
      
      src/ldpc/mod2sparse.pxd:6:0: 'ldpc/c_util/double2numpy.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cpdef np.ndarray[np.int_t, ndim=1] mul(self, np.ndarray[np.int_t, ndim=1] vector)
                              ^
      ------------------------------------------------------------
      
      src/ldpc/mod2sparse.pxd:80:24: Invalid type.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cpdef np.ndarray[np.int_t, ndim=1] decode(self, input_vector)
                              ^
      ------------------------------------------------------------
      
      src/ldpc/bp_decoder.pxd:32:24: Invalid type.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cpdef np.ndarray[np.int_t, ndim=1] decode(self, input_vector):
                              ^
      ------------------------------------------------------------
      
      src/ldpc/bp_decoder.pyx:122:24: Invalid type.
      Compiling src/ldpc/bp_decoder.pyx because it changed.
      Compiling src/ldpc/mod2sparse.pyx because it changed.
      Compiling src/ldpc/c_util.pyx because it changed.
      Compiling src/ldpc/osd.pyx because it changed.
      [1/4] Cythonizing src/ldpc/bp_decoder.pyx
      Traceback (most recent call last):
        ...
      Cython.Compiler.Errors.CompileError: src/ldpc/bp_decoder.pyx
      [end of output]

Steps to Reproduce:

  1. Set up a virtual environment on macOS with Python 3.12.3.
  2. Install Numpy 2.0.1 using pip.
  3. Attempt to install the ldpc package using pip.

Environment:

  • Operating System: macOS
  • Python Version: 3.12.3
  • Numpy Version: 2.0.1
  • ldpc Version: 0.1.51

Expected Behavior:
The installation process should successfully build and install the ldpc package without errors.

Actual Behavior:
The installation process fails during the wheel build for ldpc, leading to a failed installation.

Errors Encountered:

  • Invalid Type Errors: Multiple occurrences of "Invalid type" errors in Cython files such as src/ldpc/c_util.pxd, src/ldpc/mod2sparse.pxd, src/ldpc/bp_decoder.pxd, and src/ldpc/bp_decoder.pyx.
  • Missing Files: The Cython compiler reports missing files: 'ldpc/c_util/char2numpy.pxd' and 'ldpc/c_util/double2numpy.pxd'.
  • Traceback: The compilation process eventually fails with a Cython.Compiler.Errors.CompileError on src/ldpc/bp_decoder.pyx.

Suggestion:
It would be beneficial to review the Cython files and dependencies to ensure compatibility with the latest Python and Numpy versions. Additionally, if ldpc is not critical to the core functionality, consider making it an optional dependency, or provide pre-built wheels for macOS to avoid these issues.

Additional Information:

  • The issue may be specific to the setup on macOS with the mentioned versions. The error messages suggest that the problem lies in the Cython code of ldpc, potentially due to missing or incompatible files.
  • A similar issue was encountered when trying to install the mqt.qecc package, which also depends on ldpc.
@quantumgizmos
Copy link
Owner

Hi. We are currently working on a v2 of this package that will be merged into this main repository shortly. Could you check whehter the problem persistis in ldpc_V2?

https://github.com/quantumgizmos/ldpc_v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants