无法在 Alpine 上安装 uwsgi

Cannot install uwsgi on Alpine

我正在尝试在我的 Alpine docker 图像中使用 pip install uwsgi 安装 uwsgi,但不幸的是它总是失败,很奇怪,没有给我真正的错误消息:

Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-mEZegv/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-c7XA_e-record/install-record.txt --single-version-externally-managed --compile:
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include/fortify', '/usr/include', '/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/include']
    Patching "bin_name" to properly install_scripts dir
    detected CPU cores: 1
    configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION="\"2.0.12\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="12" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"core/utils.c: In function 'uwsgi_as_root':
    core/utils.c:344:7: error: implicit declaration of function 'unshare' [-Werror=implicit-function-declaration]
       if (unshare(uwsgi.unshare)) {
           ^
    core/utils.c:564:5: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
         sigfillset(&smask);
         ^
    core/utils.c:565:5: error: implicit declaration of function 'sigprocmask' [-Werror=implicit-function-declaration]
         sigprocmask(SIG_BLOCK, &smask, NULL);
         ^
    core/utils.c:565:17: error: 'SIG_BLOCK' undeclared (first use in this function)
         sigprocmask(SIG_BLOCK, &smask, NULL);
                     ^
    core/utils.c:565:17: note: each undeclared identifier is reported only once for each function it appears in
    core/utils.c:586:7: error: implicit declaration of function 'chroot' [-Werror=implicit-function-declaration]
       if (chroot(uwsgi.chroot)) {
           ^
    core/utils.c:791:5: error: unknown type name 'ushort'
         ushort *array;
         ^
    core/utils.c:833:8: error: implicit declaration of function 'setgroups' [-Werror=implicit-function-declaration]
        if (setgroups(0, NULL)) {
            ^
    core/utils.c:848:8: error: implicit declaration of function 'initgroups' [-Werror=implicit-function-declaration]
        if (initgroups(uidname, uwsgi.gid)) {
            ^
    core/utils.c: In function 'uwsgi_close_request':
    core/utils.c:1145:18: error: 'WAIT_ANY' undeclared (first use in this function)
       while (waitpid(WAIT_ANY, &waitpid_status, WNOHANG) > 0);
                      ^
    core/utils.c: In function 'uwsgi_resolve_ip':
    core/utils.c:1802:7: error: implicit declaration of function 'gethostbyname' [-Werror=implicit-function-declaration]
      he = gethostbyname(domain);
           ^
    core/utils.c:1802:5: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
      he = gethostbyname(domain);
         ^
    core/utils.c: In function 'uwsgi_unix_signal':
    core/utils.c:1936:19: error: storage size of 'sa' isn't known
      struct sigaction sa;
                       ^
    core/utils.c:1938:24: error: invalid application of 'sizeof' to incomplete type 'struct sigaction'
      memset(&sa, 0, sizeof(struct sigaction));
                            ^
    core/utils.c:1942:2: error: implicit declaration of function 'sigemptyset' [-Werror=implicit-function-declaration]
      sigemptyset(&sa.sa_mask);
      ^
    core/utils.c:1944:6: error: implicit declaration of function 'sigaction' [-Werror=implicit-function-declaration]
      if (sigaction(signum, &sa, NULL) < 0) {
          ^
    core/utils.c:1936:19: error: unused variable 'sa' [-Werror=unused-variable]
      struct sigaction sa;
                       ^
    In file included from core/utils.c:1:0:
    core/utils.c: In function 'uwsgi_list_has_num':
    ./uwsgi.h:140:47: error: implicit declaration of function 'strtok_r' [-Werror=implicit-function-declaration]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                   ^
    core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list2, ",", p, ctx) {
      ^
    ./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                  ^
    core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list2, ",", p, ctx) {
      ^
    ./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                                          ^
    core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list2, ",", p, ctx) {
      ^
    core/utils.c: In function 'uwsgi_list_has_str':
    ./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                  ^
    core/utils.c:1968:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list2, " ", p, ctx) {
      ^
    ./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                                          ^
    core/utils.c:1968:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list2, " ", p, ctx) {
      ^
    core/utils.c:1969:8: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
       if (!strcasecmp(p, str)) {
            ^
    core/utils.c: In function 'uwsgi_sig_pause':
    core/utils.c:2361:2: error: implicit declaration of function 'sigsuspend' [-Werror=implicit-function-declaration]
      sigsuspend(&mask);
      ^
    core/utils.c: In function 'uwsgi_run_command_putenv_and_wait':
    core/utils.c:2453:7: error: implicit declaration of function 'putenv' [-Werror=implicit-function-declaration]
       if (putenv(envs[i])) {
           ^
    In file included from core/utils.c:1:0:
    core/utils.c: In function 'uwsgi_build_unshare':
    ./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                  ^
    core/utils.c:2855:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list, ",", p, ctx) {
      ^
    ./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
     #define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
                                                                          ^
    core/utils.c:2855:2: note: in expansion of macro 'uwsgi_foreach_token'
      uwsgi_foreach_token(list, ",", p, ctx) {
      ^
    core/utils.c: In function 'uwsgi_tmpfd':
    core/utils.c:3533:7: error: implicit declaration of function 'mkstemp' [-Werror=implicit-function-declaration]
      fd = mkstemp(template);
           ^
    core/utils.c: In function 'uwsgi_expand_path':
    core/utils.c:3615:7: error: implicit declaration of function 'realpath' [-Werror=implicit-function-declaration]
      if (!realpath(src, dst)) {
           ^
    core/utils.c: In function 'uwsgi_set_cpu_affinity':
    core/utils.c:3641:3: error: unknown type name 'cpu_set_t'
       cpu_set_t cpuset;
       ^
    core/utils.c:3646:3: error: implicit declaration of function 'CPU_ZERO' [-Werror=implicit-function-declaration]
       CPU_ZERO(&cpuset);
       ^
    core/utils.c:3651:4: error: implicit declaration of function 'CPU_SET' [-Werror=implicit-function-declaration]
        CPU_SET(base_cpu, &cpuset);
        ^
    core/utils.c:3662:7: error: implicit declaration of function 'sched_setaffinity' [-Werror=implicit-function-declaration]
       if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
           ^
    core/utils.c:3662:35: error: 'cpu_set_t' undeclared (first use in this function)
       if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
                                       ^
    core/utils.c: In function 'uwsgi_thread_run':
    core/utils.c:3782:2: error: implicit declaration of function 'pthread_sigmask' [-Werror=implicit-function-declaration]
      pthread_sigmask(SIG_BLOCK, &smask, NULL);
      ^
    core/utils.c:3782:18: error: 'SIG_BLOCK' undeclared (first use in this function)
      pthread_sigmask(SIG_BLOCK, &smask, NULL);
                      ^
    core/utils.c: In function 'uwsgi_envdir':
    core/utils.c:4349:8: error: implicit declaration of function 'unsetenv' [-Werror=implicit-function-declaration]
        if (unsetenv(de->d_name)) {
            ^
    core/utils.c:4380:7: error: implicit declaration of function 'setenv' [-Werror=implicit-function-declaration]
       if (setenv(de->d_name, content, 1)) {
           ^
    cc1: all warnings being treated as errors

    *** uWSGI compiling server core ***

知道是什么原因造成的吗?我预先安装了以下依赖项:

RUN apk --update add \
        bash \
        python \
        python-dev \
        py-pip \
        gcc \
        zlib-dev \
        git \
        linux-headers \
        build-base \
        musl \
        musl-dev \
        memcached \
        libmemcached-dev

不幸的是,uwsgi 的最新版本不支持 musl,这是 alpine 和其他几个发行版使用的 glibc 替代品。当包含 ugreen 插件时,Uwsgi 将不会使用 musl 构建(参见 https://github.com/unbit/uwsgi/pull/522), so you still cannot pip install uwsgi. However, if you build uwsgi with the environment variable UWSGI_PROFILE=corethe build should succeed; but if will fail at runtime due to the issues solved here (https://github.com/unbit/uwsgi/pull/1210)。这可能是个坏消息——我知道这是给我的——但至少看起来 uwsgi 团队正在花时间解决它在 musl 上的问题 运行。希望它能在下一个版本中运行。

你试过了吗

http://github.com/unbit/uwsgi/archive/uwsgi-2.0.zip

在你的 requirements.txt ?

您需要安装 pcre-dev 软件包

我在 GitHub thread 上找到了这个。稍微修改了一下,在 Python 3.5

上对我来说工作得很好
apk add python3-dev build-base linux-headers pcre-dev
pip install uwsgi

这有点陈旧,OP 的情况并非如此。在我的例子中,将 requirements.txt 上的版本升级到 uwsgi==2.0.17.1 有效,因为我发现 here.

将 uWSGI 从 2.0.14 升级到 2.0.19.1 对我有用。