[IPython-dev] How did Cython magic know to include np.get_include()?

Yuxiang Wang yw5aj at virginia.edu
Fri Apr 3 23:09:27 EDT 2015


Aaaahh thanks! I was looking for this piece of code. This is exactly
what I am asking for. Thanks Nathan!

For future interested readers: in line 245, it says very clear that

if 'numpy' in code:
    import numpy
    c_include_dirs.append(numpy.get_include())

Shawn


On Fri, Apr 3, 2015 at 10:49 PM, Nathan Goldbaum <nathan12343 at gmail.com> wrote:
>
>
> On Fri, Apr 3, 2015 at 7:35 PM, Yuxiang Wang <yw5aj at virginia.edu> wrote:
>>
>> Hi all,
>>
>> When I use %%cython magic, it automatically knows to include the
>> np.get_include(), which works really great. But just being curious - how was
>> that achieved? Did the code detect whether numpy was imported, and if yes it
>> will add np.get_include to the include_dirs?
>>
>
> You may be interested in the implementation:
>
> https://github.com/cython/cython/blob/9e956fa59e3899a5fae06519d3ca9728db52adb0/Cython/Build/IpythonMagic.py#L192
>
>>
>> Shawn
>>
>> --
>> Yuxiang "Shawn" Wang
>> Gerling Research Lab
>> University of Virginia
>> yw5aj at virginia.edu
>> +1 (434) 284-0836
>> https://sites.google.com/a/virginia.edu/yw5aj/
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj at virginia.edu
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/



More information about the IPython-dev mailing list