Skip to content

Instantly share code, notes, and snippets.

@snorfalorpagus
Last active January 17, 2017 15:02
Show Gist options
  • Save snorfalorpagus/33fa9af14959ae995277e11124503495 to your computer and use it in GitHub Desktop.
Save snorfalorpagus/33fa9af14959ae995277e11124503495 to your computer and use it in GitHub Desktop.
Building Python 3.5 (32-bit) modules with Anaconda and MINGW64 (without MSVC 2015)

Building Python 3.5 (32-bit) modules with Anaconda and MINGW64 (without MSVC 2015)

To create 32-bit anaconda environment on 64-bit install:

set CONDA_FORCE_32BIT=1
conda create -n py35_32 python=3.5

To install mingw64, don't use mingw package (deprecated). Intsead:

conda install m2w64-toolchain

Modify env\py35_32\Lib\distutils\cygwincompiler.py with rule for MSVC 1900:

        elif msc_ver == '1600':
            # VS2010 / MSVC 10.0
            return ['msvcr100']
        elif msc_ver == '1900':
            return ['vcruntime140']
        else:
            raise ValueError("Unknown MS Compiler version %s " % msc_ver)

To compile, need to tell it to use mingw32 compiler and add folder with vcruntime140.dll to library search path.

python setup.py build_ext --compiler=mingw32 -LC:\Miniconda3-x64\envs\py35_32 -i

Confirm the resulting file is 32 bit (should be obvious from filename!):

D:\pycatchmod>file pycatchmod\_catchmod.cp35-win32.pyd
pycatchmod\_catchmod.cp35-win32.pyd: PE32 executable (DLL) (console) Intel 80386 (stripped to external PDB), for MS Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment