Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error in psutil/_psutil_linux.c:520:21 #664

Closed
bkleef opened this issue Aug 4, 2015 · 8 comments
Closed

Compilation error in psutil/_psutil_linux.c:520:21 #664

bkleef opened this issue Aug 4, 2015 · 8 comments
Labels

Comments

@bkleef
Copy link
Contributor

bkleef commented Aug 4, 2015

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)&ethcmd;
                     ^
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)&ethcmd;
                       ^
  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)&ethcmd;
                         ^
    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
@bkleef
Copy link
Contributor Author

bkleef commented Aug 4, 2015

Looks like this has to do with the fact that Alpine Linux is using musl libc and not glibc (metachris/RPIO#40).

@bkleef
Copy link
Contributor Author

bkleef commented Aug 4, 2015

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.

giampaolo added a commit that referenced this issue Aug 4, 2015
Fix #664 by compiling on musl libc
openstack-gerrit pushed a commit to openstack/monasca-agent that referenced this issue Feb 3, 2017
This bumps the psutil requirement to >= 3.0.1 to match the new upper
constraint in the global requirements [1]. This also removes the local
capping of psutil to version 3.0.1.

Removing the 3.0.1 cap is also necessary to run the agent in
environments using the musl libc, such as Alpine Linux, due to an issue
resolved in more recent releases [2].

[1]: https://review.openstack.org/#/c/420837/
[2]: giampaolo/psutil#664

Change-Id: If811db1aeac7cb7b37c710f1ba79568d7beb101f
openstack-gerrit pushed a commit to openstack/openstack that referenced this issue Feb 11, 2017
Project: openstack/requirements  795a708517b41f6d64d4f86a04cbf4ce52b9c478

Update global-requirements for psutil to 3.2.2

In order to run monasca-agent in environments using the musl libc
such as Alpine Linux, we need psutil>=3.2.2 due to an issue in the
old release [1].

[1]: giampaolo/psutil#664

Change-Id: I76570d36648cde2838982542bc4fa2b65d12715f
openstack-gerrit pushed a commit to openstack/requirements that referenced this issue Feb 11, 2017
In order to run monasca-agent in environments using the musl libc
such as Alpine Linux, we need psutil>=3.2.2 due to an issue in the
old release [1].

[1]: giampaolo/psutil#664

Change-Id: I76570d36648cde2838982542bc4fa2b65d12715f
openstack-gerrit pushed a commit to openstack/openstack that referenced this issue Feb 11, 2017
Project: openstack/requirements  795a708517b41f6d64d4f86a04cbf4ce52b9c478

Update global-requirements for psutil to 3.2.2

In order to run monasca-agent in environments using the musl libc
such as Alpine Linux, we need psutil>=3.2.2 due to an issue in the
old release [1].

[1]: giampaolo/psutil#664

Change-Id: I76570d36648cde2838982542bc4fa2b65d12715f
@jmjpro
Copy link

jmjpro commented Feb 15, 2017

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/*

@ghost
Copy link

ghost commented Feb 3, 2019

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/*

@shinbero
Copy link

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.

@fantasyhh
Copy link

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.

wow , thanks ahahahhaahha ....

@jossef
Copy link

jossef commented Apr 19, 2020

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.

thanks. works also for python:3.8-alpine

@brando90
Copy link

brando90 commented Sep 8, 2022

related: dask/dask-kubernetes#238

tanaypf9 pushed a commit to tanaypf9/pf9-requirements that referenced this issue May 20, 2024
In order to run monasca-agent in environments using the musl libc
such as Alpine Linux, we need psutil>=3.2.0 due to an issue in the
old release [1].

[1]: giampaolo/psutil#664

Change-Id: I76570d36648cde2838982542bc4fa2b65d12715f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants