pedroilidio / bipartite_learn

BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Cythonization error with pip install #3

Closed pedroilidio closed 2 years ago

pedroilidio commented 2 years ago

Hypertrees will compile just fine with python setup.py build_ext --inplace but fails inexplicably when issuing pip install --editable .:

  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python /usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmplqrqeq_a
       cwd: /home/pedro/mestrado/biomal_repo/scripts/predictors/hypertrees
  Complete output (109 lines):

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
              else:
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
                             ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:327:28: Cannot convert Python object to 'double *'

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
          sum_right = criterion.sum_right
                              ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:328:29: Cannot convert Python object to 'double *'

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
              else:
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
                             ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:327:28: Coercion from Python not allowed without the GIL

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
              else:
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
                             ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:327:28: Accessing Python attribute not allowed without gil

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
          sum_right = criterion.sum_right
                              ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:328:29: Coercion from Python not allowed without the GIL

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
                  criterion = self.splitter_rows.criterion

          pos = criterion.pos

          sum_left = criterion.sum_left
          sum_right = criterion.sum_right
                              ^
  ------------------------------------------------------------

  hypertree/tree/_nd_criterion.pyx:328:29: Accessing Python attribute not allowed without gil
  Compiling hypertree/tree/_nd_criterion.pyx because it changed.
  Compiling hypertree/tree/_nd_splitter.pyx because it changed.
  Compiling hypertree/tree/_nd_tree.pyx because it changed.
  Compiling hypertree/tree/_semisupervised_criterion.pyx because it changed.
  [1/4] Cythonizing hypertree/tree/_nd_criterion.pyx
  Traceback (most recent call last):
    File "/usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/usr/lib/python3.10/site-pac
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-im_y7hcw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/tmp/pip-build-env-im_y7hcw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-im_y7hcw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 39, in <module>
      ext_modules=cythonize(
    File "/tmp/pip-build-env-im_y7hcw/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1127, in cythonize
      cythonize_one(*args)
    File "/tmp/pip-build-env-im_y7hcw/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1250, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: hypertree/tree/_nd_criterion.pyx
pedroilidio commented 2 years ago

scikit-learn was updated to version 1.1.1 in the meantime, removing sum_* attributes from Criterion (https://github.com/scikit-learn/scikit-learn/pull/22921). Then, the older sklearn version installed in my machine saw no problem in compiling the extensions with setup.py build_ext, but newly downloaded sklearn with pip instal -e . complained.