I\'m starting out some projects in words processing and I needed NumPy and NLTK.
That was the first time I got to know easy_install and how to compile new modul
For Windows 10, Python 2.7.11, Cygwin 2.5.2 and x86_64-w64-mingw32-gcc 4.9.2 or 5.4.0 (but see note under 1 below), pulling together comments from elsewhere, here's what I had to do for my Python extension to compile, link, and beat a race condition between msvcrt.dll and msvcr90.dll:
Edit distutils/cygwinccompiler, and in class Mingw32CCompiler
Replace the old -mno-cygwin fix with
if self.gcc_version < '4' or is_cygwingcc():
no_cygwin = ' -nostdlib -lgcc'
for gcc 4.9.2 -- note for 5.4.0, no 'if', just
no_cygwin = ''
Get the right compiler in place:
self.set_executables(compiler='x86_64-w64-mingw32-gcc%s -O -Wall' % no_cygwin,
compiler_so='x86_64-w64-mingw32-gcc%s -mdll -O -Wall' % no_cygwin,
compiler_cxx='x86_64-w64-mingw32-g++%s -O -Wall' % no_cygwin,
linker_exe='x86_64-w64-mingw32-gcc%s' % no_cygwin,
linker_so='x86_64-w64-mingw32-%s%s %s %s'
note for x86_64-w64-mingw32-gcc 5.4.0, it seems to work better without msvcr90, so make the call to get_msvcr conditional:
if self.gcc_version < '5':
self.dll_libraries = get_msvcr()
Use a setup.py with the following
libdirs=['C:\\Python27\\libs',...]
macros=[('MS_WIN64','1'),...]
platform="WIN32"
Patch one of my source file headers to include
#ifdef MS_WIN64
#define strdup _strdup
#endif
Finally,
/c/Python27/python [editted setup].py -v build --compiler=mingw32
/c/Python27/python [editted setup].py -v install
Some of the above may not be in quite the optimal place, but it got my extension working...