Mingwpy distribution

What is it?

mingwpy is a mingw-w64 gcc toolchain customized for building Python extensions.

See Issues for the need of the various customizations.

Where is it?

Latest versions should be at the mingwpy anaconda site.

There are older versions at the mingwpy bitbucket repo.

What’s in it?

See notes below.

See Mingwpy retired bitbucket site for lists of files in the (older) distribution.

Customizations over standard mingw-builds releases

  • two dedicated GCC toolchains for both 32bit (POSIX threads, Dwarf exceptions) and 64 bit (POSIX threads, SEH exceptions);
  • statically built toolchain based on gcc and mingw-w64;
  • languages: C, C++, gfortran, with LTO enabled;
  • customized ‘specs’ file for MSVCR90 linkage and manifest support (MSVCR100 linkage coming soon);
  • additional ftime64 patch to allow winpthreads and OpenMP to work with MSVCR90 linkage;
  • OpenBLAS with windows thread support (OpenMP disabled) included.

Notes for the distribution

libpython import files

The libpython27.a import files have been generated with gendef and dlltool according to the recommendations on the mingw-w64 faq site. It is essential to not use import libraries from anywhere, but create them with the tools in the GCC toolchain. The GCC toolchains contain correct generated mscvrXXX import files by default.

OpenBLAS files

The openblas DLL must be copied to numpy/core before building numpy. All Blas and Lapack code will be linked dynamically to this DLL. Because of this the overall distro size gets much smaller compared to numpy-MKL or scipy-MKL. It is not necessary to add numpy/core to the path! (at least on my machine). To load libopenblas.dll to the process space it is only necessary to import numpy – nothing else. libopenblas.dll is linked against the msvcr90.dll, just like python. The DLL itself is a fat binary containing all optimized kernels for all supported platforms. DLL, headers and import files have been included into the toolchain.

Compiling numpy and scipy

Compiling numpy

  1. <mingw>bin and python should be in the PATH. Choose 32 bit or 64 bit architecture.

  2. copy libpython27.a to <python>libs check, that <python>libs does not contain libmsvcr90.a

  3. apply numpy.patch

  4. copy libopenblas.dll from <mingw>bin to numpycore of course don’t ever mix 32bit and 64 bit code

  5. create a site.cfg in the numpy folder with the absolute path to the mingw import files/header files. I copied the openblas header files, importlibs into the GCC toolchain.

  6. create a mingw distutils.cfg file

  7. test the configuration:

    python setup.py config_fc --verbose
    python setup.py build --help-fcompiler
    
  8. build:

    python setup.py build --fcompiler=gnu95
    
  9. make a exe installer:

    python setup.py bdist --format=wininst
    
  10. make a wheel:

    Example for built 32-bit exe installer:

    wininst2wheel numpy-1.8.0.win32-py2.7.exe
    
  11. install:

    wheel install numpy-1.8.0-cp27-none-win32.whl
    
  12. test:

    python -c 'import numpy; numpy.test()'
    

Compiling scipy

  1. apply scipy.patch

  2. Check fortran compiler with:

    python setup.py build --fcompiler=gnu95
    

    and a second time:

    python setup.py build --fcompiler=gnu95
    
  3. Build exe installer:

    python setup.py bdist --format=wininst
    
  4. install

  5. test with:

    import scipy; scipy.test()