This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amyodov
Recipients amyodov, eric.araujo, tarek
Date 2011-10-24.23:41:38
SpamBayes Score 3.8857806e-14
Marked as misclassified No
Message-id <1319499699.99.0.666933133396.issue13260@psf.upfronthosting.co.za>
In-reply-to
Content
I was recently trying to cross-compile several extensions (host: Linux, target: Win32) using mingw-gcc, and noticed that there is quite a little amount of changes needed to distutils code to at least make proper win32-compabible modules.

Some of them require pretty noticeable functionality changes to distutils (like, adding a new option) thus they are unlikely a target for 2.7 anymore (though with some luck, any person who wants to follow my way and do cross-compilation, may just subclass the existing code). But some others are obvious bugs, and their fixes may still be useful for users stuck at 2.7.

1. (This is dubious but still is related to the problem, and was required to build some of the modules). "--include-dirs" and "--library-dirs" options to build_ext command support multiple paths separated by os.pathsep. For some reason (which I may be unaware of) "--libraries" option doesn't. A tiny fix just adds this support.

2. (more obvious issue) get_msvcr() function in distutils/cygwincompiler.py tries to guess the C runtime library which the target extension should link to. To do that, it tests the Python where the setup.py is *running* for what library it was linked to. But when the compilation target is Win32 but the compilation host is Linux, the hosts's Python won't contain such information. In this case, this function will return None. The result then gets assigned to self.dll_libraries (in an instance of CygwinCCompiler or Mingw32CCompiler), and gets used in a context which implies it is always an iterable (libraries.extend(self.dll_libraries)).

These changes, together with altering or subclassing Mingw32CCompiler to use a different compiler name (like, "i586-mingw32msvc-gcc" instead of "gcc"), make it possible to cross-compile a number of extensions which were non-compileable before.
History
Date User Action Args
2011-10-24 23:41:40amyodovsetrecipients: + amyodov, tarek, eric.araujo
2011-10-24 23:41:39amyodovsetmessageid: <1319499699.99.0.666933133396.issue13260@psf.upfronthosting.co.za>
2011-10-24 23:41:39amyodovlinkissue13260 messages
2011-10-24 23:41:39amyodovcreate