Build python gcc windows
Learn more. Build Python with Mingw and gcc Ask Question. Asked 8 years, 10 months ago. Active 4 years, 5 months ago.
Viewed 19k times. Theuns Heydenrych Theuns Heydenrych 1 1 gold badge 4 4 silver badges 12 12 bronze badges. Download the sources, read the docs, and run the compiler with appropriate flags. StoryTeller your name is aptly chosen.
Python does not build out of the box with MinGW, let alone for Win Add a comment. Active Oldest Votes. Thank you for the reply. The reason for this, is I would like to compile Quantum-Gis for 64 bit with mingw and gcc.
I started to build Sip with Mingw and gcc and Python 2. I successfully compiled PyQt4 and install it, but when testing it in a python console it just fails. I don't know how to debug this failure?
Because of this failure I reasoned that maybe I need to compile Python 2. PyInstaller comes with pre-compiled bootloaders for some platforms in the bootloader folder of the distribution folder.
When there is no pre-compiled bootloader for the current platform operating-system and word-size , the pip setup will attempt to build one. If there is no precompiled bootloader for your platform, or if you want to modify the bootloader source, you need to build the bootloader.
To do this,. This will produce the bootloader executables for your current platform of course, for Windows these files will have the.
For more information about cross-building please read on and mind the section about the virtual machines provided in the Vagrantfile. You can run the following to install everything required:. Alternatively you may want to use the linux64 build-guest provided by the Vagrantfile see below. If for some reason you want to build Linux Standard Base LSB compliant binaries 1 , you can do so by specifying --lsb on the waf command line, as follows:.
LSB version 4. Please refer to python. Unfortunately it is not widely adopted and both Debian and Ubuntu dropped support for LSB in autumn Open it in some flavour of text previewer to see them:. Instead of installing the full Xcode package, you can also install and use Command Line Tools for Xcode.
Installing either will provide the clang compiler. This requires a recent version of Xcode This behavior can be controlled by passing --universal2 or --no-universal2 flags to the waf build command. Attempting to use --universal2 flag and a toolchain that lacks support for universal2 binaries will result in configuration error. By default, the build script targets Mac OSX This is easy to get and needs to be done only once and the result can be transferred to you build-system. If you are interested in the details, and what other features OS X Cross offers, please refer to its homepage.
Download Command Line Tools for Xcode You will need an Apple ID to search and download the files; if you do not have one already, you can register it for free. Save the downloaded. If for some reason this fails, try running vagrant provision build-osxcross. Or are these steps more or less what I'll have to do to compile for the platform other than the one I'm running on?
My ultimate goal is to produce an egg package which will contain both PE and ELF binaries in it and will install them in the correct location on either platform when installed by pip or pipenv.
It should compile on Linux compiling it on MS Windows isn't necessary. I'm posting this as community wiki because it's a pretty unsatisfactory answer: it only tells you why it's very hard rather than offers really solutions. The official Python distributions on Windows are compiled with Microsoft Visual C MSVC , and when compiling a Python extension it's generally necessary to use the same version as the one that Python was compiled with.
This shows you that an exact compiler match is pretty important. It is possible to get versions of Python compiled with Mingw, and these would then be compatible with modules compiled with Mingw. This could probably be made to work as a cross-compiler on Linux but the modules would only be useful to a very small subset of people that have this custom build of Python so doesn't help create a useful distributable.
The main driver for this seems to be the lack of freely Fortran compiler for Windows that is compatible with MSVC, hence the ability to build Fortran modules is very useful.
The mingwpy toolchain worked pretty well in my experience, until Python 3. My feeling would be that any viable solution would probably be based around these mostly-working Mingw compilers for windows. Moreover, building extensions with compilers other than the MSVC that Python is built with is not officially supported.
I had the same issue once, but I just used a virtual machine to compile my most painfuly microsoft dependant programs. If you don't have access to a windows machine or your programs uses very specific machiney like a fortran compiler optimized or some POSIX dependant stuff or newest features from VS redistributable versions, you better give a try to a virtual machine based compilation system.
Here is a proof of concept for cross compiling Cython- extensions for Windows on Linux, which follows more or less the steps for building with mingw-w64 on Windows. But first a word of warning: While possible, the workflow is not really supported it starts with the fact that the only supported windows compiler is MSVC , so it can be broken with changes in future versions.
I use Python 3. There might be legit scenarios for cross-compilation for Windows, but the python world seems to live quite good without, so probably cross-compilation is not the right direction in the most cases. I guess one can be minimalistic and only use -O2 compile flag in most cases. It is important, that the python-library python37 should be the dll itself and not the lib see this SO-post.
One probably should add the proper suffix to the resulting pyd-file, I use the old convention for simplicity here. In case the python should be embeded, i. C-code is generated via cython -3 --embed foo. Note: for the resulting executable to run, a whole python-distribution and not only the dll is needed see also this SO-post.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Cross-compile extension on Linux for Windows Ask Question.
Asked 3 years, 11 months ago.
0コメント