sissa-data-science / DADApy

Distance-based Analysis of DAta-manifolds in python
https://dadapy.readthedocs.io/
Apache License 2.0
99 stars 16 forks source link

Issue installing on MacOS Arm64 #131

Open debarshibanerjee opened 3 weeks ago

debarshibanerjee commented 3 weeks ago

Subject of the issue

The 'pip install dadapy' and 'pip install git+https://github.com/sissa-data-science/DADApy ' both appear to fail for a fresh install. However, installing by downloading the source appears to work and the same error doesn't arise.

Your environment

Steps to reproduce

When trying to install the latest version, I get an error since the wheel for DADApy fails to build.

Expected behaviour

Installation should go smoothly. Previous versions seemed to work fine.

Actual behaviour

I get the following error message:

Building wheels for collected packages: dadapy
  Building wheel for dadapy (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for dadapy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [158 lines of output]
      OpenMP not supported
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-13.4-arm64-cpython-310
      creating build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/density_advanced.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/plot.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/neigh_graph.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/clustering.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/metric_comparisons.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/id_discrete.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/feature_weighting.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/__init__.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/density_estimation.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/data_sets.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/base.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/id_estimation.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/data.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      copying dadapy/kstar.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy
      creating build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/differentiable_imbalance.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/metric_comparisons.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/__init__.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/utils.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/discrete_functions.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/density_estimation.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      copying dadapy/_utils/id_estimation.py -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils
      running egg_info
      writing dadapy.egg-info/PKG-INFO
      writing dependency_links to dadapy.egg-info/dependency_links.txt
      writing requirements to dadapy.egg-info/requires.txt
      writing top-level names to dadapy.egg-info/top_level.txt
      reading manifest file 'dadapy.egg-info/SOURCES.txt'
      writing manifest file 'dadapy.egg-info/SOURCES.txt'
      /private/var/folders/lx/j553g_p92l905lmb9ychkkj40000gn/T/pip-build-env-p20nxmuv/overlay/lib/python3.10/site-packages/setuptools/command/build_py.py:215: _Warning: Package 'dadapy._cython' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'dadapy._cython' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'dadapy._cython' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'dadapy._cython' to be distributed and are
              already explicitly excluding 'dadapy._cython' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      /private/var/folders/lx/j553g_p92l905lmb9ychkkj40000gn/T/pip-build-env-p20nxmuv/overlay/lib/python3.10/site-packages/setuptools/command/build_py.py:215: _Warning: Package 'dadapy._utils.discrete_volumes' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'dadapy._utils.discrete_volumes' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'dadapy._utils.discrete_volumes' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'dadapy._utils.discrete_volumes' to be distributed and are
              already explicitly excluding 'dadapy._utils.discrete_volumes' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      creating build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_clustering.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_clustering_v2.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_density.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_differentiable_imbalance.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_distances.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_grads.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_maximum_likelihood_opt.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_maximum_likelihood_opt_full.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      copying dadapy/_cython/cython_overlap.c -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_cython
      creating build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/V_exact.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/L_coefficients_float.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/L_coefficients_exact.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/L_coefficients_exact.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/L_coefficients_float.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      copying dadapy/_utils/discrete_volumes/V_exact.dat -> build/lib.macosx-13.4-arm64-cpython-310/dadapy/_utils/discrete_volumes
      running build_ext
      building 'dadapy._cython.cython_clustering' extension
      creating build/temp.macosx-13.4-arm64-cpython-310
      creating build/temp.macosx-13.4-arm64-cpython-310/dadapy
      creating build/temp.macosx-13.4-arm64-cpython-310/dadapy/_cython
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/opt/homebrew/opt/openblas/include -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/private/var/folders/lx/j553g_p92l905lmb9ychkkj40000gn/T/pip-build-env-p20nxmuv/overlay/lib/python3.10/site-packages/numpy/_core/include -I/Users/dbanerje/.pyenv/versions/md/include -I/Users/dbanerje/.pyenv/versions/3.10.12/include/python3.10 -c dadapy/_cython/cython_clustering.c -o build/temp.macosx-13.4-arm64-cpython-310/dadapy/_cython/cython_clustering.o
      dadapy/_cython/cython_clustering.c:4232:41: error: no member named 'subarray' in 'struct _PyArray_Descr'
          __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
                                   ~~~~~~~~~  ^
      dadapy/_cython/cython_clustering.c:1861:37: note: expanded from macro '__Pyx_INCREF'
        #define __Pyx_INCREF(r) Py_INCREF(r)
                                          ^
      /Users/dbanerje/.pyenv/versions/3.10.12/include/python3.10/object.h:475:49: note: expanded from macro 'Py_INCREF'
      #define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))
                                                      ^~
      /Users/dbanerje/.pyenv/versions/3.10.12/include/python3.10/object.h:112:41: note: expanded from macro '_PyObject_CAST'
      #define _PyObject_CAST(op) ((PyObject*)(op))
                                              ^~
      dadapy/_cython/cython_clustering.c:4233:38: error: no member named 'subarray' in 'struct _PyArray_Descr'
          __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
                                ~~~~~~~~~  ^
      2 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dadapy
Failed to build dadapy
ERROR: Could not build wheels for dadapy, which is required to install pyproject.toml-based projects
AldoGl commented 3 weeks ago

Dear @debarshibanerjee thank you very much for opening this issue. I am having the same problemm it seems related to a new version of numpy. Along with @imacocco we are investigating this further

AldoGl commented 2 weeks ago

Hi @debarshibanerjee, we found out this was a compatibility problem of cython with numpy 2.0. Thanks to @diegodoimo change in 6736b147fd4a5585d924a7e3ea12c44beb4e2763 we released version 0.3.1 which now you should be able to install correctly