(This is the section to read for people doing any sort of interesting build. Things to talk about:
This subsection describes the necessary steps to use Distutils with the Borland C++ compiler version 5.5.
First you have to know that the Borland's object file format(OMF) is different from what is used by the Python version you can download from the Python Web site. (Python is built with Microsoft Visual C++, which uses COFF as object file format.) For this reason you have to convert Python's library python20.lib into the Borland format. You can do this as follows:
coff2omf python20.lib python20_bcpp.lib
The coff2omf program comes with the Borland compiler. The file python20.lib is in the Libs directory of your Python installation. If your extension uses other libraries (zlib,...) you have to convert them too.
The converted files have to reside in the same directories as the normal libraries.
How does Distutils manage to use these libraries with their changed names? If the extension needs a library (eg. foo) Distutils checks first if it finds a library with suffix _bcpp (eg. foo_bcpp.lib) and then uses this library. In the case it doesn't find such a special library it uses the default name (foo.lib.)1
To let Distutils compile your extension with Borland C++ you now have to type:
python setup.py build --compiler=bcpp
If you want to use the Borland C++ compiler as default, you should consider to write it in your personal or system-wide configuration file for Distutils (see section 6.)
See Also:
This section describes the necessary steps to use Distutils with the GNU C/C++ compilers in their Cygwin and MinGW32 distributions.2
** For a Python which was built with Cygwin, all should work without any of these following steps. **
For these compilers we have to create some special libraries too. This task is more complex as for Borland's C++, because there is no program to convert the library (inclusive the references on data structures.)
First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at http://starship.python.net/crew/kernr/mingw32/Notes.html, see at PExports 0.42h there.)
pexports python20.dll >python20.def
Then you can create from these information an import library for gcc.
dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a
The resulting library has to be placed in the same directory as python20.lib. (Should be the libs directory under your Python installation directory.)
If your extension uses other libraries (zlib,...) you might have to convert them too. The converted files have to reside in the same directories as the normal libraries do.
To let Distutils compile your extension with Cygwin you now have to type
python setup.py build --compiler=cygwin
and for Cygwin in no-cygwin mode3 or for MinGW32 type:
python setup.py build --compiler=mingw32
If you want to use any of these options/compilers as default, you should consider to write it in your personal or system-wide configuration file for Distutils (see section 6.)
See Also: