C/C++ inlining in Python (scipy.weave.inline fails on Windows with MinGW)

Python is marvellous, but sometimes a little slow on number-crunching large arrays. So <code>scipy.weave.inline</code> comes in pretty handy when inlining c/c++ code to process numpy arrays.

However (there is always a however), with recent numpy/scipy installations the compile-process for the c/c++ code fails on Windows (using MinGW32 compiler) because first the VisualStudio libmsvcr90.a library is build and that one conflicts with the mingw-libs. The issue looks like this:

I found a workaround for that (works for Python(x,y) standard installation): Let the building of libmsvcr90.a fail!

  • Open C:\Python27\Lib\site-packages\numpy\distutils\mingw32ccompiler.py
  • In function build_msvcr_library  (around line 330) make an early  return False

  •  If it is not your first try you will have to delete the falsely build VisualStudio-Libs

Now all should work fine!

4 thoughts on “C/C++ inlining in Python (scipy.weave.inline fails on Windows with MinGW)

  1. Hi y’all,

    I tried to make an early return False,

    but then got an error about the next line in the code. I’m not exactly sure what ‘make an early return False’ means.
    I’m new to python, so please correct me if i understood something wrong.


  2. Hi Juliette,

    with “make an early return False” I meant: insert one single line of code :

    as the first statement of the function so that it does virtually nothing but return immediately stating “False” as its result.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">