bab2min / tomotopy

Python package of Tomoto, the Topic Modeling Tool
https://bab2min.github.io/tomotopy
MIT License
557 stars 62 forks source link

Eigen file not found during pip installation #216

Closed teresaibarra closed 1 month ago

teresaibarra commented 6 months ago

When running pip install tomotopy

I get the following output:


  Using cached tomotopy-0.12.7.tar.gz (1.3 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.11.0 in /Users/path/to/project/venv/lib/python3.12/site-packages (from tomotopy) (1.26.4)
Building wheels for collected packages: tomotopy
^[[A  Building wheel for tomotopy (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [92 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-14.0-arm64-cpython-312
      creating build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/_version.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/coherence.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/__init__.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/_call_utils.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/_summary.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/utils.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/label.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/_show_progress.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      running egg_info
      writing tomotopy.egg-info/PKG-INFO
      writing dependency_links to tomotopy.egg-info/dependency_links.txt
      writing requirements to tomotopy.egg-info/requires.txt
      writing top-level names to tomotopy.egg-info/top_level.txt
      reading manifest file 'tomotopy.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching '*.c' under directory 'src'
      warning: no files found matching 'LICENSE.txt'
      adding license file 'LICENSE'
      writing manifest file 'tomotopy.egg-info/SOURCES.txt'
      /Users/path/to/project/venv/lib/python3.12/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'tomotopy.viewer' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'tomotopy.viewer' 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 'tomotopy.viewer' 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 'tomotopy.viewer' to be distributed and are
              already explicitly excluding 'tomotopy.viewer' 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)
      copying tomotopy/auto_labeling_code.rst -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/auto_labeling_code_with_porter.rst -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/documentation.kr.rst -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      copying tomotopy/documentation.rst -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy
      creating build/lib.macosx-14.0-arm64-cpython-312/tomotopy/viewer
      copying tomotopy/viewer/__init__.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy/viewer
      copying tomotopy/viewer/template.html -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy/viewer
      copying tomotopy/viewer/viewer_server.py -> build/lib.macosx-14.0-arm64-cpython-312/tomotopy/viewer
      running build_ext
      building '_tomotopy' extension
      creating build/temp.macosx-14.0-arm64-cpython-312
      creating build/temp.macosx-14.0-arm64-cpython-312/src
      creating build/temp.macosx-14.0-arm64-cpython-312/src/Labeling
      creating build/temp.macosx-14.0-arm64-cpython-312/src/TopicModel
      creating build/temp.macosx-14.0-arm64-cpython-312/src/python
      clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -DMODULE_NAME=PyInit__tomotopy -Iinclude "-I/Users/path/to/project/venv/lib/python3.12/site-packages/numpy/core/include" "-I/Users/path/to/project/venv/include" -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/Labeling/FoRelevance.cpp -o build/temp.macosx-14.0-arm64-cpython-312/src/Labeling/FoRelevance.o -std=c++1y -O3 -fpermissive -stdlib=libc++ -Wno-unused-variable -Wno-switch -DTOMOTOPY_ISA=arm64 -arch arm64
      In file included from src/Labeling/FoRelevance.cpp:4:
      In file included from src/Labeling/FoRelevance.h:4:
      In file included from src/Labeling/Labeler.h:4:
      In file included from src/Labeling/../TopicModel/TopicModel.hpp:5:
      In file included from src/Labeling/../TopicModel/../Utils/Dictionary.h:9:
      src/Labeling/../TopicModel/../Utils/serializer.hpp:10:10: fatal error: 'Eigen/Dense' file not found
      #include <Eigen/Dense>
               ^~~~~~~~~~~~~
      1 error 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 tomotopy
  Running setup.py clean for tomotopy
Failed to build tomotopy
ERROR: Could not build wheels for tomotopy, which is required to install pyproject.toml-based projects```

I'm running this on an Apple M3 Pro.
fx86 commented 4 months ago

I faced the same error and I went down the route of building from source. After cloning the repo, run the following commands from within the tomotopy folder:

git clone https://gitlab.com/libeigen/eigen
cd eigen
git checkout tags/3.4.0
cd ..
mkdir include
mv eigen/Eigen/ include/
rm -rf eigen-git-mirror/
git clone https://github.com/bab2min/EigenRand
cd EigenRand
git checkout tags/v0.4.1
cd ..
mv EigenRand/EigenRand include/
git clone https://github.com/mapbox/variant
cd variant
git checkout tags/v1.1.3
cd ..
mv variant/include/mapbox include/

Now, run: python setup.py install.

This took me past the error that this issue talks about. Found these steps in the github workflow files that @bab2min (thanks!) had added. cc: @teresaibarra

(all hail grep!)