[Distutils] pip can't find header file for extension module, but `python setup.py install` works fine

AJ Friend ajfriend at gmail.com
Sun May 31 23:07:01 CEST 2015


I'm trying to write a new `setup.py` file for an extension module to
wrap a C library (https://github.com/cvxgrp/scs).

The current `setup.py` file imports numpy. I'm trying to delay that
import statement until setuptools has a chance to install numpy if
it's not already installed. I'm trying to do that with this bit of

from setuptools.command.build_ext import build_ext as _build_ext
class build_ext(_build_ext):
    def finalize_options(self):
        # Prevent numpy from thinking it is still in its setup process:
        __builtins__.__NUMPY_SETUP__ = False
        import numpy
        self.include_dirs += ext['include_dirs'] + [numpy.get_include()]

Running `python setup.py install` seems to work fine on my OSX
machine, but when I run `pip install .` in the directory with
`setup.py`, I get a clang error that it can't find one of the header

Any idea why that would be happening? Could it have anything to do
with the relative path I'm giving for the include directories?

Also, I had trouble finding good documentation on subclassing
build_ext. Does anyone know if setting self.include_dirs overwrites or
appends to the include_dirs attribute of an Extension object defined
later in setup.py?

For the curious, my current attempt at setup.py is
athttps://github.com/ajfriend/scs/blob/setup2/python/setup.py. The
original can be found in the same directory.

More generally, since I'm new to python packaging, I'm not sure how
well or correctly I've written my `setup.py` file. Any feedback on
doing things correctly would be appreciated.


More information about the Distutils-SIG mailing list