在 dockerizing 期间无法在 alpine 上安装 pycosat

Cannot install pycosat on alpine during dockerizing

我正在尝试 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

这是我的 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

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

我也在使用 docker-compose 来构建它

pycosat 似乎与 musl 不兼容,musl 是 Alpine 中使用的 libc 库实现。

musl 的 unistd.h header 位于系统 header 的根文件夹 /usr/include 中,而不是像 glibc 中那样在 /usr/include/sys 下(glibc 是事实上的 Linux libc 标准),因此编译失败 fatal error: sys/unistd.h: No such file or directory.

作为一种解决方法,您可以在 sys/unistd.h 下创建自己的 header,这将在 pycosat 构建步骤之前简单地包含本机 unistd.h

RUN echo "#include <unistd.h>" > /usr/include/sys/unistd.h