AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

Necessary documentation for error while running `poetry install`: Building wheel for pysqlite3 (pyproject.toml) did not run successfully. #39

Closed simojo closed 11 months ago

simojo commented 1 year ago

After running poetry install in the root directory of this project, I encoutered the following error:

    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Building wheels for collected packages: pysqlite3
    Building wheel for pysqlite3 (pyproject.toml): started
    Building wheel for pysqlite3 (pyproject.toml): finished with status 'error'
    error: subprocess-exited-with-error

    × Building wheel for pysqlite3 (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [20 lines of output]
  • Installing flatterer (0.19.8): Installing...
  • Installing hypofuzz (23.7.1)
  • Installing hypothesis-jsonschema (0.22.1)
  • Installing isort (5.12.0)
  • Installing mypy (1.4.1)
  • Installing pyastgrep (1.2.2)
  • Installing pydantic (2.0.3)
  • Installing pysqlite3 (0.5.1): Failed

...

    × Building wheel for pysqlite3 (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [20 lines of output]
        running bdist_wheel
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-cpython-311
        creating build/lib.linux-x86_64-cpython-311/pysqlite3
        copying pysqlite3/dbapi2.py -> build/lib.linux-x86_64-cpython-311/pysqlite3
        copying pysqlite3/__init__.py -> build/lib.linux-x86_64-cpython-311/pysqlite3
        running build_ext
        Builds a C extension linking against libsqlite3 library
        building 'pysqlite3._sqlite3' extension
        creating build/temp.linux-x86_64-cpython-311
        creating build/temp.linux-x86_64-cpython-311/src
        gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/nix/store/vshdx1ds1rmpl4by04i2g807zvkqyq8q-libxcrypt-4.4.33/include -fPIC -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -I/home/simon/.cache/pypoetry/virtualenvs/chasten-LtXvhvXr-py3.11/include -I/nix/store/l87x5cpmxpfxb93nl4madnr4mmmlvhy4-python3-3.11.1/include/python3.11 -c src/blob.c -o build/temp.linux-x86_64-cpython-311/src/blob.o
        In file included from src/blob.c:1:
        src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
            4 | #include "sqlite3.h"
              |          ^~~~~~~~~~~
        compilation terminated.
        error: command '/nix/store/1y8i61anhs9hh1g5x3zw2fvdbivwixzg-gcc-wrapper-11.3.0/bin/gcc' 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 pysqlite3
  Failed to build pysqlite3
  ERROR: Could not build wheels for pysqlite3, which is required to install pyproject.toml-based projects

The same error is repeated numerous times in the output, because it propagates to many parts of the project. I'm leaving out the other repeated error messages. The last blurb would indicate to me that the problem is because poetry can't find the development headers for sqlite3:

src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
            4 | #include "sqlite3.h"
              |          ^~~~~~~~~~~

This was solved by the following:

Solution (NixOS)

Install pkgs.sqlite.dev to add the directory holding sqlite3.h to $CMAKE_INCLUDE_DIRS.

Solution (Ubuntu)

Install libsqlite3-dev to add the directory holding sqlite3.h to $CMAKE_INCLUDE_DIRS.

Proposed solution

Either include in documentation that sqlite3 dev files are required, or automate this.

gkapfham commented 1 year ago

Hi @simojo, thanks for bringing this problem to our attention!

It may be possible for us to not use the pysqlite3 dependency and still get the main features of chasten to work correctly. This could potentially resolve this issue and ensure that it is easier for others to quickly and easily install the tool.

With that said, more testing would need to be done to ensure that the features of pysqlite3 are not absolutely needed. My recollection is that the package was added so that we could use some SQLite 3 extensions that were used by one or more of the datasette plugins!

Ultimately, we need to task someone on on team with investigating this issue on three platforms and ensuring that we can either (a) write installation instructions for every platform to ensure a smooth install or (b) remove this dependency and make installation easier by default.

Finally, it is worth noting that we cannot remove some of the dependencies for the chasten tool! For instance, we need to keep the dependency on Datasette because that it what we use to create the web-based dashboard of the data that we collect.

AlishChhetri commented 1 year ago

I ran into a similar issue. After running "pipx install chasten", I received the following error:

Fatal error from pip prevented installation. Full pip output in file:
    /home/chhetri01/.local/pipx/logs/cmd_2023-08-30_12.33.49_pip_errors.log

pip failed to build package:
    pysqlite3

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
    error: command '/usr/bin/gcc' failed with exit code 1

Error installing chasten.

I solved the issue by running the following command:

sudo apt-get install -y libsqlite3-dev

After installing that dependency, I ran pipx install chasten to install chasten, then I cloned the chasten repo, and finally ran poetry install.

I did not run into the same issue presented by @simojo after running the poetry install command using this approach.

gkapfham commented 1 year ago

Hi, if you have experienced a similar issue with MacOS or Windows, can you please share more details here?

gkapfham commented 12 months ago

What is the status on this issue? Can we either resolve it, document a fix, link it to another issue or close it forthwith?

simojo commented 11 months ago

If PR #47 is agreed to pass, it will close this issue and no documentation is needed. However, if we decide PR #47 cannot be merged, then this issue will need to be looked at to create documentation during the install steps. I will trigger PR #47 to automatically close this issue if passed.

hayleepierce commented 11 months ago

PR #47 was merged. Can this issue be closed?

simojo commented 11 months ago

@hayleepierce yes, this can be closed.