On Wed, Oct 3, 2012 at 2:11 PM, Chris Barker <
chris....@noaa.gov> wrote:
> While I'm asking questions...
>
> Folks,
>
> I recently discovered the cythonize command for use in your setup.py.
>
> It looks like it gives some nice functionality, and also I like
> putting dependency-like information in the pyx, rather than in the
> setup.py. HOwever, a couple questions:
>
> The examples I've seen use hard-coded everything -- is it possible to
> make that dynamic?, for instance I need the numpy includes:
>
> np.get_include()
>
> Also -- other includes, libs, etc may be in different places on
> different systems -- a lot of setup.py's have code to search for
> stuff.
You should be able to do
cythonize(..., aliases={'NUMPY_INCLUDES': np.get_include()})
(untested, and just realized we don't even have a test for this either).
> What about different platforms -- there are a number of things we need
> to set up differently for Windows vs. *nix -- includes, libs, defines,
> etc. -- again, we can switch on that in a setup.py, but how would we
> do it with Cythonize?
cythonize() can take a list of Extension objects, which are used as a
template and overlayed to the information found in the sourcefiles.
You can set the name to "*" and the source to "[glob].pyx". This
allows you to split your logic to where it fits best (if you have
complicated, cross-module logic, perhaps it is better in the setup.py
file).
- Robert