Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Python with Mingw and gcc

Is it possible to build Python interpreter from source with Mingw and gcc on Windows 7? And I would like to biuld a 64bit version.

If a 64bit Python (gcc Mingw) version is available for download please let me know, I would use that also. At the end I still would like to compile it with gcc and mingw.

like image 525
Theuns Heydenrych Avatar asked Mar 12 '13 15:03

Theuns Heydenrych


People also ask

Can MinGW compile Python?

MinGW is an alternative C/C++ compiler that works with all Python versions up to 3.4.

Can GCC compile Python?

In theory the plugin allows you to write Python scripts that can run inside GCC as it compiles code, exposing GCC's internal data structures as a collection of Python classes and functions.

Does MinGW use GCC?

MinGW is a compiler system based on the GNU GCC and Binutils projects that compiles and links code to be run on Win32 (Windows) systems. It provides C, C++ and Fortran compilers plus other related tools.

Is MinGW-w64 better than MinGW?

MinGW-w64 is a improved version which supports both 32bit and 64bit, and some more of the WinAPI (still not all, because thats much work, but more than MinGW). MinGW-w64 only provides their source code, but no binaries to "just use" the compiler.


2 Answers

First off, you do not need to build Python with MinGW-w64 to link to it and embed a interpreter. Just extract the msi installer, and use the prebuilt DLL. Note you'll have to be careful not to mix msvcr[t|90].dll objects, but I've never seen that be a real issue personally.

MinGW-w64 gcc/ld should be able to link to DLL's directly, otherwise you'll have to use gendef to create a .def file and dlltool to create an import library.

Secondly, there's a patchset to build Python with MinGW, but I'm not sure about its 64-bit compatibility.

like image 162
rubenvb Avatar answered Sep 29 '22 22:09

rubenvb


You may try this repository:

hg clone https://bitbucket.org/puqing/python-mingw

It is a copy of the official repository but contains some modification to make it compile with mingw. Enter PC/MinGW directory:

cd PC/MinGW && make

Not sure if it compiles in win64, but with win32 and msys it should work.

like image 40
cpq Avatar answered Sep 29 '22 23:09

cpq