0

Sorry for being new to Anaconda (and Cython).

I used Anaconda 64-bit Python 3.4 Windows.

Where did Anaconda do all these settings for Cython? I have a test code called cy_test.pyx as follows:

import numpy as np

cpdef double [:] func():
    cdef double [:] a = np.arange(10.)
    return a

And then, Instead of

import pyximport, numpy
pyximport.install(setup_args={"script_args":["--compiler=mingw32"], "include_dirs":numpy.get_include()})

I only need to run import pyximport; pyximport.install(). Then I can use

import test_cy
a = test_cy.func()
print(list(a))

It just worked, without me telling it to include the numpy.get_include().

My question is, where is this being set? There should be a configuration file somewhere, right?

-Shawn

Yuxiang Wang
  • 8,095
  • 13
  • 64
  • 95

1 Answers1

2

import numpy is just a regular import. Unless you do cimport numpy Cython doesn't treat this specially (it doesn't import headers or other compile-time files), thus there's nothing special to include.

I very much doubt there is any special feature Anaconda is doing.

If you want to configure pyximport, you can make a pxybld file, such as when you want to support C++ with pyximport.

Community
  • 1
  • 1
Veedrac
  • 58,273
  • 15
  • 112
  • 169
  • `import numpy` itself is just a regular import. The part that is weird is it is not necessary to add `np.get_include()` to `"include_dirs"` in the `pyximport.install()`, as stated in the question. – Yuxiang Wang Oct 01 '14 at 18:15
  • OMG you are right! I am sorry that I did not first understand your answer. I apologize for the downvote and will cancel it once I am allowed (after 2 hours). – Yuxiang Wang Oct 01 '14 at 20:22
  • No hard feelings; glad I could help :). – Veedrac Oct 01 '14 at 20:32
  • 2
    @ShawnWang Something to note here, in the past, I've had to set up a 'distutils.cfg' file in /Lib/distutils to get pyximport working. Anaconda already has that set up with an entry that tells Python's distutils to use MinGW for compilation by default. – IanH Oct 03 '14 at 05:14