Cygwin gcc mingw python development environment configuration

Tony Kelman tony@kelman.net
Thu Jan 29 16:25:00 GMT 2015


> - how to include gcc/mingw options when needed for python setup.py 
> situations

The Cygwin-hosted MinGW compilers are set up in a very similar way to cross-
compilation from Linux. Python and most of its infrastructure for building
C extensions do not support MinGW very well, from any host environment.
They generally don't even support Posix-to-Posix cross-compilation very
well either.

> For example, if compiling Cython, which uses python setup.py, which in 
> turn
> calls gcc using a select build environment - how can I configure this to 
> use
> mingw, if this is required, instead of Cygwin gcc? How to configure paths 
> or
> select gcc parameters?

You can attempt to use the cross-compilers, either i686-w64-mingw32-gcc to
create 32 bit binaries, or x86_64-w64-mingw32-gcc for 64 bit binaries.
This might not work too well, depending how many ingrained assumptions are
buried in Cython and all of its supporting tools that treat build and host
as the same thing, expecting properties of the build-system's Python to be
the same as the host system's Python.

> The choices are either an intrinsic Cygwin gcc build environment, or a
> Cygwin mingw based one. This provides for Cygwin and Windows dependent
> platform targets.

In terms of building Python C extensions, building in Cygwin should work
fairly well for the Cygwin-hosted, POSIX-style Python. The conventional
Win32 MSVC-built Python is a different beast, and the two don't always
play well together. MinGW, which is GCC for Win32, works great for
compiling a pretty wide array of libraries. But much of the Python
ecosystem tends to treat it as a marginal, unsupported platform.

> I want to work from mintty, as opposed to using a separate C:\MingGW MSYS
> build environment. (Especially because I use python and other tools 
> directly
> from Cygwin/mintty)

You might want to look at MSYS2. It is a relatively recent, up-to-date fork
of Cygwin, using mintty and an up-to-date MinGW-w64 toolchain, but set up
like the legacy MSYS1 so that most builds do not look like a conventional
cross-compilation. This is the Cygwin mailing list not the MSYS2 list, and
I believe there's still some disagreement over the need to fork Cygwin vs
contributing to and improving it. But they do have an experimental build of
Python using MinGW (heavily patched) that you may find useful to try out.

-Tony


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list