karlb / sqlite-spellfix

Loadable spellfix1 extension for sqlite as python package
MIT License
25 stars 8 forks source link

Compiling on Windows 10 #1

Open kutschkem opened 2 years ago

kutschkem commented 2 years ago

When trying to install sqlite-spellfix via pypi, I get the following output:

Collecting sqlite-spellfix
  Using cached sqlite-spellfix-1.0.tar.gz (27 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: sqlite-spellfix
  Building wheel for sqlite-spellfix (setup.py): started
  Building wheel for sqlite-spellfix (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'c:\legacyapp\python36\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"'; __file__='"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\uidj1662\AppData\Local\Temp\pip-wheel-xt_946uz'
       cwd: C:\Users\uidj1662\AppData\Local\Temp\pip-install-1wkorcj8\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  copying sqlite_spellfix.py -> build\lib.win-amd64-3.6
  running build_ext
  building 'spellfix1' extension
  creating build\temp.win-amd64-3.6
  creating build\temp.win-amd64-3.6\Release
  c:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\legacyapp\python36\include -Ic:\legacyapp\python36\include "-Ic:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ic:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcspellfix.c /Fobuild\temp.win-amd64-3.6\Release\spellfix.obj
  spellfix.c
  spellfix.c(17): fatal error C1083: Cannot open include file: 'sqlite3ext.h': No such file or directory
  error: command 'c:\\LegacyApp\\Microsoft Visual Studio\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for sqlite-spellfix
  Running setup.py clean for sqlite-spellfix
Failed to build sqlite-spellfix
Installing collected packages: sqlite-spellfix
    Running setup.py install for sqlite-spellfix: started
    Running setup.py install for sqlite-spellfix: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: 'c:\legacyapp\python36\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"'; __file__='"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\uidj1662\AppData\Local\Temp\pip-record-3b559fus\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\legacyapp\python36\Include\sqlite-spellfix'
         cwd: C:\Users\uidj1662\AppData\Local\Temp\pip-install-1wkorcj8\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\
    Complete output (16 lines):
    running install
    c:\legacyapp\python36\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      setuptools.SetuptoolsDeprecationWarning,
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying sqlite_spellfix.py -> build\lib.win-amd64-3.6
    running build_ext
    building 'spellfix1' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    c:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\legacyapp\python36\include -Ic:\legacyapp\python36\include "-Ic:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ic:\LegacyApp\Microsoft Visual Studio\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcspellfix.c /Fobuild\temp.win-amd64-3.6\Release\spellfix.obj
    spellfix.c
    spellfix.c(17): fatal error C1083: Cannot open include file: 'sqlite3ext.h': No such file or directory
    error: command 'c:\\LegacyApp\\Microsoft Visual Studio\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\legacyapp\python36\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"'; __file__='"'"'C:\\Users\\uidj1662\\AppData\\Local\\Temp\\pip-install-1wkorcj8\\sqlite-spellfix_405ffd966c0c4b059d974ca2289434d5\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\uidj1662\AppData\Local\Temp\pip-record-3b559fus\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\legacyapp\python36\Include\sqlite-spellfix' Check the logs for full command output.

I am using Python 3.6 on Windows 10. I see the missing include is the error, but don't know what to do about it.

spellfix.c(17): fatal error C1083: Cannot open include file: 'sqlite3ext.h': No such file or directory

kodmarcel commented 2 years ago

Probably not gonna help you, but for reference. I had the same problem on Kali Linux and found out that it is caused by sqlite3ext.h not being provided in the sqlite package. Solved it by running

apt-file search sqlite3ext

and then based on the results installing libsqlite3-dev package which provides sqlite3ext.h Afterwards i was able to do pip install normally. On my Arch machine everything worked out of the box as sqlite package provides sqlite3ext by default.

So my assumption is you have to find a way to install sqlite in a way that provides the sqlite3ext shared file, or download it from sqlite sources and add it to a place where your compiler will find it.

rmitsch commented 2 years ago

I'm encountering the same issue on Windows. I'll look into this and update here if I find a solution. Hints are appreciated :slightly_smiling_face:

kutschkem commented 2 years ago

@rmitsch I didn't find a solution, but my workaround was this instead of using spellfix (I wanted to spellfix to get some string distance measure):

from Levenshtein import distance as levenshtein_distance

con.create_function('levenshtein',2,levenshtein_distance)

cur.execute("""
SELECT file_origin.filename, 
                        file_origin.original_path, 
                        file_migrated.new_path,
                        levenshtein(original_path,new_path) as levenshtein_dist
                     FROM file_origin
                     JOIN file_migrated
                     ON file_origin.filename = file_migrated.filename
""")
rmitsch commented 2 years ago

@kutschkem Thanks for the reply! I was thinking of custom functions too, but they are nowhere near the runtime performance with spellfix1 in my experience (and performance is critical for my use case, unfortunately).