langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
49.68k stars 7.1k forks source link

`poetry install` failed with error about gmpy2 #9355

Open saifeiLee opened 1 week ago

saifeiLee commented 1 week ago

Self Checks

Dify version

recently

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. start project in vscode with devcontainer
  2. the devcontainer building process will end up with a error message like this:

    
    Package operations: 1 install, 0 updates, 0 removals
    
    - Installing gmpy2 (2.2.1): Failed
    
    ChefBuildError
    
    Backend subprocess exited when trying to invoke build_wheel
    
    running bdist_wheel
    running build
    running build_py
    creating build/lib.linux-aarch64-cpython-310/gmpy2
    copying gmpy2/__init__.py -> build/lib.linux-aarch64-cpython-310/gmpy2
    running egg_info
    writing gmpy2.egg-info/PKG-INFO
    writing dependency_links to gmpy2.egg-info/dependency_links.txt
    writing requirements to gmpy2.egg-info/requires.txt
    writing top-level names to gmpy2.egg-info/top_level.txt
    reading manifest file 'gmpy2.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    adding license file 'COPYING'
    adding license file 'COPYING.LESSER'
    writing manifest file 'gmpy2.egg-info/SOURCES.txt'
    copying gmpy2/__init__.pxd -> build/lib.linux-aarch64-cpython-310/gmpy2
    copying gmpy2/gmpy2.h -> build/lib.linux-aarch64-cpython-310/gmpy2
    copying gmpy2/gmpy2.pxd -> build/lib.linux-aarch64-cpython-310/gmpy2
    running build_ext
    building 'gmpy2.gmpy2' extension
    creating build/temp.linux-aarch64-cpython-310/src
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/tmpf3uh8tfo/.venv/include -I/usr/local/include/python3.10 -c src/gmpy2.c -o build/temp.linux-aarch64-cpython-310/src/gmpy2.o -DSHARED=1
    In file included from src/gmpy2.c:112:
    src/gmpy2.h:77:10: fatal error: mpfr.h: No such file or directory
     77 | #include <mpfr.h>
        |          ^~~~~~~~
    compilation terminated.
    error: command '/usr/bin/gcc' failed with exit code 1
    
    at /usr/local/py-utils/venvs/poetry/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with gmpy2 (2.2.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "gmpy2 (==2.2.1)"'.


If you run `poetry install` in terminal. You will reproduce same error.

### ✔️ Expected Behavior

`poetry install` should run successfully.

### ❌ Actual Behavior

Install error about `gmpy2`.
dosubot[bot] commented 1 week ago

To resolve the poetry install error related to gmpy2, ensure that the necessary system dependencies for gmpy2 are installed. The error message indicates that the mpfr.h file is missing, which is part of the libmpfr-dev package. Make sure your devcontainer setup includes the installation of this package. According to the Dockerfile used in the Dify project, the required packages should be installed with the following command:

RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev

Verify that this part of the Dockerfile is executed correctly in your devcontainer setup. If the error persists, check that the apt-get update and apt-get install commands complete successfully without errors during the build process [1].

To continue talking to Dosu, mention @dosu.

saifeiLee commented 1 week ago

Run command:

sudo apt-get install -y --no-install-recommends gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev

can fix this error. But devconatiner init should handle it properly.