Updating Ansible On Babun

On most platforms with pip, updating Ansible is as simple as:

$ pip install -U ansible

However, on babun, I received the following error:

[...]
/usr/include/sys/time.h:104:34: error: unknown type name ‘u_int’
[...]
    error: command 'gcc' failed with exit status 1

        ----------------------------------------
          Rolling back uninstall of pycrypto
          Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-eY8zz7/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-iUMqxd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-eY8zz7/pycrypto/

To track down the error, I grep‘d’ through the header files in /usr/include/sys which lead me to:

  • sys/types.h: Where u_int is defined if ___BSD_VISIBLE is set.
  • sys/features.h: Where __BSD_VISIBLE is defined if the _DEFAULT_SOURCE FTM (feature test macro) is set.

Running the pip command with the appropriate CFLAGS environment variable completes without an issue:

$ CFLAGS="-D_DEFAULT_SOURCE" pip install -U ansible

If you are unfamiliar with glibc FTMs, here are some good resources to check out: