Search code examples
pythonsetuptoolsdistutils

How to pass flags to a distutils extension?


I'm trying to install a Python module that contains C modules. The C code relies on a library being available in the system's global install locations (/usr/include, /usr/lib), but in my case I only have a local installation of this lib available. Therefore, I would like to pass parameters (e.g., --incdir, --libdir) when calling "setup.py build" so that these values end up in the setup script.

Is there a way to achieve this?


Solution

  • I found out that prepending

    CFLAGS="-I<local include dir>" LDFLAGS="-L<local lib dir>"
    

    to the command line when calling setup.py did the trick.