Issue: Install fails if sqlite3 headers not present
Author: fungs
State: closed
Created: 2019-10-08 16:22:19

For latest version 0.11.2 and Python 3.5.2 installing with pip on Linux 64bit does give an exit status of 1 instead of installing without sqlite3 module. On the same system, `import sqlite3` works fine, only development files are missing.

pip install peewee
```
Collecting peewee
  Using cached https://files.pythonhosted.org/packages/90/58/04bc705057694cac14c5c9a00dc83a80aafa1de27785227d3ee245cd4165/peewee-3.11.2.tar.gz
    Complete output from command python setup.py egg_info:
    /tmp/tmp_pw_sqlite3_3umvosqx/test_pw_sqlite3.c:1:21: fatal error: sqlite3.h: No such file or directory
    compilation terminated.
    /tmp/pip-install-01ifbd7u/peewee/setup.py:100: UserWarning: Could not find libsqlite3, SQLite extensions will not be built.
      warnings.warn('Could not find libsqlite3, SQLite extensions will not '
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-01ifbd7u/peewee/setup.py", line 162, in <module>
        _do_setup(extension_support, sqlite_extension_support)
      File "/tmp/pip-install-01ifbd7u/peewee/setup.py", line 157, in _do_setup
        ext_modules=cythonize(ext_modules))
      File "/databricks/python/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 799, in cythonize
        aliases=aliases)
      File "/databricks/python/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 689, in create_extension_list
        raise TypeError(msg)
    TypeError: pattern is not of type str nor subclass of Extension (<class 'setuptools.extension.Extension'>) but of type <class 'NoneType'> and class <class 'NoneType'>
    unable to compile sqlite3 C extensions - missing headers?
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-01ifbd7u/peewee/
```

Similar if you disable sqlite3 detection using `NO_SQLITE=1`
```

Collecting peewee
  Using cached https://files.pythonhosted.org/packages/90/58/04bc705057694cac14c5c9a00dc83a80aafa1de27785227d3ee245cd4165/peewee-3.11.2.tar.gz
    Complete output from command python setup.py egg_info:
    /tmp/pip-install-sdbh8yg2/peewee/setup.py:98: UserWarning: SQLite extensions will not be built at users request.
      warnings.warn('SQLite extensions will not be built at users request.')
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-sdbh8yg2/peewee/setup.py", line 162, in <module>
        _do_setup(extension_support, sqlite_extension_support)
      File "/tmp/pip-install-sdbh8yg2/peewee/setup.py", line 157, in _do_setup
        ext_modules=cythonize(ext_modules))
      File "/databricks/python/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 799, in cythonize
        aliases=aliases)
      File "/databricks/python/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 689, in create_extension_list
        raise TypeError(msg)
    TypeError: pattern is not of type str nor subclass of Extension (<class 'setuptools.extension.Extension'>) but of type <class 'NoneType'> and class <class 'NoneType'>
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-sdbh8yg2/peewee/
```

Only way around is to install libsqlite3-dev package on Debian based systems, which is not an option in some environments.

Looks like you have cython installed, but perhaps it is not compatible with Python 3.5? This error looks to be cython-related rather than anything else (to me).

Sqlite does show an error that it couldn't build the sqlite extensions, but it is not a fatal error. The actual error that is causing the install to fail is related to cython:

https://github.com/cython/cython/issues/1507

You are probably right about the error being in Cython but it is triggered by peewee install and does not fail if sqlite3 headers are present. Do you know what other Cython extensions are build when installing peewee that might be affected. My logic suggests that the Cython error indirectly results from trying to build the sqlite3 extension which fails. Also the issue you referenced is from 2016 and probably already fixed and has to do with bad combination of Cython and setuptools, which could also be an issue here. I can try to dig into it, any suggestions?

What version of Cython are you using? I figured if you're on python 3.5, it might be likely your Cython is also old.

I will come back with more details. This is a DataBricks enterprise pre-configured environment using interactive notebooks, so it needs some investigation. That being said, it's not unlikely that there is some kind of misconfiguration.

Should be easy to determine the cython version.

Cython is 0.24.1 which indeed was released Jul 15, 2016. Likely that this bug is in Cython, but why is it called when I disable C extension building?


> Cython is 0.24.1

Me:

> This error looks to be cython-related rather than anything else (to me).

If you have cython, peewee tries to cythonize the extensions. It catches a build error, but not this particular cython bug. Just update cython.

Ok thanks! This is a legacy environment where I cannot update Cython (it is a static containerized environment). Too bad that the Cython build cannot be disabled in the first place.