dockerizing 期间无法在 alpine 上安装 pycosat

Uji*_*jin 3 python-3.x docker docker-compose alpine-linux

我正在尝试 dockerize django 应用程序,并且我使用alpine:edge作为基本图像。并且pycosat安装失败并出现错误

In file included from pycosat.c:19:
picosat.c:8150:10: fatal error: sys/unistd.h: No such file or directory
 #include <sys/unistd.h>
          ^~~~~~~~~~~~~~
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

这是我的 Dockerfile 的样子

FROM alpine:edge
    ENV PYTHONBUFFERED 1

    RUN apk update && \
        apk add --virtual build-deps gcc python3-dev musl-dev \
        libffi-dev openssl-dev python3 py3-zmq build-base libzmq zeromq-dev \
        curl g++ make zlib-dev linux-headers openssl ca-certificates libevent-dev

    RUN pip3 install --upgrade pip setuptools
    RUN mkdir /config
    ADD /config/requirements.txt /config/
    RUN easy_install pyzmq
    RUN easy_install pycosat
    RUN mkdir /src
    WORKDIR /src
Run Code Online (Sandbox Code Playgroud)

我怎样才能安装这个库?我是否错过了一些包或实用程序之类的东西?

我也使用 docker-compose 来构建它

val*_*ano 5

It seems pycosat is not compatible with musl, the libc library implementation used in Alpine.

musl's unistd.h header is located at the system headers root folder, /usr/include, and not under /usr/include/sys as in glibc (glibc is the defacto Linux libc standard), and therefore compilation fails with fatal error: sys/unistd.h: No such file or directory.

As a workaround, you could create your own header under sys/unistd.h which will simply include the native unistd.h, prior to pycosat build step:

RUN echo "#include <unistd.h>" > /usr/include/sys/unistd.h
Run Code Online (Sandbox Code Playgroud)