This occurs both in Python 3.4.3 (output in this issue is from 3.4.3) and 2.7.9 with pip 7.1.0 on Alpine Linux 3.2 x64 in Docker 1.7.1 while compiling psutil 3.1.1 (pip install psutil==2.2.1
works).
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
Full log:
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
Looks like this has to do with the fact that Alpine Linux is using musl libc and not glibc (https://github.com/metachris/RPIO/issues/40).
Whoop whoop:
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
If somebody could just put this fix in 3.1.2.
For me the solution for alpine 3.5 and psutil 5.1.3 was to add the apk for python3-dev. Dockerfile snippet:
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/*
thanks to jmjpro, I minimized it a little bit for python:3.7-alpine
and it still works fine
RUN apk add --update gcc libc-dev fortify-headers linux-headers && rm -rf /var/cache/apk/*
Thank you @armenic .
But it seems fortify-headers
is not needed.
So,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
works fine for python:3.7-alpine
.
Thank you @armenic .
But it seemsfortify-headers
is not needed.So,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
works fine forpython:3.7-alpine
.
wow , thanks ahahahhaahha ....
Thank you @armenic .
But it seemsfortify-headers
is not needed.So,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
works fine forpython:3.7-alpine
.
thanks. works also for python:3.8-alpine
Most helpful comment
Thank you @armenic .
But it seems
fortify-headers
is not needed.So,
RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
works fine for
python:3.7-alpine
.