R1j1t / contextualSpellCheck

✔️Contextual word checker for better suggestions
MIT License
405 stars 56 forks source link

[BUG] Windows users with Python 3.8+ cannot resolve editdistance==0.5.3 dependency #79

Closed tpanza closed 2 years ago

tpanza commented 2 years ago

Describe the bug A Windows user running Python 3.8 or 3.9 cannot successfully run pip install contextualSpellCheck. (Unless Microsoft C++ Build Tools has been installed ahead of time.)

To Reproduce

conda create -n myenv python=3.9
conda activate myenv
python -m pip install contextualSpellCheck

Building wheels for collected packages: editdistance
  Building wheel for editdistance (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-39
      creating build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\__init__.py -> build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\_editdistance.h -> build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\def.h -> build\lib.win-amd64-cpython-39\editdistance
      running build_ext
      building 'editdistance.bycython' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for editdistance
  Running setup.py clean for editdistance
Failed to build editdistance
Installing collected packages: editdistance, contextualSpellCheck
  Running setup.py install for editdistance ... error
  error: subprocess-exited-with-error

  × Running setup.py install for editdistance did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      running install
      C:\Users\sv182c\work\mambaforge\envs\bellablue\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-39
      creating build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\__init__.py -> build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\_editdistance.h -> build\lib.win-amd64-cpython-39\editdistance
      copying editdistance\def.h -> build\lib.win-amd64-cpython-39\editdistance
      running build_ext
      building 'editdistance.bycython' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

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

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

Expected behavior Installation to succeed on Windows for Python 3.8 or 3.9, without having to install Microsoft C++ Build Tools.

Version (please complete the following information):

Additional information

The setup.py script for contextualSpellCheck has its editdistance dependency pinned to version 0.5.3. That release of editdistance only has prebuilt binary wheels for up to Python 3.7.

A newer release of editdistance, 0.6.0, contains no code changes but includes binary wheels for more versions of Python (up to 3.9).

So if the editdistance dependency version were simply relaxed to something like >= 0.5.3 or ~= 0.5, then pip would find the 0.6.0 release and use those pre-built binary wheels. Since there are no underlying code changes to that release of editdistance, that would be a simple and low-risk change for contextualSpellCheck.

R1j1t commented 2 years ago

Hi @tpanza Thank you for reporting the bug as well as proposing a solution! If you want, you can update the version in the below files and raise a PR. I will merge and release the change.

https://github.com/R1j1t/contextualSpellCheck/blob/750824dee1cdcc786e757ae0e75a87a538ea6338/setup.py#L34

https://github.com/R1j1t/contextualSpellCheck/blob/750824dee1cdcc786e757ae0e75a87a538ea6338/requirements.txt#L2

As there is no stable release for editdistance, please use the specific version (here 0.6.0).

confused-certainties commented 1 year ago

Hi

Wanted to check if this error had been resolved as I was getting this exact error on Python 3.11. Following that I downloaded and installed Microsoft Visual C++ 14.0 as well, but am getting the below error now instead.

Building wheels for collected packages: editdistance
  Building wheel for editdistance (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\editdistance
      copying editdistance\__init__.py -> build\lib.win-amd64-cpython-311\editdistance
      copying editdistance\_editdistance.h -> build\lib.win-amd64-cpython-311\editdistance
      copying editdistance\def.h -> build\lib.win-amd64-cpython-311\editdistance
      running build_ext
      building 'editdistance.bycython' extension
      creating build\temp.win-amd64-cpython-311
      creating build\temp.win-amd64-cpython-311\Release
      creating build\temp.win-amd64-cpython-311\Release\editdistance
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I./editdistance "-IC:\Users\gaurav.daftary_pures\My Drive\project_files\test\include" -IC:\Users\gaurav.daftary_pures\AppData\Local\Programs\Python\Python311\include -IC:\Users\gaurav.daftary_pures\AppData\Local\Programs\Python\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /EHsc /Tpeditdistance/_editdistance.cpp /Fobuild\temp.win-amd64-cpython-311\Release\editdistance/_editdistance.obj
      _editdistance.cpp
      editdistance/_editdistance.cpp(92): warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
      editdistance/_editdistance.cpp(120): note: see reference to function template instantiation 'unsigned int edit_distance_map_<1>(const int64_t *,const size_t,const int64_t *,const size_t)' being compiled
      editdistance/_editdistance.cpp(93): warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
      editdistance/_editdistance.cpp(44): warning C4018: '<=': signed/unsigned mismatch
      editdistance/_editdistance.cpp(98): note: see reference to function template instantiation 'unsigned int edit_distance_bpv<cmap_v,varr<1>>(T &,const int64_t *,const size_t &,const unsigned int &,const unsigned int &)' being compiled
              with
              [
                  T=cmap_v
              ]
      editdistance/_editdistance.cpp(120): note: see reference to function template instantiation 'unsigned int edit_distance_map_<1>(const int64_t *,const size_t,const int64_t *,const size_t)' being compiled
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I./editdistance "-IC:\Users\gaurav.daftary_pures\My Drive\project_files\test\include" -IC:\Users\gaurav.daftary_pures\AppData\Local\Programs\Python\Python311\include -IC:\Users\gaurav.daftary_pures\AppData\Local\Programs\Python\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /EHsc /Tpeditdistance/bycython.cpp /Fobuild\temp.win-amd64-cpython-311\Release\editdistance/bycython.obj
      bycython.cpp
      editdistance/bycython.cpp(216): fatal error C1083: Cannot open include file: 'longintrepr.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.36.32532\\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 editdistance
  Running setup.py clean for editdistance
Failed to build editdistance
ERROR: Could not build wheels for editdistance, which is required to install pyproject.toml-based projects