quantumgizmos / ldpc

Software for decoding classical and quantum codes
MIT License
79 stars 27 forks source link

Cython raised compiling error "Cannot assign type 'double' to 'long'" in installing #17

Closed HL-Bo closed 11 months ago

HL-Bo commented 1 year ago

While installing ldpc by pip, I got following error:

Collecting ldpc>=0.1.4 (from -r requirements.txt (line 9))
  Using cached https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/80/02/eb84ce26c129c7dc887fab5084d59ca0bf8400a88b77ea0e850c89303c0d/ldpc-0.1.50.tar.gz (273 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
  ╰─> [44 lines of output]

      Error compiling Cython file:
      ------------------------------------------------------------
      ...

              self.MEM_ALLOCATED=True

          cdef void osd_e_setup(self):

              self.encoding_input_count=2**self.osd_order
                                         ^
      ------------------------------------------------------------

      src\ldpc\osd.pyx:97:35: Cannot assign type 'double' to 'long'
      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
      [2/4] Cythonizing src/ldpc/c_util.pyx
      [3/4] Cythonizing src/ldpc/mod2sparse.pyx
      [4/4] Cythonizing src/ldpc/osd.pyx
      Traceback (most recent call last):
        File "C:\Path\To\Project\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>        
          main()
        File "C:\Path\To\Project\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Path\To\Project\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Bo\AppData\Local\Temp\pip-build-env-m8q0xzf0\overlay\Lib\site-packages\setuptools\build_meta.py", line 355, in get_requires_for_build_wheel   
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Bo\AppData\Local\Temp\pip-build-env-m8q0xzf0\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in _get_build_requires
          self.run_setup()
        File "C:\Users\Bo\AppData\Local\Temp\pip-build-env-m8q0xzf0\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 48, in <module>
        File "C:\Users\Bo\AppData\Local\Temp\pip-build-env-m8q0xzf0\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "C:\Users\Bo\AppData\Local\Temp\pip-build-env-m8q0xzf0\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: src/ldpc/osd.pyx
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

The system with the python interpreter is as follows:

(env) PS C:\Path\To\Project> python
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.uname()
uname_result(system='Windows', node='LAPTOP-AABBCCDD', release='11', version='10.0.22621', machine='AMD64')
>>> platform.python_implementation() 
'CPython'
(env) PS C:\Path\To\Project> pip list
Package                       Version
----------------------------- ---------
...                           ...
pip                           23.3.1
setuptools                    68.2.2

There is a similar issue in (https://github.com/Marcello-Sega/pytetgen/issues/9) and I don't know if this is caused by a similar cause.

quantumgizmos commented 1 year ago

Hi. Try replacing 2**self.osd_order with int(2**self.osd_order)