fiaisis / FIA-API

ReST API for FIA
GNU General Public License v3.0
0 stars 1 forks source link

psycopg2 dependency doesn't support all platforms, replace with psycopg2-binary #340

Open HumzahJavid opened 1 month ago

HumzahJavid commented 1 month ago

Description of the issue

The install log attached at the bottom of this issue was carried out on a WSL2 instance running ubuntu 22.02 on a windows 10 machine (whilst working on the admin-portal integrations with FIA-API) The "psycopg2" package threw the following error. This was resolved by replacing it with a non pinned version of "psycopg2-binary"

Recommendation to replace psycopg2 with psycopg2-binary in the pyproject.toml file see stack overflow solution. See https://github.com/fiaisis/FIA-API/issues/340#issuecomment-2188495107

/home/FIA-API$ pip install .

Processing /home/FIA-API

  Installing build dependencies ... done

  Getting requirements to build wheel ... done

    Preparing wheel metadata ... done

Collecting fastapi[all]==0.110.2

  Downloading fastapi-0.110.2-py3-none-any.whl (91 kB)

     |████████████████████████████████| 91 kB 3.8 MB/s

Collecting psycopg2==2.9.9

  Downloading psycopg2-2.9.9.tar.gz (384 kB)

     |████████████████████████████████| 384 kB 10.6 MB/s

    ERROR: Command errored out with exit status 1:

     command: /home/FIA-API/.venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nmtj8xt4/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nmtj8xt4/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info

         cwd: /tmp/pip-install-nmtj8xt4/psycopg2/

    Complete output (23 lines):

    running egg_info

    creating /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info

    writing /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO

    writing dependency_links to /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt

    writing top-level names to /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt

    writing manifest file '/tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory

    containing pg_config to the $PATH or specify the full executable path with the

    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI

    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at

    <[https://www.psycopg.org/docs/install.html>).](https://www.psycopg.org/docs/install.html%3E).)

    ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
keiranjprice101 commented 1 month ago

From https://www.psycopg.org/docs/install.html#psycopg-vs-psycopg-binary the binary is only reccomended for development. A better solution could be to make a note of the binary version in the docs for development purposes only.

Warning

The psycopg2 wheel package comes packaged, among the others, with its own libssl binary. This may create conflicts with other extension modules binding with libssl as well, for instance with the Python ssl module: in some cases, under concurrency, the interaction between the two libraries may result in a segfault. In case of doubts you are advised to use a package built from source.