Это происходит как в Python 3.4.3 (вывод в этом выпуске из 3.4.3), так и в 2.7.9 с pip 7.1.0 в Alpine Linux 3.2 x64 в Docker 1.7.1 при компиляции psutil 3.1.1 ( pip install psutil==2.2.1
работает).
psutil/_psutil_linux.c: In function 'psutil_net_if_stats':
psutil/_psutil_linux.c:520:21: error: 'caddr_t' undeclared (first use in this function)
ifr.ifr_data = (caddr_t)ðcmd;
^
psutil/_psutil_linux.c:520:21: note: each undeclared identifier is reported only once for each function it appears in
Полный журнал:
Step 13 : RUN pip install psutil
---> Running in 532c9c1374d2
Collecting psutil
Downloading psutil-3.1.1.tar.gz (247kB)
Building wheels for collected packages: psutil
Running setup.py bdist_wheel for psutil
Complete output from command /usr/bin/python3 -c "import setuptools;__file__='/tmp/pip-build-zlgyqv29/psutil/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpbu50pa8fpip-wheel-:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-3.4/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-3.4/psutil
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/psutil
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSUTIL_VERSION=311 -I/usr/include/python3.4m -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-3.4/psutil/_psutil_linux.o
psutil/_psutil_linux.c: In function 'psutil_net_if_stats':
psutil/_psutil_linux.c:520:21: error: 'caddr_t' undeclared (first use in this function)
ifr.ifr_data = (caddr_t)ðcmd;
^
psutil/_psutil_linux.c:520:21: note: each undeclared identifier is reported only once for each function it appears in
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed to build psutil
Installing collected packages: psutil
Running setup.py install for psutil
Failed building wheel for psutil
Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-zlgyqv29/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yu0fgz74-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
running build_ext
building 'psutil._psutil_linux' extension
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSUTIL_VERSION=311 -I/usr/include/python3.4m -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-3.4/psutil/_psutil_linux.o
psutil/_psutil_linux.c: In function 'psutil_net_if_stats':
psutil/_psutil_linux.c:520:21: error: 'caddr_t' undeclared (first use in this function)
ifr.ifr_data = (caddr_t)ðcmd;
^
psutil/_psutil_linux.c:520:21: note: each undeclared identifier is reported only once for each function it appears in
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-zlgyqv29/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yu0fgz74-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-zlgyqv29/psutil
The command '/bin/sh -c pip install psutil' returned a non-zero code: 1
make: *** [build] Error 1
Похоже, это связано с тем, что Alpine Linux использует musl libc, а не glibc (https://github.com/metachris/RPIO/issues/40).
Ой, крик:
Step 14 : RUN pip install git+https://github.com/bkleef/psutil@patch-1
---> Running in 97d5a5ac261f
Collecting git+https://github.com/bkleef/psutil@patch-1
Cloning https://github.com/bkleef/psutil (to patch-1) to /tmp/pip-mq2e05rg-build
Installing collected packages: psutil
Running setup.py install for psutil
Successfully installed psutil-3.1.2
---> e2446aa584fb
Removing intermediate container 97d5a5ac261f
Successfully built e2446aa584fb
Если бы кто-нибудь мог просто поставить это исправление в 3.1.2.
Для меня решением для alpine 3.5 и psutil 5.1.3 было добавление apk для python3-dev. Фрагмент Dockerfile:
FROM alpine:3.5
RUN apk add --no-cache python3 && python3 -m ensurepip && rm -r /usr/lib/python*/ensurepip && pip3 install --upgrade pip setuptools && rm -r /root/.cache
RUN apk add --update build-base vim curl bash zip git linux-headers python3-dev py-psutil && rm -rf /var/cache/apk/*
благодаря jmjpro, я немного свернул его за python:3.7-alpine
и он по-прежнему работает нормально
RUN apk add --update gcc libc-dev fortify-headers linux-headers && rm -rf /var/cache/apk/*
Спасибо @armenic .
Но похоже, что fortify-headers
не нужны.
Так,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
отлично работает для python:3.7-alpine
.
Спасибо @armenic .
Но похоже, чтоfortify-headers
не нужны.Так,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
отлично работает дляpython:3.7-alpine
.
вау, спасибо ахахаххаахха ....
Спасибо @armenic .
Но похоже, чтоfortify-headers
не нужны.Так,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
отлично работает дляpython:3.7-alpine
.
Благодарю. работает также для python:3.8-alpine
Самый полезный комментарий
Спасибо @armenic .
Но похоже, что
fortify-headers
не нужны.Так,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
отлично работает для
python:3.7-alpine
.