SciPy 0.6.0 API Documentation Generated by Endo, 2007-10-17
Tools for compiling C/C++ code to extension modules
The main function, build_extension(), takes the C/C++ file along with some other options and builds a Python extension. It uses distutils for most of the heavy lifting.
choose_compiler() is also useful (mainly on windows anyway) for trying to determine whether MSVC++ or gcc is available. MSVC doesn't handle templates as well, so some of the code emitted by the python->C conversions need this info to choose what kind of code to create.
The other main thing here is an alternative version of the MingW32 compiler class. The class makes it possible to build libraries with gcc even if the original version of python was built using MSVC. It does this by converting a pythonxx.lib file to a libpythonxx.a file. Note that you need write access to the pythonxx/lib directory to do this.
old_argv = [ ]
old_init_posix = distutils.sysconfig._init_posix
Build the file given by module_path into a Python extension module.
build_extensions uses distutils to build Python extension modules.
kw arguments not used are passed on to the distutils extension
module. Directory settings can handle absoulte settings, but don't
currently expand '~' or environment variables.
module_path -- the full path name to the c file to compile.
Something like: /full/path/name/module_name.c
The name of the c/c++ file should be the same as the
name of the module (i.e. the initmodule() routine)
compiler_name -- The name of the compiler to use. On Windows if it
isn't given, MSVC is used if it exists (is found).
gcc is used as a second choice. If neither are found,
the default distutils compiler is used. Acceptable
names are 'gcc', 'msvc' or any of the compiler names
shown by distutils.ccompiler.show_compilers()
build_dir -- The location where the resulting extension module
should be placed. This location must be writable. If
it isn't, several default locations are tried. If the
build_dir is not in the current python path, a warning
is emitted, and it is added to the end of the path.
build_dir defaults to the current directory.
temp_dir -- The location where temporary files (*.o or *.obj)
from the build are placed. This location must be
writable. If it isn't, several default locations are
tried. It defaults to tempfile.gettempdir()
verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints
minimal information. 2 is noisy.
**kw -- keyword arguments. These are passed on to the
distutils extension module. Most of the keywords
are listed below.
Distutils keywords. These are cut and pasted from Greg Ward's
distutils.extension.Extension class for convenience:
sources : [string]
list of source filenames, relative to the distribution root
(where the setup script lives), in Unix form (slash-separated)
for portability. Source files may be C, C++, SWIG (.i),
platform-specific resource files, or whatever else is recognized
by the "build_ext" command as source for a Python extension.
Note: The module_path file is always appended to the front of this
list
include_dirs : [string]
list of directories to search for C/C++ header files (in Unix
form for portability)
define_macros : [(name : string, value : string|None)]
list of macros to define; each macro is defined using a 2-tuple,
where 'value' is either the string to define it to or None to
define it without a particular value (equivalent of "#define
FOO" in source or -DFOO on Unix C compiler command line)
undef_macros : [string]
list of macros to undefine explicitly
library_dirs : [string]
list of directories to search for C/C++ libraries at link time
libraries : [string]
list of library names (not filenames or paths) to link against
runtime_library_dirs : [string]
list of directories to search for C/C++ libraries at run time
(for shared extensions, this is when the extension is loaded)
extra_objects : [string]
list of extra files to link with (eg. object files not implied
by 'sources', static library that must be explicitly specified,
binary resource files, etc.)
extra_compile_args : [string]
any extra platform- and compiler-specific information to use
when compiling the source files in 'sources'. For platforms and
compilers where "command line" makes sense, this is typically a
list of command-line arguments, but for other platforms it could
be anything.
extra_link_args : [string]
any extra platform- and compiler-specific information to use
when linking object files together to create the extension (or
to create a new static Python interpreter). Similar
interpretation as for 'extra_compile_args'.
export_symbols : [string]
list of symbols to be exported from a shared extension. Not
used on all platforms, and not generally necessary for Python
extensions, which typically export exactly one symbol: "init" +
extension_name.
Try and figure out which compiler is gonna be used on windows. On other platforms, it just returns whatever value it is given.
converts 'gcc' to 'mingw32' on win32
Create an Extension that can be buil by setup.py
See build_extension for information on keyword arguments.
Test to make sure gcc is found
Does this return correct value on win98???
Determine whether MSVC is available on the machine.
| Local name | Refers to |
|---|---|
| commands | commands |
| distutils.dir_util | distutils.dir_util |
| distutils.sysconfig | distutils.sysconfig |
| exceptions | exceptions |
| Extension | numpy.distutils.core.Extension |
| os | os |
| platform_info | SciPy.weave.platform_info |
| string | string |
| sys | sys |
| tempfile | tempfile |
| time | time |