Running setup.py install for cffi did not run successfully.

4,829 views
Skip to first unread message

Prosper Lekia

unread,
Mar 8, 2022, 5:05:55 PM3/8/22
to python-cffi
I am trying to deploy my app to google cloud. Here's the error I'm having

 Running setup.py install for cffi: started
  Running setup.py install for cffi: finished with status 'error'
  error: subprocess-exited-with-error

  ? Running setup.py install for cffi did not run successfully.
  ? exit code: 1
  ??> [47 lines of output]

          No working compiler found, or bogus compiler options passed to
          the compiler from Python's standard "distutils" module.  See
          the error messages above.  Likely, the problem is not related
          to CFFI but generic to the setup.py of any Python package that
          tries to compile C code.  (Hints: on OS/X 10.8, for errors about
          -mno-fused-madd see http://stackoverflow.com/questions/22313407/
          Otherwise, see https://wiki.python.org/moin/CompLangPython or
          the IRC channel #python on irc.libera.chat.)

          Trying to continue anyway.  If you are trying to install CFFI from
          a build done in a different context, you can ignore this warning.

      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.9
      creating build/lib.linux-x86_64-3.9/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.9/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.9/cffi
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.9
      creating build/temp.linux-x86_64-3.9/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/venv/include -I/usr/local/include/python3.9 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.9/c/_cffi_backend.o
      error: command 'gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

? Encountered error while trying to install package.
??> cffi

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1


Here's my Dockfile.
# pull official base image
FROM python:3.9.0-alpine As builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"

# install dependencies
RUN pip install --upgrade pip
RUN pip install pipenv
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY ./Pipfile /usr/src/app/Pipfile

# RUN pipenv install -e --skip-lock --system --dev
# copy project
RUN apt-get update && apt-get upgrade -y && apt-get install gcc
COPY . /usr/src/app/
# final stage
FROM python:3.9-alpine
COPY --from=builder /venv /venv
WORKDIR /usr/src/app
ENV PATH="/venv/bin:$PATH"
# run development server
CMD python ./django_on_cloudrun/manage.py runserver 0.0.0.0:$PORT

ste...@rivera.za.net

unread,
Mar 8, 2022, 6:13:38 PM3/8/22
to pytho...@googlegroups.com, Prosper Lekia
Hi Prosper (2022.03.08_22:05:55_+0000)
> gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall
> -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi
> -I/venv/include -I/usr/local/include/python3.9 -c c/_cffi_backend.c -o
> build/temp.linux-x86_64-3.9/c/_cffi_backend.o
> error: command 'gcc' failed: No such file or directory

^ There's the problem. You need to install gcc.

> Here's my Dockfile.
> # pull official base image
> FROM python:3.9.0-alpine As builder
> # set work directory
> WORKDIR /usr/src/app
> # set environment variables
> ENV PYTHONDONTWRITEBYTECODE 1
> ENV PYTHONUNBUFFERED 1
>
> RUN python -m venv /venv
> ENV PATH="/venv/bin:$PATH"
>
> # install dependencies
> RUN pip install --upgrade pip
> RUN pip install pipenv
> COPY requirements.txt requirements.txt
> RUN pip install -r requirements.txt
> COPY ./Pipfile /usr/src/app/Pipfile
>
> # RUN pipenv install -e --skip-lock --system --dev
> # copy project
> RUN apt-get update && apt-get upgrade -y && apt-get install gcc

It looks like you are installing it, but only after you need it. The pip
command above is requiring it.

SR

--
Stefano Rivera
http://tumbleweed.org.za/
+1 415 683 3272
Reply all
Reply to author
Forward
0 new messages