MaxHalford / vose

Cython implementation of Vose's Alias method
MIT License
5 stars 5 forks source link

Error while doing pip install vose #7

Closed ishanSengar closed 2 weeks ago

ishanSengar commented 1 month ago

Hi,

I am running into error while installing vose in my conda env.

cmd : pip install vose

full error stack trace is here :

Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [96 lines of output]

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  cimport numpy as np

  cdef class Sampler:

      cdef int n
      cdef np.int_t [:] alias
           ^
  ------------------------------------------------------------

  vose\sampler.pxd:6:9: 'int_t' is not a type identifier

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      cdef int n
      cdef np.int_t [:] alias
      cdef np.float_t [:] proba

      cdef int sample_1(self)
      cdef np.int_t [:] sample_k(self, int k)
           ^
  ------------------------------------------------------------

  vose\sampler.pxd:10:9: 'int_t' is not a type identifier

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
          # Based on the outcome, return either the column or its alias.
          if heads:
              return col
          return self.alias[col]

      cdef np.int_t [:] sample_k(self, int k):
           ^
  ------------------------------------------------------------

  vose\sampler.pyx:141:9: 'int_t' is not a type identifier

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

          if copy:
              weights = weights.copy()

          cdef int n = weights.size
          cdef np.int_t [:] alias = np.zeros(n, dtype=int)
               ^
  ------------------------------------------------------------

  vose\sampler.pyx:67:13: 'int_t' is not a type identifier

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
          if heads:
              return col
          return self.alias[col]

      cdef np.int_t [:] sample_k(self, int k):
          cdef np.int_t [:] samples = np.zeros(k, dtype=int)
               ^
  ------------------------------------------------------------

  vose\sampler.pyx:142:13: 'int_t' is not a type identifier
  Compiling vose/sampler.pyx because it changed.
  [1/1] Cythonizing vose/sampler.pyx
  Traceback (most recent call last):
    File "C:\Users\ishan\anaconda\envs\deep_synth\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "C:\Users\ishan\anaconda\envs\deep_synth\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:\Users\ishan\anaconda\envs\deep_synth\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\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\setuptools\build_meta.py", line 327, in get_requires_for_build_wheel    
      return self._get_build_requires(config_settings, requirements=[])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\setuptools\build_meta.py", line 297, in _get_build_requires
      self.run_setup()
    File "C:\Users\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\setuptools\build_meta.py", line 497, in run_setup
      super().run_setup(setup_script=setup_script)
    File "C:\Users\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\setuptools\build_meta.py", line 313, in run_setup
      exec(code, locals())
    File "<string>", line 28, in <module>
    File "C:\Users\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
    File "C:\Users\ishan\AppData\Local\Temp\pip-build-env-t_szwvp7\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: vose/sampler.pyx
  [end of output]
MaxHalford commented 1 month ago

Hello there! What version of Cython are you using? And what Python version?

ishanSengar commented 2 weeks ago

Hi @MaxHalford thanks for your response, apologies for late reply. I am using Python 3.10.12 and Cython 0.29.32

MaxHalford commented 2 weeks ago

Ok thanks, I could reproduce the issue. I just pushed a fix, and released v0.0.2.