vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
566 stars 76 forks source link

legacy-install-failure in version above 0.9.0 #141

Closed Emiri-W closed 12 months ago

Emiri-W commented 12 months ago

I try to install leidenalg using pip install leidenalg and it says legacy-install-failure. I tried installing the leidenalg version 0.8.10 (run pip install leidenalg==0.8.10), and I was able to install it, but I cannot install the new version.

I am using docker (docker image python:1-3.8-bookworm) with VScode extention.

Below is the whole error message that I get when I try to update the version of leidenalg.

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: leidenalg in /home/vscode/.local/lib/python3.8/site-packages (0.8.10)
Collecting leidenalg
  Downloading leidenalg-0.10.0.tar.gz (448 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 448.6/448.6 kB 6.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting igraph<0.11,>=0.10.0
  Using cached igraph-0.10.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB)
Requirement already satisfied: texttable>=1.6.2 in /home/vscode/.local/lib/python3.8/site-packages (from igraph<0.11,>=0.10.0->leidenalg) (1.6.7)
Building wheels for collected packages: leidenalg
  Building wheel for leidenalg (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      /usr/local/lib/python3.8/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-38
      creating build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/VertexPartition.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/__init__.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/version.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/functions.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/Optimiser.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      running build_ext
      building 'leidenalg._c_leiden' extension
      creating build/temp.linux-aarch64-cpython-38
      creating build/temp.linux-aarch64-cpython-38/src
      creating build/temp.linux-aarch64-cpython-38/src/leidenalg
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Iinclude -Ibuild-deps/install/include -I/usr/local/include/python3.8 -c src/leidenalg/pynterface.cpp -o build/temp.linux-aarch64-cpython-38/src/leidenalg/pynterface.o
      In file included from src/leidenalg/pynterface.cpp:1:
      include/pynterface.h:5:10: fatal error: igraph/igraph.h: No such file or directory
          5 | #include <igraph/igraph.h>
            |          ^~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' 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 leidenalg
  Running setup.py clean for leidenalg
Failed to build leidenalg
Installing collected packages: igraph, leidenalg
  Attempting uninstall: igraph
    Found existing installation: igraph 0.9.11
    Uninstalling igraph-0.9.11:
      Successfully uninstalled igraph-0.9.11
  Attempting uninstall: leidenalg
    Found existing installation: leidenalg 0.8.10
    Uninstalling leidenalg-0.8.10:
      Successfully uninstalled leidenalg-0.8.10
  Running setup.py install for leidenalg ... error
  error: subprocess-exited-with-error

  × Running setup.py install for leidenalg did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      /usr/local/lib/python3.8/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      running install
      /usr/local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-38
      creating build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/VertexPartition.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/__init__.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/version.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/functions.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      copying src/leidenalg/Optimiser.py -> build/lib.linux-aarch64-cpython-38/leidenalg
      running build_ext
      building 'leidenalg._c_leiden' extension
      creating build/temp.linux-aarch64-cpython-38
      creating build/temp.linux-aarch64-cpython-38/src
      creating build/temp.linux-aarch64-cpython-38/src/leidenalg
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Iinclude -Ibuild-deps/install/include -I/usr/local/include/python3.8 -c src/leidenalg/pynterface.cpp -o build/temp.linux-aarch64-cpython-38/src/leidenalg/pynterface.o
      In file included from src/leidenalg/pynterface.cpp:1:
      include/pynterface.h:5:10: fatal error: igraph/igraph.h: No such file or directory
          5 | #include <igraph/igraph.h>
            |          ^~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Rolling back uninstall of leidenalg
  Moving to /home/vscode/.local/lib/python3.8/site-packages/leidenalg-0.8.10.dist-info/
   from /home/vscode/.local/lib/python3.8/site-packages/~eidenalg-0.8.10.dist-info
  Moving to /home/vscode/.local/lib/python3.8/site-packages/leidenalg.libs/
   from /home/vscode/.local/lib/python3.8/site-packages/~eidenalg.libs
  Moving to /home/vscode/.local/lib/python3.8/site-packages/leidenalg/
   from /home/vscode/.local/lib/python3.8/site-packages/~eidenalg
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> leidenalg

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
vtraag commented 12 months ago

The leidenalg Python package is now separate from C++ core, which is implemented as a separate C++ library at https://github.com/vtraag/libleidenalg. The error you see indicates it cannot find the C++ library anywhere.

In principle, you should be able to compile the libleidenalg C++ core yourself, the steps are provided here, with some scripts to facilitate the build process. However, there should have been binary wheels on PyPI. For some reason however, the aarch64 wheels have not been uploaded to PyPI, even if they were correctly build. You could get the binary wheel directly from the build artifacts (see "artifacts" down below, the file contains all binary wheels). I'll look into this to correct this to make sure there's a binary wheel directly available from PyPI.

vtraag commented 12 months ago

The GHA automatic upload to PyPI is now solved in b994319dca240ab59e4fd65e8a0e0eef3c4b286a. It turned out that I missed a dependency on aarch64, so the upload to PyPI was triggered before the upload.

I've now also manually uploaded the aarch64 packages, so you should now not need to install it from source anymore, and can just install a binary directly.

Emiri-W commented 11 months ago

I really appreciate you for solving my problem. I couldn't understand how to import the C++ core by myself because I am a beginner, but you fixed my problem in the last comment. Thank you.

I am having the same problem while installing your louvain packages using pip install louvain. I understand you are not maintaining that package anymore, but I am using scanpy==1.11.1 and when I try to use scanpy.tl.louvain, it says ModuleNotFoundError: No module named 'louvain'. Could you please help me?

vtraag commented 11 months ago

Could you please open a separate issue for this in the louvain repository at https://github.com/vtraag/louvain-igraph? I'm not sure if I'll solve it, but I can take a closer look.

Emiri-W commented 11 months ago

Thank you very much for your kindness. I posted the new issue here: https://github.com/vtraag/louvain-igraph/issues/64