polm / fugashi

A Cython MeCab wrapper for fast, pythonic Japanese tokenization and morphological analysis.
MIT License
402 stars 33 forks source link

Unable to build wheels, Python3 Windows install #88

Closed arihid closed 8 months ago

arihid commented 8 months ago

Hello, I'm installing pcleaner that uses fugashi as its component in Windows, but it always error (please refer to this log).

  error: subprocess-exited-with-error

  × Building wheel for fugashi (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      WARNING setuptools_scm.pyproject_reading toml section missing 'pyproject.toml does not contain a tool.setuptools_scm section'
      running bdist_wheel
      running build
      running build_py
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\fugashi
      copying fugashi\cli.py -> build\lib.win-amd64-cpython-312\fugashi
      copying fugashi\__init__.py -> build\lib.win-amd64-cpython-312\fugashi
      running build_ext
      cythoning fugashi/fugashi.pyx to fugashi\fugashi.c
      building 'fugashi.fugashi' extension
      creating build\temp.win-amd64-cpython-312
      creating build\temp.win-amd64-cpython-312\Release
      creating build\temp.win-amd64-cpython-312\Release\fugashi
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\mecab -IC:\Users\kekes\AppData\Local\Programs\Python\Python312\include -IC:\Users\kekes\AppData\Local\Programs\Python\Python312\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcfugashi\fugashi.c /Fobuild\temp.win-amd64-cpython-312\Release\fugashi\fugashi.obj
      fugashi.c
      fugashi\fugashi.c(750): fatal error C1083: Cannot open include file: 'mecab.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

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

I have installed mecab and mecab-python3, and when I tried to install fugashi with pip install fugashi, i run into the same error.

polm commented 8 months ago

It can't find mecab.h for some reason. That's strange because mecab.h is already included with the source here.

I'm not very familiar with the Windows compiler, but can you try adding a flag like -Ipath/to/mecab.h in the appropriate place?

arihid commented 8 months ago

Am I supposed to run it like pip install fugashi "-IC:\Program Files\MeCab\sdk\mecab.h" because that command prints possible commands instead. And the same goes if I run the command without typing the quotation marks.

C:\Users\<username>>pip install fugashi "-IC:\Program Files\MeCab\sdk\mecab.h"

Usage:
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

Arguments to -C must be of the form KEY=VAL

I'm sorry I'm unfamiliar with python.

polm commented 8 months ago

It's a compiler argument, so you can't pass it directly to pip.

I am working on building 3.12 wheels, but it looks like PyPI authorization has changed, so I need to take a little time to fix that. Can you try using Python 3.11 or lower in the meantime? With those you should not need to build from source, which should avoid this problem.

Also note that if wheels are available you do not need MeCab installed separately. In any case you do not need to install mecab-python3 to use fugashi.

polm commented 8 months ago

Try this:

pip install fugashi==1.3.1dev0
fanyingfx commented 8 months ago

pip install fugashi==1.3.1dev0

Just tried it on my Windows machine, python version 3.12.2, it works well!

polm commented 8 months ago

Thanks for confirming, I'll make a release.

arihid commented 8 months ago

I'm sorry for the late reply. This version installed successfully. I'll close the issue.