[Distutils] Cross compiling with extensions

Tres Seaver tseaver at palladion.com
Sat Jul 19 20:39:24 CEST 2008

Hash: SHA1

Dale Weber wrote:
> 	Hi, everyone,
> 	I've been in the process of rebuilding my robot, W.A.L.T.E.R. and will
> be using Python to create all the new control and interface software for
> it. I'm currently using Gentoo Embedded Linux on a TinCanTools Hammer
> Board (http://www.tincantools.com). I have gotten all the software
> components I need cross compiled except two - pysqlite and imaging
> (Python Imaging). These packages have extensions, and will not cross
> compile properly.
> 	I'm willing to do work on getting a cross compile working for these
> types of packages, but am not quite sure where to start. I've been
> looking at the code for distutils that installes with Python 2.4.4, and
> I think I understand at least part of what needs to be done, but again
> am not completely sure because I don't know how to interface to
> distutils.
> 	What is the proper way to interface to distutils to start a build? Is
> there already a mechanism to tell distutils which compiler to use and/or
> which platform to build for?

You can run the 'build_ext' step separately, which allows you to specify
several options you may need::

- ----------------------- 8< ----------------------------------
$ python setup.py build_ext --help
Global options:
  --verbose (-v)  run verbosely (default)
  --quiet (-q)    run quietly (turns verbosity off)
  --dry-run (-n)  don't actually do anything
  --help (-h)     show detailed help message

Options for 'build_ext' command:
  --build-lib (-b)     directory for compiled extension modules
  --build-temp (-t)    directory for temporary files (build by-products)
  --inplace (-i)       ignore build-lib and put compiled extensions into the
                       source directory alongside your pure Python modules
  --include-dirs (-I)  list of directories to search for header files
                       (separated by ':')
  --define (-D)        C preprocessor macros to define
  --undef (-U)         C preprocessor macros to undefine
  --libraries (-l)     external C libraries to link with
  --library-dirs (-L)  directories to search for external C libraries
                       (separated by ':')
  --rpath (-R)         directories to search for shared C libraries at
  --link-objects (-O)  extra explicit link objects to include in the link
  --debug (-g)         compile/link with debugging information
  --force (-f)         forcibly build everything (ignore file timestamps)
  --compiler (-c)      specify the compiler type
  --swig-cpp           make SWIG create C++ files (default is C)
  --swig-opts          list of SWIG command line options
  --swig               path to the SWIG executable
  --help-compiler      list available compilers

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

$ python setup.py build_ext --help-compiler
List of available compilers:
  --compiler=bcpp     Borland C++ Compiler
  --compiler=cygwin   Cygwin port of GNU C Compiler for Win32
  --compiler=emx      EMX port of GNU C Compiler for OS/2
  --compiler=mingw32  Mingw32 port of GNU C Compiler for Win32
  --compiler=msvc     Microsoft Visual C++
  --compiler=mwerks   MetroWerks CodeWarrior
  --compiler=unix     standard UNIX-style compiler

- ----------------------- 8< ----------------------------------

Hope that helps,

- --
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Distutils-SIG mailing list