Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els11.x86_64 #1 SMP Sun Nov 3 09:06:59 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.138.121.79
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python-docs-2.7.5 /
html /
distutils /
[ HOME SHELL ]
Name
Size
Permission
Action
apiref.html
178.6
KB
-rw-r--r--
builtdist.html
34.16
KB
-rw-r--r--
commandref.html
7.46
KB
-rw-r--r--
configfile.html
13.62
KB
-rw-r--r--
examples.html
21.65
KB
-rw-r--r--
extending.html
12.53
KB
-rw-r--r--
index.html
22.98
KB
-rw-r--r--
introduction.html
18.43
KB
-rw-r--r--
packageindex.html
17.61
KB
-rw-r--r--
setupscript.html
61.81
KB
-rw-r--r--
sourcedist.html
25.39
KB
-rw-r--r--
uploading.html
4.77
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : apiref.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>10. API Reference — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="Distributing Python Modules" href="index.html" /> <link rel="next" title="Installing Python Modules" href="../install/index.html" /> <link rel="prev" title="9. Command Reference" href="commandref.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="../install/index.html" title="Installing Python Modules" accesskey="N">next</a> |</li> <li class="right" > <a href="commandref.html" title="9. Command Reference" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" accesskey="U">Distributing Python Modules</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="api-reference"> <span id="id1"></span><h1>10. API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h1> <div class="section" id="module-distutils.core"> <span id="distutils-core-core-distutils-functionality"></span><h2>10.1. <a class="reference internal" href="#module-distutils.core" title="distutils.core: The core Distutils functionality"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.core</span></tt></a> — Core Distutils functionality<a class="headerlink" href="#module-distutils.core" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#module-distutils.core" title="distutils.core: The core Distutils functionality"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.core</span></tt></a> module is the only module that needs to be installed to use the Distutils. It provides the <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a> (which is called from the setup script). Indirectly provides the <tt class="xref py py-class docutils literal"><span class="pre">distutils.dist.Distribution</span></tt> and <a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><tt class="xref py py-class docutils literal"><span class="pre">distutils.cmd.Command</span></tt></a> class.</p> <dl class="function"> <dt id="distutils.core.setup"> <tt class="descclassname">distutils.core.</tt><tt class="descname">setup</tt><big>(</big><em>arguments</em><big>)</big><a class="headerlink" href="#distutils.core.setup" title="Permalink to this definition">¶</a></dt> <dd><p>The basic do-everything function that does most everything you could ever ask for from a Distutils method.</p> <p>The setup function takes a large number of arguments. These are laid out in the following table.</p> <table border="1" class="docutils"> <colgroup> <col width="18%" /> <col width="28%" /> <col width="54%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">argument name</th> <th class="head">value</th> <th class="head">type</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>name</em></td> <td>The name of the package</td> <td>a string</td> </tr> <tr class="row-odd"><td><em>version</em></td> <td>The version number of the package; see <a class="reference internal" href="#module-distutils.version" title="distutils.version: implements classes that represent module version numbers."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.version</span></tt></a></td> <td>a string</td> </tr> <tr class="row-even"><td><em>description</em></td> <td>A single line describing the package</td> <td>a string</td> </tr> <tr class="row-odd"><td><em>long_description</em></td> <td>Longer description of the package</td> <td>a string</td> </tr> <tr class="row-even"><td><em>author</em></td> <td>The name of the package author</td> <td>a string</td> </tr> <tr class="row-odd"><td><em>author_email</em></td> <td>The email address of the package author</td> <td>a string</td> </tr> <tr class="row-even"><td><em>maintainer</em></td> <td>The name of the current maintainer, if different from the author. Note that if the maintainer is provided, distutils will use it as the author in <tt class="file docutils literal"><span class="pre">PKG-INFO</span></tt></td> <td>a string</td> </tr> <tr class="row-odd"><td><em>maintainer_email</em></td> <td>The email address of the current maintainer, if different from the author</td> <td>a string</td> </tr> <tr class="row-even"><td><em>url</em></td> <td>A URL for the package (homepage)</td> <td>a string</td> </tr> <tr class="row-odd"><td><em>download_url</em></td> <td>A URL to download the package</td> <td>a string</td> </tr> <tr class="row-even"><td><em>packages</em></td> <td>A list of Python packages that distutils will manipulate</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>py_modules</em></td> <td>A list of Python modules that distutils will manipulate</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>scripts</em></td> <td>A list of standalone script files to be built and installed</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>ext_modules</em></td> <td>A list of Python extensions to be built</td> <td>a list of instances of <a class="reference internal" href="#distutils.core.Extension" title="distutils.core.Extension"><tt class="xref py py-class docutils literal"><span class="pre">distutils.core.Extension</span></tt></a></td> </tr> <tr class="row-even"><td><em>classifiers</em></td> <td>A list of categories for the package</td> <td>a list of strings; valid classifiers are listed on <a class="reference external" href="http://pypi.python.org/pypi?:action=list_classifiers">PyPI</a>.</td> </tr> <tr class="row-odd"><td><em>distclass</em></td> <td>the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt></a> class to use</td> <td>a subclass of <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">distutils.core.Distribution</span></tt></a></td> </tr> <tr class="row-even"><td><em>script_name</em></td> <td>The name of the setup.py script - defaults to <tt class="docutils literal"><span class="pre">sys.argv[0]</span></tt></td> <td>a string</td> </tr> <tr class="row-odd"><td><em>script_args</em></td> <td>Arguments to supply to the setup script</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>options</em></td> <td>default options for the setup script</td> <td>a dictionary</td> </tr> <tr class="row-odd"><td><em>license</em></td> <td>The license for the package</td> <td>a string</td> </tr> <tr class="row-even"><td><em>keywords</em></td> <td>Descriptive meta-data, see <span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0314"><strong>PEP 314</strong></a></td> <td>a list of strings or a comma-separated string</td> </tr> <tr class="row-odd"><td><em>platforms</em></td> <td> </td> <td>a list of strings or a comma-separated string</td> </tr> <tr class="row-even"><td><em>cmdclass</em></td> <td>A mapping of command names to <a class="reference internal" href="#distutils.core.Command" title="distutils.core.Command"><tt class="xref py py-class docutils literal"><span class="pre">Command</span></tt></a> subclasses</td> <td>a dictionary</td> </tr> <tr class="row-odd"><td><em>data_files</em></td> <td>A list of data files to install</td> <td>a list</td> </tr> <tr class="row-even"><td><em>package_dir</em></td> <td>A mapping of package to directory names</td> <td>a dictionary</td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="distutils.core.run_setup"> <tt class="descclassname">distutils.core.</tt><tt class="descname">run_setup</tt><big>(</big><em>script_name</em><span class="optional">[</span>, <em>script_args=None</em>, <em>stop_after='run'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.core.run_setup" title="Permalink to this definition">¶</a></dt> <dd><p>Run a setup script in a somewhat controlled environment, and return the <tt class="xref py py-class docutils literal"><span class="pre">distutils.dist.Distribution</span></tt> instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from <em>script</em> to <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a>), or the contents of the config files or command-line.</p> <p><em>script_name</em> is a file that will be run with <a class="reference internal" href="../library/functions.html#execfile" title="execfile"><tt class="xref py py-func docutils literal"><span class="pre">execfile()</span></tt></a> <tt class="docutils literal"><span class="pre">sys.argv[0]</span></tt> will be replaced with <em>script</em> for the duration of the call. <em>script_args</em> is a list of strings; if supplied, <tt class="docutils literal"><span class="pre">sys.argv[1:]</span></tt> will be replaced by <em>script_args</em> for the duration of the call.</p> <p><em>stop_after</em> tells <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a> when to stop processing; possible values:</p> <table border="1" class="docutils"> <colgroup> <col width="25%" /> <col width="75%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">value</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>init</em></td> <td>Stop after the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt></a> instance has been created and populated with the keyword arguments to <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a></td> </tr> <tr class="row-odd"><td><em>config</em></td> <td>Stop after config files have been parsed (and their data stored in the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt></a> instance)</td> </tr> <tr class="row-even"><td><em>commandline</em></td> <td>Stop after the command-line (<tt class="docutils literal"><span class="pre">sys.argv[1:]</span></tt> or <em>script_args</em>) have been parsed (and the data stored in the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt></a> instance.)</td> </tr> <tr class="row-odd"><td><em>run</em></td> <td>Stop after all commands have been run (the same as if <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a> had been called in the usual way). This is the default value.</td> </tr> </tbody> </table> </dd></dl> <p>In addition, the <a class="reference internal" href="#module-distutils.core" title="distutils.core: The core Distutils functionality"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.core</span></tt></a> module exposed a number of classes that live elsewhere.</p> <ul class="simple"> <li><tt class="xref py py-class docutils literal"><span class="pre">Extension</span></tt> from <a class="reference internal" href="#module-distutils.extension" title="distutils.extension: Provides the Extension class, used to describe C/C++ extension modules in setup scripts"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.extension</span></tt></a></li> <li><a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><tt class="xref py py-class docutils literal"><span class="pre">Command</span></tt></a> from <a class="reference internal" href="#module-distutils.cmd" title="distutils.cmd: This module provides the abstract base class Command. This class is subclassed by the modules in the distutils.command subpackage."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.cmd</span></tt></a></li> <li><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt> from <a class="reference internal" href="#module-distutils.dist" title="distutils.dist: Provides the Distribution class, which represents the module distribution being built/installed/distributed"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.dist</span></tt></a></li> </ul> <p>A short description of each of these follows, but see the relevant module for the full reference.</p> <dl class="class"> <dt id="distutils.core.Extension"> <em class="property">class </em><tt class="descclassname">distutils.core.</tt><tt class="descname">Extension</tt><a class="headerlink" href="#distutils.core.Extension" title="Permalink to this definition">¶</a></dt> <dd><p>The Extension class describes a single C or C++extension module in a setup script. It accepts the following keyword arguments in its constructor</p> <table border="1" class="docutils"> <colgroup> <col width="29%" /> <col width="39%" /> <col width="33%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">argument name</th> <th class="head">value</th> <th class="head">type</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>name</em></td> <td>the full name of the extension, including any packages — ie. <em>not</em> a filename or pathname, but Python dotted name</td> <td>a string</td> </tr> <tr class="row-odd"><td><em>sources</em></td> <td>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 <strong class="command">build_ext</strong> command as source for a Python extension.</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>include_dirs</em></td> <td>list of directories to search for C/C++ header files (in Unix form for portability)</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>define_macros</em></td> <td>list of macros to define; each macro is defined using a 2-tuple <tt class="docutils literal"><span class="pre">(name,</span> <span class="pre">value)</span></tt>, where <em>value</em> is either the string to define it to or <tt class="docutils literal"><span class="pre">None</span></tt> to define it without a particular value (equivalent of <tt class="docutils literal"><span class="pre">#define</span> <span class="pre">FOO</span></tt> in source or <em class="xref std std-option">-DFOO</em> on Unix C compiler command line)</td> <td>a list of tuples</td> </tr> <tr class="row-even"><td><em>undef_macros</em></td> <td>list of macros to undefine explicitly</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>library_dirs</em></td> <td>list of directories to search for C/C++ libraries at link time</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>libraries</em></td> <td>list of library names (not filenames or paths) to link against</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>runtime_library_dirs</em></td> <td>list of directories to search for C/C++ libraries at run time (for shared extensions, this is when the extension is loaded)</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>extra_objects</em></td> <td>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.)</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>extra_compile_args</em></td> <td>any extra platform- and compiler-specific information to use when compiling the source files in ‘sources’. For platforms and compilers where a command line makes sense, this is typically a list of command-line arguments, but for other platforms it could be anything.</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>extra_link_args</em></td> <td>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’.</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>export_symbols</em></td> <td>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: <tt class="docutils literal"><span class="pre">init</span></tt> + extension_name.</td> <td>a list of strings</td> </tr> <tr class="row-even"><td><em>depends</em></td> <td>list of files that the extension depends on</td> <td>a list of strings</td> </tr> <tr class="row-odd"><td><em>language</em></td> <td>extension language (i.e. <tt class="docutils literal"><span class="pre">'c'</span></tt>, <tt class="docutils literal"><span class="pre">'c++'</span></tt>, <tt class="docutils literal"><span class="pre">'objc'</span></tt>). Will be detected from the source extensions if not provided.</td> <td>a string</td> </tr> </tbody> </table> </dd></dl> <dl class="class"> <dt id="distutils.core.Distribution"> <em class="property">class </em><tt class="descclassname">distutils.core.</tt><tt class="descname">Distribution</tt><a class="headerlink" href="#distutils.core.Distribution" title="Permalink to this definition">¶</a></dt> <dd><p>A <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt></a> describes how to build, install and package up a Python software package.</p> <p>See the <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a> function for a list of keyword arguments accepted by the Distribution constructor. <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt></a> creates a Distribution instance.</p> </dd></dl> <dl class="class"> <dt id="distutils.core.Command"> <em class="property">class </em><tt class="descclassname">distutils.core.</tt><tt class="descname">Command</tt><a class="headerlink" href="#distutils.core.Command" title="Permalink to this definition">¶</a></dt> <dd><p>A <a class="reference internal" href="#distutils.core.Command" title="distutils.core.Command"><tt class="xref py py-class docutils literal"><span class="pre">Command</span></tt></a> class (or rather, an instance of one of its subclasses) implement a single distutils command.</p> </dd></dl> </div> <div class="section" id="module-distutils.ccompiler"> <span id="distutils-ccompiler-ccompiler-base-class"></span><h2>10.2. <a class="reference internal" href="#module-distutils.ccompiler" title="distutils.ccompiler: Abstract CCompiler class"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.ccompiler</span></tt></a> — CCompiler base class<a class="headerlink" href="#module-distutils.ccompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides the abstract base class for the <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> classes. A <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> instance can be used for all the compile and link steps needed to build a single project. Methods are provided to set options for the compiler — macro definitions, include directories, link path, libraries and the like.</p> <p>This module provides the following functions.</p> <dl class="function"> <dt id="distutils.ccompiler.gen_lib_options"> <tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">gen_lib_options</tt><big>(</big><em>compiler</em>, <em>library_dirs</em>, <em>runtime_library_dirs</em>, <em>libraries</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.gen_lib_options" title="Permalink to this definition">¶</a></dt> <dd><p>Generate linker options for searching library directories and linking with specific libraries. <em>libraries</em> and <em>library_dirs</em> are, respectively, lists of library names (not filenames!) and search directories. Returns a list of command-line options suitable for use with some compiler (depending on the two format strings passed in).</p> </dd></dl> <dl class="function"> <dt id="distutils.ccompiler.gen_preprocess_options"> <tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">gen_preprocess_options</tt><big>(</big><em>macros</em>, <em>include_dirs</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.gen_preprocess_options" title="Permalink to this definition">¶</a></dt> <dd><p>Generate C pre-processor options (<em class="xref std std-option">-D</em>, <a class="reference internal" href="../using/cmdline.html#cmdoption-U"><em class="xref std std-option">-U</em></a>, <em class="xref std std-option">-I</em>) as used by at least two types of compilers: the typical Unix compiler and Visual C++. <em>macros</em> is the usual thing, a list of 1- or 2-tuples, where <tt class="docutils literal"><span class="pre">(name,)</span></tt> means undefine (<a class="reference internal" href="../using/cmdline.html#cmdoption-U"><em class="xref std std-option">-U</em></a>) macro <em>name</em>, and <tt class="docutils literal"><span class="pre">(name,</span> <span class="pre">value)</span></tt> means define (<em class="xref std std-option">-D</em>) macro <em>name</em> to <em>value</em>. <em>include_dirs</em> is just a list of directory names to be added to the header file search path (<em class="xref std std-option">-I</em>). Returns a list of command-line options suitable for either Unix compilers or Visual C++.</p> </dd></dl> <dl class="function"> <dt id="distutils.ccompiler.get_default_compiler"> <tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">get_default_compiler</tt><big>(</big><em>osname</em>, <em>platform</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.get_default_compiler" title="Permalink to this definition">¶</a></dt> <dd><p>Determine the default compiler to use for the given platform.</p> <p><em>osname</em> should be one of the standard Python OS names (i.e. the ones returned by <tt class="docutils literal"><span class="pre">os.name</span></tt>) and <em>platform</em> the common value returned by <tt class="docutils literal"><span class="pre">sys.platform</span></tt> for the platform in question.</p> <p>The default values are <tt class="docutils literal"><span class="pre">os.name</span></tt> and <tt class="docutils literal"><span class="pre">sys.platform</span></tt> in case the parameters are not given.</p> </dd></dl> <dl class="function"> <dt id="distutils.ccompiler.new_compiler"> <tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">new_compiler</tt><big>(</big><em>plat=None</em>, <em>compiler=None</em>, <em>verbose=0</em>, <em>dry_run=0</em>, <em>force=0</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.new_compiler" title="Permalink to this definition">¶</a></dt> <dd><p>Factory function to generate an instance of some CCompiler subclass for the supplied platform/compiler combination. <em>plat</em> defaults to <tt class="docutils literal"><span class="pre">os.name</span></tt> (eg. <tt class="docutils literal"><span class="pre">'posix'</span></tt>, <tt class="docutils literal"><span class="pre">'nt'</span></tt>), and <em>compiler</em> defaults to the default compiler for that platform. Currently only <tt class="docutils literal"><span class="pre">'posix'</span></tt> and <tt class="docutils literal"><span class="pre">'nt'</span></tt> are supported, and the default compilers are “traditional Unix interface” (<tt class="xref py py-class docutils literal"><span class="pre">UnixCCompiler</span></tt> class) and Visual C++ (<tt class="xref py py-class docutils literal"><span class="pre">MSVCCompiler</span></tt> class). Note that it’s perfectly possible to ask for a Unix compiler object under Windows, and a Microsoft compiler object under Unix—if you supply a value for <em>compiler</em>, <em>plat</em> is ignored.</p> </dd></dl> <dl class="function"> <dt id="distutils.ccompiler.show_compilers"> <tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">show_compilers</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.ccompiler.show_compilers" title="Permalink to this definition">¶</a></dt> <dd><p>Print list of available compilers (used by the <em class="xref std std-option">--help-compiler</em> options to <strong class="command">build</strong>, <strong class="command">build_ext</strong>, <strong class="command">build_clib</strong>).</p> </dd></dl> <dl class="class"> <dt id="distutils.ccompiler.CCompiler"> <em class="property">class </em><tt class="descclassname">distutils.ccompiler.</tt><tt class="descname">CCompiler</tt><big>(</big><span class="optional">[</span><em>verbose=0</em>, <em>dry_run=0</em>, <em>force=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler" title="Permalink to this definition">¶</a></dt> <dd><p>The abstract base class <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> defines the interface that must be implemented by real compiler classes. The class also has some utility methods used by several compiler classes.</p> <p>The basic idea behind a compiler abstraction class is that each instance can be used for all the compile/link steps in building a single project. Thus, attributes common to all of those compile and link steps — include directories, macros to define, libraries to link against, etc. — are attributes of the compiler instance. To allow for variability in how individual files are treated, most of those attributes may be varied on a per-compilation or per-link basis.</p> <p>The constructor for each subclass creates an instance of the Compiler object. Flags are <em>verbose</em> (show verbose output), <em>dry_run</em> (don’t actually execute the steps) and <em>force</em> (rebuild everything, regardless of dependencies). All of these flags default to <tt class="docutils literal"><span class="pre">0</span></tt> (off). Note that you probably don’t want to instantiate <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> or one of its subclasses directly - use the <tt class="xref py py-func docutils literal"><span class="pre">distutils.CCompiler.new_compiler()</span></tt> factory function instead.</p> <p>The following methods allow you to manually alter compiler options for the instance of the Compiler class.</p> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.add_include_dir"> <tt class="descname">add_include_dir</tt><big>(</big><em>dir</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.add_include_dir" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>dir</em> to the list of directories that will be searched for header files. The compiler is instructed to search directories in the order in which they are supplied by successive calls to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_include_dir" title="distutils.ccompiler.CCompiler.add_include_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_include_dir()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_include_dirs"> <tt class="descname">set_include_dirs</tt><big>(</big><em>dirs</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_include_dirs" title="Permalink to this definition">¶</a></dt> <dd><p>Set the list of directories that will be searched to <em>dirs</em> (a list of strings). Overrides any preceding calls to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_include_dir" title="distutils.ccompiler.CCompiler.add_include_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_include_dir()</span></tt></a>; subsequent calls to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_include_dir" title="distutils.ccompiler.CCompiler.add_include_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_include_dir()</span></tt></a> add to the list passed to <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_include_dirs" title="distutils.ccompiler.CCompiler.set_include_dirs"><tt class="xref py py-meth docutils literal"><span class="pre">set_include_dirs()</span></tt></a>. This does not affect any list of standard include directories that the compiler may search by default.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.add_library"> <tt class="descname">add_library</tt><big>(</big><em>libname</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.add_library" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>libname</em> to the list of libraries that will be included in all links driven by this compiler object. Note that <em>libname</em> should *not* be the name of a file containing a library, but the name of the library itself: the actual filename will be inferred by the linker, the compiler, or the compiler class (depending on the platform).</p> <p>The linker will be instructed to link against libraries in the order they were supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library" title="distutils.ccompiler.CCompiler.add_library"><tt class="xref py py-meth docutils literal"><span class="pre">add_library()</span></tt></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><tt class="xref py py-meth docutils literal"><span class="pre">set_libraries()</span></tt></a>. It is perfectly valid to duplicate library names; the linker will be instructed to link against libraries as many times as they are mentioned.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_libraries"> <tt class="descname">set_libraries</tt><big>(</big><em>libnames</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_libraries" title="Permalink to this definition">¶</a></dt> <dd><p>Set the list of libraries to be included in all links driven by this compiler object to <em>libnames</em> (a list of strings). This does not affect any standard system libraries that the linker may include by default.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.add_library_dir"> <tt class="descname">add_library_dir</tt><big>(</big><em>dir</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.add_library_dir" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>dir</em> to the list of directories that will be searched for libraries specified to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library" title="distutils.ccompiler.CCompiler.add_library"><tt class="xref py py-meth docutils literal"><span class="pre">add_library()</span></tt></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><tt class="xref py py-meth docutils literal"><span class="pre">set_libraries()</span></tt></a>. The linker will be instructed to search for libraries in the order they are supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library_dir" title="distutils.ccompiler.CCompiler.add_library_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_library_dir()</span></tt></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_library_dirs" title="distutils.ccompiler.CCompiler.set_library_dirs"><tt class="xref py py-meth docutils literal"><span class="pre">set_library_dirs()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_library_dirs"> <tt class="descname">set_library_dirs</tt><big>(</big><em>dirs</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_library_dirs" title="Permalink to this definition">¶</a></dt> <dd><p>Set the list of library search directories to <em>dirs</em> (a list of strings). This does not affect any standard library search path that the linker may search by default.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.add_runtime_library_dir"> <tt class="descname">add_runtime_library_dir</tt><big>(</big><em>dir</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.add_runtime_library_dir" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>dir</em> to the list of directories that will be searched for shared libraries at runtime.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_runtime_library_dirs"> <tt class="descname">set_runtime_library_dirs</tt><big>(</big><em>dirs</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_runtime_library_dirs" title="Permalink to this definition">¶</a></dt> <dd><p>Set the list of directories to search for shared libraries at runtime to <em>dirs</em> (a list of strings). This does not affect any standard search path that the runtime linker may search by default.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.define_macro"> <tt class="descname">define_macro</tt><big>(</big><em>name</em><span class="optional">[</span>, <em>value=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.define_macro" title="Permalink to this definition">¶</a></dt> <dd><p>Define a preprocessor macro for all compilations driven by this compiler object. The optional parameter <em>value</em> should be a string; if it is not supplied, then the macro will be defined without an explicit value and the exact outcome depends on the compiler used.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.undefine_macro"> <tt class="descname">undefine_macro</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.undefine_macro" title="Permalink to this definition">¶</a></dt> <dd><p>Undefine a preprocessor macro for all compilations driven by this compiler object. If the same macro is defined by <a class="reference internal" href="#distutils.ccompiler.CCompiler.define_macro" title="distutils.ccompiler.CCompiler.define_macro"><tt class="xref py py-meth docutils literal"><span class="pre">define_macro()</span></tt></a> and undefined by <a class="reference internal" href="#distutils.ccompiler.CCompiler.undefine_macro" title="distutils.ccompiler.CCompiler.undefine_macro"><tt class="xref py py-meth docutils literal"><span class="pre">undefine_macro()</span></tt></a> the last call takes precedence (including multiple redefinitions or undefinitions). If the macro is redefined/undefined on a per-compilation basis (ie. in the call to <a class="reference internal" href="../library/functions.html#compile" title="compile"><tt class="xref py py-meth docutils literal"><span class="pre">compile()</span></tt></a>), then that takes precedence.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.add_link_object"> <tt class="descname">add_link_object</tt><big>(</big><em>object</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.add_link_object" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>object</em> to the list of object files (or analogues, such as explicitly named library files or the output of “resource compilers”) to be included in every link driven by this compiler object.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_link_objects"> <tt class="descname">set_link_objects</tt><big>(</big><em>objects</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_link_objects" title="Permalink to this definition">¶</a></dt> <dd><p>Set the list of object files (or analogues) to be included in every link to <em>objects</em>. This does not affect any standard object files that the linker may include by default (such as system libraries).</p> </dd></dl> <p>The following methods implement methods for autodetection of compiler options, providing some functionality similar to GNU <strong class="program">autoconf</strong>.</p> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.detect_language"> <tt class="descname">detect_language</tt><big>(</big><em>sources</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.detect_language" title="Permalink to this definition">¶</a></dt> <dd><p>Detect the language of a given file, or list of files. Uses the instance attributes <tt class="xref py py-attr docutils literal"><span class="pre">language_map</span></tt> (a dictionary), and <tt class="xref py py-attr docutils literal"><span class="pre">language_order</span></tt> (a list) to do the job.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.find_library_file"> <tt class="descname">find_library_file</tt><big>(</big><em>dirs</em>, <em>lib</em><span class="optional">[</span>, <em>debug=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.find_library_file" title="Permalink to this definition">¶</a></dt> <dd><p>Search the specified list of directories for a static or shared library file <em>lib</em> and return the full path to that file. If <em>debug</em> is true, look for a debugging version (if that makes sense on the current platform). Return <tt class="docutils literal"><span class="pre">None</span></tt> if <em>lib</em> wasn’t found in any of the specified directories.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.has_function"> <tt class="descname">has_function</tt><big>(</big><em>funcname</em><span class="optional">[</span>, <em>includes=None</em>, <em>include_dirs=None</em>, <em>libraries=None</em>, <em>library_dirs=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.has_function" title="Permalink to this definition">¶</a></dt> <dd><p>Return a boolean indicating whether <em>funcname</em> is supported on the current platform. The optional arguments can be used to augment the compilation environment by providing additional include files and paths and libraries and paths.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.library_dir_option"> <tt class="descname">library_dir_option</tt><big>(</big><em>dir</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.library_dir_option" title="Permalink to this definition">¶</a></dt> <dd><p>Return the compiler option to add <em>dir</em> to the list of directories searched for libraries.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.library_option"> <tt class="descname">library_option</tt><big>(</big><em>lib</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.library_option" title="Permalink to this definition">¶</a></dt> <dd><p>Return the compiler option to add <em>dir</em> to the list of libraries linked into the shared library or executable.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.runtime_library_dir_option"> <tt class="descname">runtime_library_dir_option</tt><big>(</big><em>dir</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.runtime_library_dir_option" title="Permalink to this definition">¶</a></dt> <dd><p>Return the compiler option to add <em>dir</em> to the list of directories searched for runtime libraries.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.set_executables"> <tt class="descname">set_executables</tt><big>(</big><em>**args</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.set_executables" title="Permalink to this definition">¶</a></dt> <dd><p>Define the executables (and options for them) that will be run to perform the various stages of compilation. The exact set of executables that may be specified here depends on the compiler class (via the ‘executables’ class attribute), but most will have:</p> <table border="1" class="docutils"> <colgroup> <col width="25%" /> <col width="75%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">attribute</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>compiler</em></td> <td>the C/C++ compiler</td> </tr> <tr class="row-odd"><td><em>linker_so</em></td> <td>linker used to create shared objects and libraries</td> </tr> <tr class="row-even"><td><em>linker_exe</em></td> <td>linker used to create binary executables</td> </tr> <tr class="row-odd"><td><em>archiver</em></td> <td>static library creator</td> </tr> </tbody> </table> <p>On platforms with a command-line (Unix, DOS/Windows), each of these is a string that will be split into executable name and (optional) list of arguments. (Splitting the string is done similarly to how Unix shells operate: words are delimited by spaces, but quotes and backslashes can override this. See <a class="reference internal" href="#distutils.util.split_quoted" title="distutils.util.split_quoted"><tt class="xref py py-func docutils literal"><span class="pre">distutils.util.split_quoted()</span></tt></a>.)</p> </dd></dl> <p>The following methods invoke stages in the build process.</p> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.compile"> <tt class="descname">compile</tt><big>(</big><em>sources</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>macros=None</em>, <em>include_dirs=None</em>, <em>debug=0</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em>, <em>depends=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.compile" title="Permalink to this definition">¶</a></dt> <dd><p>Compile one or more source files. Generates object files (e.g. transforms a <tt class="file docutils literal"><span class="pre">.c</span></tt> file to a <tt class="file docutils literal"><span class="pre">.o</span></tt> file.)</p> <p><em>sources</em> must be a list of filenames, most likely C/C++ files, but in reality anything that can be handled by a particular compiler and compiler class (eg. <tt class="xref py py-class docutils literal"><span class="pre">MSVCCompiler</span></tt> can handle resource files in <em>sources</em>). Return a list of object filenames, one per source filename in <em>sources</em>. Depending on the implementation, not all source files will necessarily be compiled, but all corresponding object filenames will be returned.</p> <p>If <em>output_dir</em> is given, object files will be put under it, while retaining their original path component. That is, <tt class="file docutils literal"><span class="pre">foo/bar.c</span></tt> normally compiles to <tt class="file docutils literal"><span class="pre">foo/bar.o</span></tt> (for a Unix implementation); if <em>output_dir</em> is <em>build</em>, then it would compile to <tt class="file docutils literal"><span class="pre">build/foo/bar.o</span></tt>.</p> <p><em>macros</em>, if given, must be a list of macro definitions. A macro definition is either a <tt class="docutils literal"><span class="pre">(name,</span> <span class="pre">value)</span></tt> 2-tuple or a <tt class="docutils literal"><span class="pre">(name,)</span></tt> 1-tuple. The former defines a macro; if the value is <tt class="docutils literal"><span class="pre">None</span></tt>, the macro is defined without an explicit value. The 1-tuple case undefines a macro. Later definitions/redefinitions/undefinitions take precedence.</p> <p><em>include_dirs</em>, if given, must be a list of strings, the directories to add to the default include file search path for this compilation only.</p> <p><em>debug</em> is a boolean; if true, the compiler will be instructed to output debug symbols in (or alongside) the object file(s).</p> <p><em>extra_preargs</em> and <em>extra_postargs</em> are implementation-dependent. On platforms that have the notion of a command-line (e.g. Unix, DOS/Windows), they are most likely lists of strings: extra command-line arguments to prepend/append to the compiler command line. On other platforms, consult the implementation class documentation. In any event, they are intended as an escape hatch for those occasions when the abstract compiler framework doesn’t cut the mustard.</p> <p><em>depends</em>, if given, is a list of filenames that all targets depend on. If a source file is older than any file in depends, then the source file will be recompiled. This supports dependency tracking, but only at a coarse granularity.</p> <p>Raises <tt class="xref py py-exc docutils literal"><span class="pre">CompileError</span></tt> on failure.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.create_static_lib"> <tt class="descname">create_static_lib</tt><big>(</big><em>objects</em>, <em>output_libname</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>debug=0</em>, <em>target_lang=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.create_static_lib" title="Permalink to this definition">¶</a></dt> <dd><p>Link a bunch of stuff together to create a static library file. The “bunch of stuff” consists of the list of object files supplied as <em>objects</em>, the extra object files supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_link_object" title="distutils.ccompiler.CCompiler.add_link_object"><tt class="xref py py-meth docutils literal"><span class="pre">add_link_object()</span></tt></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_link_objects" title="distutils.ccompiler.CCompiler.set_link_objects"><tt class="xref py py-meth docutils literal"><span class="pre">set_link_objects()</span></tt></a>, the libraries supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library" title="distutils.ccompiler.CCompiler.add_library"><tt class="xref py py-meth docutils literal"><span class="pre">add_library()</span></tt></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><tt class="xref py py-meth docutils literal"><span class="pre">set_libraries()</span></tt></a>, and the libraries supplied as <em>libraries</em> (if any).</p> <p><em>output_libname</em> should be a library name, not a filename; the filename will be inferred from the library name. <em>output_dir</em> is the directory where the library file will be put.</p> <p><em>debug</em> is a boolean; if true, debugging information will be included in the library (note that on most platforms, it is the compile step where this matters: the <em>debug</em> flag is included here just for consistency).</p> <p><em>target_lang</em> is the target language for which the given objects are being compiled. This allows specific linkage time treatment of certain languages.</p> <p>Raises <tt class="xref py py-exc docutils literal"><span class="pre">LibError</span></tt> on failure.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.link"> <tt class="descname">link</tt><big>(</big><em>target_desc</em>, <em>objects</em>, <em>output_filename</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>libraries=None</em>, <em>library_dirs=None</em>, <em>runtime_library_dirs=None</em>, <em>export_symbols=None</em>, <em>debug=0</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em>, <em>build_temp=None</em>, <em>target_lang=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.link" title="Permalink to this definition">¶</a></dt> <dd><p>Link a bunch of stuff together to create an executable or shared library file.</p> <p>The “bunch of stuff” consists of the list of object files supplied as <em>objects</em>. <em>output_filename</em> should be a filename. If <em>output_dir</em> is supplied, <em>output_filename</em> is relative to it (i.e. <em>output_filename</em> can provide directory components if needed).</p> <p><em>libraries</em> is a list of libraries to link against. These are library names, not filenames, since they’re translated into filenames in a platform-specific way (eg. <em>foo</em> becomes <tt class="file docutils literal"><span class="pre">libfoo.a</span></tt> on Unix and <tt class="file docutils literal"><span class="pre">foo.lib</span></tt> on DOS/Windows). However, they can include a directory component, which means the linker will look in that specific directory rather than searching all the normal locations.</p> <p><em>library_dirs</em>, if supplied, should be a list of directories to search for libraries that were specified as bare library names (ie. no directory component). These are on top of the system default and those supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library_dir" title="distutils.ccompiler.CCompiler.add_library_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_library_dir()</span></tt></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_library_dirs" title="distutils.ccompiler.CCompiler.set_library_dirs"><tt class="xref py py-meth docutils literal"><span class="pre">set_library_dirs()</span></tt></a>. <em>runtime_library_dirs</em> is a list of directories that will be embedded into the shared library and used to search for other shared libraries that *it* depends on at run-time. (This may only be relevant on Unix.)</p> <p><em>export_symbols</em> is a list of symbols that the shared library will export. (This appears to be relevant only on Windows.)</p> <p><em>debug</em> is as for <a class="reference internal" href="../library/functions.html#compile" title="compile"><tt class="xref py py-meth docutils literal"><span class="pre">compile()</span></tt></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.create_static_lib" title="distutils.ccompiler.CCompiler.create_static_lib"><tt class="xref py py-meth docutils literal"><span class="pre">create_static_lib()</span></tt></a>, with the slight distinction that it actually matters on most platforms (as opposed to <a class="reference internal" href="#distutils.ccompiler.CCompiler.create_static_lib" title="distutils.ccompiler.CCompiler.create_static_lib"><tt class="xref py py-meth docutils literal"><span class="pre">create_static_lib()</span></tt></a>, which includes a <em>debug</em> flag mostly for form’s sake).</p> <p><em>extra_preargs</em> and <em>extra_postargs</em> are as for <a class="reference internal" href="../library/functions.html#compile" title="compile"><tt class="xref py py-meth docutils literal"><span class="pre">compile()</span></tt></a> (except of course that they supply command-line arguments for the particular linker being used).</p> <p><em>target_lang</em> is the target language for which the given objects are being compiled. This allows specific linkage time treatment of certain languages.</p> <p>Raises <tt class="xref py py-exc docutils literal"><span class="pre">LinkError</span></tt> on failure.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.link_executable"> <tt class="descname">link_executable</tt><big>(</big><em>objects</em>, <em>output_progname</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>libraries=None</em>, <em>library_dirs=None</em>, <em>runtime_library_dirs=None</em>, <em>debug=0</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em>, <em>target_lang=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.link_executable" title="Permalink to this definition">¶</a></dt> <dd><p>Link an executable. <em>output_progname</em> is the name of the file executable, while <em>objects</em> are a list of object filenames to link in. Other arguments are as for the <a class="reference internal" href="#distutils.ccompiler.CCompiler.link" title="distutils.ccompiler.CCompiler.link"><tt class="xref py py-meth docutils literal"><span class="pre">link()</span></tt></a> method.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.link_shared_lib"> <tt class="descname">link_shared_lib</tt><big>(</big><em>objects</em>, <em>output_libname</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>libraries=None</em>, <em>library_dirs=None</em>, <em>runtime_library_dirs=None</em>, <em>export_symbols=None</em>, <em>debug=0</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em>, <em>build_temp=None</em>, <em>target_lang=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.link_shared_lib" title="Permalink to this definition">¶</a></dt> <dd><p>Link a shared library. <em>output_libname</em> is the name of the output library, while <em>objects</em> is a list of object filenames to link in. Other arguments are as for the <a class="reference internal" href="#distutils.ccompiler.CCompiler.link" title="distutils.ccompiler.CCompiler.link"><tt class="xref py py-meth docutils literal"><span class="pre">link()</span></tt></a> method.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.link_shared_object"> <tt class="descname">link_shared_object</tt><big>(</big><em>objects</em>, <em>output_filename</em><span class="optional">[</span>, <em>output_dir=None</em>, <em>libraries=None</em>, <em>library_dirs=None</em>, <em>runtime_library_dirs=None</em>, <em>export_symbols=None</em>, <em>debug=0</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em>, <em>build_temp=None</em>, <em>target_lang=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.link_shared_object" title="Permalink to this definition">¶</a></dt> <dd><p>Link a shared object. <em>output_filename</em> is the name of the shared object that will be created, while <em>objects</em> is a list of object filenames to link in. Other arguments are as for the <a class="reference internal" href="#distutils.ccompiler.CCompiler.link" title="distutils.ccompiler.CCompiler.link"><tt class="xref py py-meth docutils literal"><span class="pre">link()</span></tt></a> method.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.preprocess"> <tt class="descname">preprocess</tt><big>(</big><em>source</em><span class="optional">[</span>, <em>output_file=None</em>, <em>macros=None</em>, <em>include_dirs=None</em>, <em>extra_preargs=None</em>, <em>extra_postargs=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.preprocess" title="Permalink to this definition">¶</a></dt> <dd><p>Preprocess a single C/C++ source file, named in <em>source</em>. Output will be written to file named <em>output_file</em>, or <em>stdout</em> if <em>output_file</em> not supplied. <em>macros</em> is a list of macro definitions as for <a class="reference internal" href="../library/functions.html#compile" title="compile"><tt class="xref py py-meth docutils literal"><span class="pre">compile()</span></tt></a>, which will augment the macros set with <a class="reference internal" href="#distutils.ccompiler.CCompiler.define_macro" title="distutils.ccompiler.CCompiler.define_macro"><tt class="xref py py-meth docutils literal"><span class="pre">define_macro()</span></tt></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.undefine_macro" title="distutils.ccompiler.CCompiler.undefine_macro"><tt class="xref py py-meth docutils literal"><span class="pre">undefine_macro()</span></tt></a>. <em>include_dirs</em> is a list of directory names that will be added to the default list, in the same way as <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_include_dir" title="distutils.ccompiler.CCompiler.add_include_dir"><tt class="xref py py-meth docutils literal"><span class="pre">add_include_dir()</span></tt></a>.</p> <p>Raises <tt class="xref py py-exc docutils literal"><span class="pre">PreprocessError</span></tt> on failure.</p> </dd></dl> <p>The following utility methods are defined by the <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> class, for use by the various concrete subclasses.</p> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.executable_filename"> <tt class="descname">executable_filename</tt><big>(</big><em>basename</em><span class="optional">[</span>, <em>strip_dir=0</em>, <em>output_dir=''</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.executable_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the filename of the executable for the given <em>basename</em>. Typically for non-Windows platforms this is the same as the basename, while Windows will get a <tt class="file docutils literal"><span class="pre">.exe</span></tt> added.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.library_filename"> <tt class="descname">library_filename</tt><big>(</big><em>libname</em><span class="optional">[</span>, <em>lib_type='static'</em>, <em>strip_dir=0</em>, <em>output_dir=''</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.library_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the filename for the given library name on the current platform. On Unix a library with <em>lib_type</em> of <tt class="docutils literal"><span class="pre">'static'</span></tt> will typically be of the form <tt class="file docutils literal"><span class="pre">liblibname.a</span></tt>, while a <em>lib_type</em> of <tt class="docutils literal"><span class="pre">'dynamic'</span></tt> will be of the form <tt class="file docutils literal"><span class="pre">liblibname.so</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.object_filenames"> <tt class="descname">object_filenames</tt><big>(</big><em>source_filenames</em><span class="optional">[</span>, <em>strip_dir=0</em>, <em>output_dir=''</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.object_filenames" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the name of the object files for the given source files. <em>source_filenames</em> should be a list of filenames.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.shared_object_filename"> <tt class="descname">shared_object_filename</tt><big>(</big><em>basename</em><span class="optional">[</span>, <em>strip_dir=0</em>, <em>output_dir=''</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.shared_object_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the name of a shared object file for the given file name <em>basename</em>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.execute"> <tt class="descname">execute</tt><big>(</big><em>func</em>, <em>args</em><span class="optional">[</span>, <em>msg=None</em>, <em>level=1</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.execute" title="Permalink to this definition">¶</a></dt> <dd><p>Invokes <a class="reference internal" href="#distutils.util.execute" title="distutils.util.execute"><tt class="xref py py-func docutils literal"><span class="pre">distutils.util.execute()</span></tt></a> This method invokes a Python function <em>func</em> with the given arguments <em>args</em>, after logging and taking into account the <em>dry_run</em> flag.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.spawn"> <tt class="descname">spawn</tt><big>(</big><em>cmd</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.spawn" title="Permalink to this definition">¶</a></dt> <dd><p>Invokes <tt class="xref py py-func docutils literal"><span class="pre">distutils.util.spawn()</span></tt>. This invokes an external process to run the given command.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.mkpath"> <tt class="descname">mkpath</tt><big>(</big><em>name</em><span class="optional">[</span>, <em>mode=511</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.mkpath" title="Permalink to this definition">¶</a></dt> <dd><p>Invokes <a class="reference internal" href="#distutils.dir_util.mkpath" title="distutils.dir_util.mkpath"><tt class="xref py py-func docutils literal"><span class="pre">distutils.dir_util.mkpath()</span></tt></a>. This creates a directory and any missing ancestor directories.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.move_file"> <tt class="descname">move_file</tt><big>(</big><em>src</em>, <em>dst</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.move_file" title="Permalink to this definition">¶</a></dt> <dd><p>Invokes <a class="reference internal" href="#distutils.file_util.move_file" title="distutils.file_util.move_file"><tt class="xref py py-meth docutils literal"><span class="pre">distutils.file_util.move_file()</span></tt></a>. Renames <em>src</em> to <em>dst</em>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.announce"> <tt class="descname">announce</tt><big>(</big><em>msg</em><span class="optional">[</span>, <em>level=1</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.announce" title="Permalink to this definition">¶</a></dt> <dd><p>Write a message using <tt class="xref py py-func docutils literal"><span class="pre">distutils.log.debug()</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.warn"> <tt class="descname">warn</tt><big>(</big><em>msg</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.warn" title="Permalink to this definition">¶</a></dt> <dd><p>Write a warning message <em>msg</em> to standard error.</p> </dd></dl> <dl class="method"> <dt id="distutils.ccompiler.CCompiler.debug_print"> <tt class="descname">debug_print</tt><big>(</big><em>msg</em><big>)</big><a class="headerlink" href="#distutils.ccompiler.CCompiler.debug_print" title="Permalink to this definition">¶</a></dt> <dd><p>If the <em>debug</em> flag is set on this <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt></a> instance, print <em>msg</em> to standard output, otherwise do nothing.</p> </dd></dl> </dd></dl> </div> <div class="section" id="module-distutils.unixccompiler"> <span id="distutils-unixccompiler-unix-c-compiler"></span><h2>10.3. <a class="reference internal" href="#module-distutils.unixccompiler" title="distutils.unixccompiler: UNIX C Compiler"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.unixccompiler</span></tt></a> — Unix C Compiler<a class="headerlink" href="#module-distutils.unixccompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-class docutils literal"><span class="pre">UnixCCompiler</span></tt> class, a subclass of <tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt> that handles the typical Unix-style command-line C compiler:</p> <ul class="simple"> <li>macros defined with <em class="xref std std-option">-Dname[=value]</em></li> <li>macros undefined with <em class="xref std std-option">-Uname</em></li> <li>include search directories specified with <em class="xref std std-option">-Idir</em></li> <li>libraries specified with <em class="xref std std-option">-llib</em></li> <li>library search directories specified with <em class="xref std std-option">-Ldir</em></li> <li>compile handled by <strong class="program">cc</strong> (or similar) executable with <a class="reference internal" href="../using/cmdline.html#cmdoption-c"><em class="xref std std-option">-c</em></a> option: compiles <tt class="file docutils literal"><span class="pre">.c</span></tt> to <tt class="file docutils literal"><span class="pre">.o</span></tt></li> <li>link static library handled by <strong class="program">ar</strong> command (possibly with <strong class="program">ranlib</strong>)</li> <li>link shared library handled by <strong class="program">cc</strong> <em class="xref std std-option">-shared</em></li> </ul> </div> <div class="section" id="module-distutils.msvccompiler"> <span id="distutils-msvccompiler-microsoft-compiler"></span><h2>10.4. <a class="reference internal" href="#module-distutils.msvccompiler" title="distutils.msvccompiler: Microsoft Compiler"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.msvccompiler</span></tt></a> — Microsoft Compiler<a class="headerlink" href="#module-distutils.msvccompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides <tt class="xref py py-class docutils literal"><span class="pre">MSVCCompiler</span></tt>, an implementation of the abstract <tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt> class for Microsoft Visual Studio. Typically, extension modules need to be compiled with the same compiler that was used to compile Python. For Python 2.3 and earlier, the compiler was Visual Studio 6. For Python 2.4 and 2.5, the compiler is Visual Studio .NET 2003. The AMD64 and Itanium binaries are created using the Platform SDK.</p> <p><tt class="xref py py-class docutils literal"><span class="pre">MSVCCompiler</span></tt> will normally choose the right compiler, linker etc. on its own. To override this choice, the environment variables <em>DISTUTILS_USE_SDK</em> and <em>MSSdk</em> must be both set. <em>MSSdk</em> indicates that the current environment has been setup by the SDK’s <tt class="docutils literal"><span class="pre">SetEnv.Cmd</span></tt> script, or that the environment variables had been registered when the SDK was installed; <em>DISTUTILS_USE_SDK</em> indicates that the distutils user has made an explicit choice to override the compiler selection by <tt class="xref py py-class docutils literal"><span class="pre">MSVCCompiler</span></tt>.</p> </div> <div class="section" id="module-distutils.bcppcompiler"> <span id="distutils-bcppcompiler-borland-compiler"></span><h2>10.5. <a class="reference internal" href="#module-distutils.bcppcompiler" title="distutils.bcppcompiler"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.bcppcompiler</span></tt></a> — Borland Compiler<a class="headerlink" href="#module-distutils.bcppcompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides <tt class="xref py py-class docutils literal"><span class="pre">BorlandCCompiler</span></tt>, an subclass of the abstract <tt class="xref py py-class docutils literal"><span class="pre">CCompiler</span></tt> class for the Borland C++ compiler.</p> </div> <div class="section" id="module-distutils.cygwinccompiler"> <span id="distutils-cygwincompiler-cygwin-compiler"></span><h2>10.6. <tt class="xref py py-mod docutils literal"><span class="pre">distutils.cygwincompiler</span></tt> — Cygwin Compiler<a class="headerlink" href="#module-distutils.cygwinccompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-class docutils literal"><span class="pre">CygwinCCompiler</span></tt> class, a subclass of <tt class="xref py py-class docutils literal"><span class="pre">UnixCCompiler</span></tt> that handles the Cygwin port of the GNU C compiler to Windows. It also contains the Mingw32CCompiler class which handles the mingw32 port of GCC (same as cygwin in no-cygwin mode).</p> </div> <div class="section" id="module-distutils.emxccompiler"> <span id="distutils-emxccompiler-os-2-emx-compiler"></span><h2>10.7. <a class="reference internal" href="#module-distutils.emxccompiler" title="distutils.emxccompiler: OS/2 EMX Compiler support"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.emxccompiler</span></tt></a> — OS/2 EMX Compiler<a class="headerlink" href="#module-distutils.emxccompiler" title="Permalink to this headline">¶</a></h2> <p>This module provides the EMXCCompiler class, a subclass of <tt class="xref py py-class docutils literal"><span class="pre">UnixCCompiler</span></tt> that handles the EMX port of the GNU C compiler to OS/2.</p> </div> <div class="section" id="module-distutils.archive_util"> <span id="distutils-archive-util-archiving-utilities"></span><h2>10.8. <a class="reference internal" href="#module-distutils.archive_util" title="distutils.archive_util: Utility functions for creating archive files (tarballs, zip files, ...)"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.archive_util</span></tt></a> — Archiving utilities<a class="headerlink" href="#module-distutils.archive_util" title="Permalink to this headline">¶</a></h2> <p>This module provides a few functions for creating archive files, such as tarballs or zipfiles.</p> <dl class="function"> <dt id="distutils.archive_util.make_archive"> <tt class="descclassname">distutils.archive_util.</tt><tt class="descname">make_archive</tt><big>(</big><em>base_name</em>, <em>format</em><span class="optional">[</span>, <em>root_dir=None</em>, <em>base_dir=None</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.archive_util.make_archive" title="Permalink to this definition">¶</a></dt> <dd><p>Create an archive file (eg. <tt class="docutils literal"><span class="pre">zip</span></tt> or <tt class="docutils literal"><span class="pre">tar</span></tt>). <em>base_name</em> is the name of the file to create, minus any format-specific extension; <em>format</em> is the archive format: one of <tt class="docutils literal"><span class="pre">zip</span></tt>, <tt class="docutils literal"><span class="pre">tar</span></tt>, <tt class="docutils literal"><span class="pre">ztar</span></tt>, or <tt class="docutils literal"><span class="pre">gztar</span></tt>. <em>root_dir</em> is a directory that will be the root directory of the archive; ie. we typically <tt class="docutils literal"><span class="pre">chdir</span></tt> into <em>root_dir</em> before creating the archive. <em>base_dir</em> is the directory where we start archiving from; ie. <em>base_dir</em> will be the common prefix of all files and directories in the archive. <em>root_dir</em> and <em>base_dir</em> both default to the current directory. Returns the name of the archive file.</p> </dd></dl> <dl class="function"> <dt id="distutils.archive_util.make_tarball"> <tt class="descclassname">distutils.archive_util.</tt><tt class="descname">make_tarball</tt><big>(</big><em>base_name</em>, <em>base_dir</em><span class="optional">[</span>, <em>compress='gzip'</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.archive_util.make_tarball" title="Permalink to this definition">¶</a></dt> <dd><p>‘Create an (optional compressed) archive as a tar file from all files in and under <em>base_dir</em>. <em>compress</em> must be <tt class="docutils literal"><span class="pre">'gzip'</span></tt> (the default), <tt class="docutils literal"><span class="pre">'compress'</span></tt>, <tt class="docutils literal"><span class="pre">'bzip2'</span></tt>, or <tt class="docutils literal"><span class="pre">None</span></tt>. Both <strong class="program">tar</strong> and the compression utility named by <em>compress</em> must be on the default program search path, so this is probably Unix-specific. The output tar file will be named <tt class="file docutils literal"><span class="pre">base_dir.tar</span></tt>, possibly plus the appropriate compression extension (<tt class="file docutils literal"><span class="pre">.gz</span></tt>, <tt class="file docutils literal"><span class="pre">.bz2</span></tt> or <tt class="file docutils literal"><span class="pre">.Z</span></tt>). Return the output filename.</p> </dd></dl> <dl class="function"> <dt id="distutils.archive_util.make_zipfile"> <tt class="descclassname">distutils.archive_util.</tt><tt class="descname">make_zipfile</tt><big>(</big><em>base_name</em>, <em>base_dir</em><span class="optional">[</span>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.archive_util.make_zipfile" title="Permalink to this definition">¶</a></dt> <dd><p>Create a zip file from all files in and under <em>base_dir</em>. The output zip file will be named <em>base_name</em> + <tt class="file docutils literal"><span class="pre">.zip</span></tt>. Uses either the <a class="reference internal" href="../library/zipfile.html#module-zipfile" title="zipfile: Read and write ZIP-format archive files."><tt class="xref py py-mod docutils literal"><span class="pre">zipfile</span></tt></a> Python module (if available) or the InfoZIP <tt class="file docutils literal"><span class="pre">zip</span></tt> utility (if installed and found on the default search path). If neither tool is available, raises <tt class="xref py py-exc docutils literal"><span class="pre">DistutilsExecError</span></tt>. Returns the name of the output zip file.</p> </dd></dl> </div> <div class="section" id="module-distutils.dep_util"> <span id="distutils-dep-util-dependency-checking"></span><h2>10.9. <a class="reference internal" href="#module-distutils.dep_util" title="distutils.dep_util: Utility functions for simple dependency checking"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.dep_util</span></tt></a> — Dependency checking<a class="headerlink" href="#module-distutils.dep_util" title="Permalink to this headline">¶</a></h2> <p>This module provides functions for performing simple, timestamp-based dependency of files and groups of files; also, functions based entirely on such timestamp dependency analysis.</p> <dl class="function"> <dt id="distutils.dep_util.newer"> <tt class="descclassname">distutils.dep_util.</tt><tt class="descname">newer</tt><big>(</big><em>source</em>, <em>target</em><big>)</big><a class="headerlink" href="#distutils.dep_util.newer" title="Permalink to this definition">¶</a></dt> <dd><p>Return true if <em>source</em> exists and is more recently modified than <em>target</em>, or if <em>source</em> exists and <em>target</em> doesn’t. Return false if both exist and <em>target</em> is the same age or newer than <em>source</em>. Raise <tt class="xref py py-exc docutils literal"><span class="pre">DistutilsFileError</span></tt> if <em>source</em> does not exist.</p> </dd></dl> <dl class="function"> <dt id="distutils.dep_util.newer_pairwise"> <tt class="descclassname">distutils.dep_util.</tt><tt class="descname">newer_pairwise</tt><big>(</big><em>sources</em>, <em>targets</em><big>)</big><a class="headerlink" href="#distutils.dep_util.newer_pairwise" title="Permalink to this definition">¶</a></dt> <dd><p>Walk two filename lists in parallel, testing if each source is newer than its corresponding target. Return a pair of lists (<em>sources</em>, <em>targets</em>) where source is newer than target, according to the semantics of <a class="reference internal" href="#distutils.dep_util.newer" title="distutils.dep_util.newer"><tt class="xref py py-func docutils literal"><span class="pre">newer()</span></tt></a></p> </dd></dl> <dl class="function"> <dt id="distutils.dep_util.newer_group"> <tt class="descclassname">distutils.dep_util.</tt><tt class="descname">newer_group</tt><big>(</big><em>sources</em>, <em>target</em><span class="optional">[</span>, <em>missing='error'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.dep_util.newer_group" title="Permalink to this definition">¶</a></dt> <dd><p>Return true if <em>target</em> is out-of-date with respect to any file listed in <em>sources</em> In other words, if <em>target</em> exists and is newer than every file in <em>sources</em>, return false; otherwise return true. <em>missing</em> controls what we do when a source file is missing; the default (<tt class="docutils literal"><span class="pre">'error'</span></tt>) is to blow up with an <a class="reference internal" href="../library/exceptions.html#exceptions.OSError" title="exceptions.OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> from inside <a class="reference internal" href="../library/os.html#os.stat" title="os.stat"><tt class="xref py py-func docutils literal"><span class="pre">os.stat()</span></tt></a>; if it is <tt class="docutils literal"><span class="pre">'ignore'</span></tt>, we silently drop any missing source files; if it is <tt class="docutils literal"><span class="pre">'newer'</span></tt>, any missing source files make us assume that <em>target</em> is out-of-date (this is handy in “dry-run” mode: it’ll make you pretend to carry out commands that wouldn’t work because inputs are missing, but that doesn’t matter because you’re not actually going to run the commands).</p> </dd></dl> </div> <div class="section" id="module-distutils.dir_util"> <span id="distutils-dir-util-directory-tree-operations"></span><h2>10.10. <a class="reference internal" href="#module-distutils.dir_util" title="distutils.dir_util: Utility functions for operating on directories and directory trees"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.dir_util</span></tt></a> — Directory tree operations<a class="headerlink" href="#module-distutils.dir_util" title="Permalink to this headline">¶</a></h2> <p>This module provides functions for operating on directories and trees of directories.</p> <dl class="function"> <dt id="distutils.dir_util.mkpath"> <tt class="descclassname">distutils.dir_util.</tt><tt class="descname">mkpath</tt><big>(</big><em>name</em><span class="optional">[</span>, <em>mode=0777</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.dir_util.mkpath" title="Permalink to this definition">¶</a></dt> <dd><p>Create a directory and any missing ancestor directories. If the directory already exists (or if <em>name</em> is the empty string, which means the current directory, which of course exists), then do nothing. Raise <tt class="xref py py-exc docutils literal"><span class="pre">DistutilsFileError</span></tt> if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If <em>verbose</em> is true, print a one-line summary of each mkdir to stdout. Return the list of directories actually created.</p> </dd></dl> <dl class="function"> <dt id="distutils.dir_util.create_tree"> <tt class="descclassname">distutils.dir_util.</tt><tt class="descname">create_tree</tt><big>(</big><em>base_dir</em>, <em>files</em><span class="optional">[</span>, <em>mode=0777</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.dir_util.create_tree" title="Permalink to this definition">¶</a></dt> <dd><p>Create all the empty directories under <em>base_dir</em> needed to put <em>files</em> there. <em>base_dir</em> is just the a name of a directory which doesn’t necessarily exist yet; <em>files</em> is a list of filenames to be interpreted relative to <em>base_dir</em>. <em>base_dir</em> + the directory portion of every file in <em>files</em> will be created if it doesn’t already exist. <em>mode</em>, <em>verbose</em> and <em>dry_run</em> flags are as for <a class="reference internal" href="#distutils.dir_util.mkpath" title="distutils.dir_util.mkpath"><tt class="xref py py-func docutils literal"><span class="pre">mkpath()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="distutils.dir_util.copy_tree"> <tt class="descclassname">distutils.dir_util.</tt><tt class="descname">copy_tree</tt><big>(</big><em>src</em>, <em>dst</em><span class="optional">[</span>, <em>preserve_mode=1</em>, <em>preserve_times=1</em>, <em>preserve_symlinks=0</em>, <em>update=0</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.dir_util.copy_tree" title="Permalink to this definition">¶</a></dt> <dd><p>Copy an entire directory tree <em>src</em> to a new location <em>dst</em>. Both <em>src</em> and <em>dst</em> must be directory names. If <em>src</em> is not a directory, raise <tt class="xref py py-exc docutils literal"><span class="pre">DistutilsFileError</span></tt>. If <em>dst</em> does not exist, it is created with <a class="reference internal" href="#distutils.dir_util.mkpath" title="distutils.dir_util.mkpath"><tt class="xref py py-func docutils literal"><span class="pre">mkpath()</span></tt></a>. The end result of the copy is that every file in <em>src</em> is copied to <em>dst</em>, and directories under <em>src</em> are recursively copied to <em>dst</em>. Return the list of files that were copied or might have been copied, using their output name. The return value is unaffected by <em>update</em> or <em>dry_run</em>: it is simply the list of all files under <em>src</em>, with the names changed to be under <em>dst</em>.</p> <p><em>preserve_mode</em> and <em>preserve_times</em> are the same as for <tt class="xref py py-func docutils literal"><span class="pre">copy_file()</span></tt> in <a class="reference internal" href="#module-distutils.file_util" title="distutils.file_util: Utility functions for operating on single files"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.file_util</span></tt></a>; note that they only apply to regular files, not to directories. If <em>preserve_symlinks</em> is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. <em>update</em> and <em>verbose</em> are the same as for <tt class="xref py py-func docutils literal"><span class="pre">copy_file()</span></tt>.</p> <p>Files in <em>src</em> that begin with <tt class="file docutils literal"><span class="pre">.nfs</span></tt> are skipped (more information on these files is available in answer D2 of the <a class="reference external" href="http://nfs.sourceforge.net/#section_d">NFS FAQ page</a>.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.7.4: </span>NFS files are ignored.</p> </dd></dl> <dl class="function"> <dt id="distutils.dir_util.remove_tree"> <tt class="descclassname">distutils.dir_util.</tt><tt class="descname">remove_tree</tt><big>(</big><em>directory</em><span class="optional">[</span>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.dir_util.remove_tree" title="Permalink to this definition">¶</a></dt> <dd><p>Recursively remove <em>directory</em> and all files and directories underneath it. Any errors are ignored (apart from being reported to <tt class="docutils literal"><span class="pre">sys.stdout</span></tt> if <em>verbose</em> is true).</p> </dd></dl> </div> <div class="section" id="module-distutils.file_util"> <span id="distutils-file-util-single-file-operations"></span><h2>10.11. <a class="reference internal" href="#module-distutils.file_util" title="distutils.file_util: Utility functions for operating on single files"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.file_util</span></tt></a> — Single file operations<a class="headerlink" href="#module-distutils.file_util" title="Permalink to this headline">¶</a></h2> <p>This module contains some utility functions for operating on individual files.</p> <dl class="function"> <dt id="distutils.file_util.copy_file"> <tt class="descclassname">distutils.file_util.</tt><tt class="descname">copy_file</tt><big>(</big><em>src</em>, <em>dst</em><span class="optional">[</span>, <em>preserve_mode=1</em>, <em>preserve_times=1</em>, <em>update=0</em>, <em>link=None</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.file_util.copy_file" title="Permalink to this definition">¶</a></dt> <dd><p>Copy file <em>src</em> to <em>dst</em>. If <em>dst</em> is a directory, then <em>src</em> is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered.) If <em>preserve_mode</em> is true (the default), the file’s mode (type and permission bits, or whatever is analogous on the current platform) is copied. If <em>preserve_times</em> is true (the default), the last-modified and last-access times are copied as well. If <em>update</em> is true, <em>src</em> will only be copied if <em>dst</em> does not exist, or if <em>dst</em> does exist but is older than <em>src</em>.</p> <p><em>link</em> allows you to make hard links (using <a class="reference internal" href="../library/os.html#os.link" title="os.link"><tt class="xref py py-func docutils literal"><span class="pre">os.link()</span></tt></a>) or symbolic links (using <a class="reference internal" href="../library/os.html#os.symlink" title="os.symlink"><tt class="xref py py-func docutils literal"><span class="pre">os.symlink()</span></tt></a>) instead of copying: set it to <tt class="docutils literal"><span class="pre">'hard'</span></tt> or <tt class="docutils literal"><span class="pre">'sym'</span></tt>; if it is <tt class="docutils literal"><span class="pre">None</span></tt> (the default), files are copied. Don’t set <em>link</em> on systems that don’t support it: <a class="reference internal" href="#distutils.file_util.copy_file" title="distutils.file_util.copy_file"><tt class="xref py py-func docutils literal"><span class="pre">copy_file()</span></tt></a> doesn’t check if hard or symbolic linking is available. It uses <tt class="xref py py-func docutils literal"><span class="pre">_copy_file_contents()</span></tt> to copy file contents.</p> <p>Return a tuple <tt class="docutils literal"><span class="pre">(dest_name,</span> <span class="pre">copied)</span></tt>: <em>dest_name</em> is the actual name of the output file, and <em>copied</em> is true if the file was copied (or would have been copied, if <em>dry_run</em> true).</p> </dd></dl> <dl class="function"> <dt id="distutils.file_util.move_file"> <tt class="descclassname">distutils.file_util.</tt><tt class="descname">move_file</tt><big>(</big><em>src</em>, <em>dst</em><span class="optional">[</span>, <em>verbose</em>, <em>dry_run</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.file_util.move_file" title="Permalink to this definition">¶</a></dt> <dd><p>Move file <em>src</em> to <em>dst</em>. If <em>dst</em> is a directory, the file will be moved into it with the same name; otherwise, <em>src</em> is just renamed to <em>dst</em>. Returns the new full name of the file.</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Handles cross-device moves on Unix using <a class="reference internal" href="#distutils.file_util.copy_file" title="distutils.file_util.copy_file"><tt class="xref py py-func docutils literal"><span class="pre">copy_file()</span></tt></a>. What about other systems?</p> </div> </dd></dl> <dl class="function"> <dt id="distutils.file_util.write_file"> <tt class="descclassname">distutils.file_util.</tt><tt class="descname">write_file</tt><big>(</big><em>filename</em>, <em>contents</em><big>)</big><a class="headerlink" href="#distutils.file_util.write_file" title="Permalink to this definition">¶</a></dt> <dd><p>Create a file called <em>filename</em> and write <em>contents</em> (a sequence of strings without line terminators) to it.</p> </dd></dl> </div> <div class="section" id="module-distutils.util"> <span id="distutils-util-miscellaneous-other-utility-functions"></span><h2>10.12. <a class="reference internal" href="#module-distutils.util" title="distutils.util: Miscellaneous other utility functions"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.util</span></tt></a> — Miscellaneous other utility functions<a class="headerlink" href="#module-distutils.util" title="Permalink to this headline">¶</a></h2> <p>This module contains other assorted bits and pieces that don’t fit into any other utility module.</p> <dl class="function"> <dt id="distutils.util.get_platform"> <tt class="descclassname">distutils.util.</tt><tt class="descname">get_platform</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.util.get_platform" title="Permalink to this definition">¶</a></dt> <dd><p>Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by ‘os.uname()’), although the exact information included depends on the OS; eg. for IRIX the architecture isn’t particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn’t particularly important.</p> <p>Examples of returned values:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">linux-i586</span></tt></li> <li><tt class="docutils literal"><span class="pre">linux-alpha</span></tt></li> <li><tt class="docutils literal"><span class="pre">solaris-2.6-sun4u</span></tt></li> <li><tt class="docutils literal"><span class="pre">irix-5.3</span></tt></li> <li><tt class="docutils literal"><span class="pre">irix64-6.2</span></tt></li> </ul> <p>For non-POSIX platforms, currently just returns <tt class="docutils literal"><span class="pre">sys.platform</span></tt>.</p> <p>For Mac OS X systems the OS version reflects the minimal version on which binaries will run (that is, the value of <tt class="docutils literal"><span class="pre">MACOSX_DEPLOYMENT_TARGET</span></tt> during the build of Python), not the OS version of the current system.</p> <p>For universal binary builds on Mac OS X the architecture value reflects the univeral binary status instead of the architecture of the current processor. For 32-bit universal binaries the architecture is <tt class="docutils literal"><span class="pre">fat</span></tt>, for 64-bit universal binaries the architecture is <tt class="docutils literal"><span class="pre">fat64</span></tt>, and for 4-way universal binaries the architecture is <tt class="docutils literal"><span class="pre">universal</span></tt>. Starting from Python 2.7 and Python 3.2 the architecture <tt class="docutils literal"><span class="pre">fat3</span></tt> is used for a 3-way universal build (ppc, i386, x86_64) and <tt class="docutils literal"><span class="pre">intel</span></tt> is used for a univeral build with the i386 and x86_64 architectures</p> <p>Examples of returned values on Mac OS X:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">macosx-10.3-ppc</span></tt></li> <li><tt class="docutils literal"><span class="pre">macosx-10.3-fat</span></tt></li> <li><tt class="docutils literal"><span class="pre">macosx-10.5-universal</span></tt></li> <li><tt class="docutils literal"><span class="pre">macosx-10.6-intel</span></tt></li> </ul> </dd></dl> <dl class="function"> <dt id="distutils.util.convert_path"> <tt class="descclassname">distutils.util.</tt><tt class="descname">convert_path</tt><big>(</big><em>pathname</em><big>)</big><a class="headerlink" href="#distutils.util.convert_path" title="Permalink to this definition">¶</a></dt> <dd><p>Return ‘pathname’ as a name that will work on the native filesystem, i.e. split it on ‘/’ and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises <a class="reference internal" href="../library/exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> on non-Unix-ish systems if <em>pathname</em> either starts or ends with a slash.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.change_root"> <tt class="descclassname">distutils.util.</tt><tt class="descname">change_root</tt><big>(</big><em>new_root</em>, <em>pathname</em><big>)</big><a class="headerlink" href="#distutils.util.change_root" title="Permalink to this definition">¶</a></dt> <dd><p>Return <em>pathname</em> with <em>new_root</em> prepended. If <em>pathname</em> is relative, this is equivalent to <tt class="docutils literal"><span class="pre">os.path.join(new_root,pathname)</span></tt> Otherwise, it requires making <em>pathname</em> relative and then joining the two, which is tricky on DOS/Windows.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.check_environ"> <tt class="descclassname">distutils.util.</tt><tt class="descname">check_environ</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.util.check_environ" title="Permalink to this definition">¶</a></dt> <dd><p>Ensure that ‘os.environ’ has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes:</p> <ul class="simple"> <li><span class="target" id="index-1"></span><tt class="xref std std-envvar docutils literal"><span class="pre">HOME</span></tt> - user’s home directory (Unix only)</li> <li><span class="target" id="index-2"></span><tt class="xref std std-envvar docutils literal"><span class="pre">PLAT</span></tt> - description of the current platform, including hardware and OS (see <a class="reference internal" href="#distutils.util.get_platform" title="distutils.util.get_platform"><tt class="xref py py-func docutils literal"><span class="pre">get_platform()</span></tt></a>)</li> </ul> </dd></dl> <dl class="function"> <dt id="distutils.util.subst_vars"> <tt class="descclassname">distutils.util.</tt><tt class="descname">subst_vars</tt><big>(</big><em>s</em>, <em>local_vars</em><big>)</big><a class="headerlink" href="#distutils.util.subst_vars" title="Permalink to this definition">¶</a></dt> <dd><p>Perform shell/Perl-style variable substitution on <em>s</em>. Every occurrence of <tt class="docutils literal"><span class="pre">$</span></tt> followed by a name is considered a variable, and variable is substituted by the value found in the <em>local_vars</em> dictionary, or in <tt class="docutils literal"><span class="pre">os.environ</span></tt> if it’s not in <em>local_vars</em>. <em>os.environ</em> is first checked/augmented to guarantee that it contains certain values: see <a class="reference internal" href="#distutils.util.check_environ" title="distutils.util.check_environ"><tt class="xref py py-func docutils literal"><span class="pre">check_environ()</span></tt></a>. Raise <a class="reference internal" href="../library/exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> for any variables not found in either <em>local_vars</em> or <tt class="docutils literal"><span class="pre">os.environ</span></tt>.</p> <p>Note that this is not a fully-fledged string interpolation function. A valid <tt class="docutils literal"><span class="pre">$variable</span></tt> can consist only of upper and lower case letters, numbers and an underscore. No { } or ( ) style quoting is available.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.grok_environment_error"> <tt class="descclassname">distutils.util.</tt><tt class="descname">grok_environment_error</tt><big>(</big><em>exc</em><span class="optional">[</span>, <em>prefix='error: '</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.util.grok_environment_error" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a useful error message from an <a class="reference internal" href="../library/exceptions.html#exceptions.EnvironmentError" title="exceptions.EnvironmentError"><tt class="xref py py-exc docutils literal"><span class="pre">EnvironmentError</span></tt></a> (<a class="reference internal" href="../library/exceptions.html#exceptions.IOError" title="exceptions.IOError"><tt class="xref py py-exc docutils literal"><span class="pre">IOError</span></tt></a> or <a class="reference internal" href="../library/exceptions.html#exceptions.OSError" title="exceptions.OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a>) exception object. Handles Python 1.5.1 and later styles, and does what it can to deal with exception objects that don’t have a filename (which happens when the error is due to a two-file operation, such as <tt class="xref py py-func docutils literal"><span class="pre">rename()</span></tt> or <tt class="xref py py-func docutils literal"><span class="pre">link()</span></tt>). Returns the error message as a string prefixed with <em>prefix</em>.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.split_quoted"> <tt class="descclassname">distutils.util.</tt><tt class="descname">split_quoted</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#distutils.util.split_quoted" title="Permalink to this definition">¶</a></dt> <dd><p>Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The backslash is stripped from any two-character escape sequence, leaving only the escaped character. The quote characters are stripped from any quoted string. Returns a list of words.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.execute"> <tt class="descclassname">distutils.util.</tt><tt class="descname">execute</tt><big>(</big><em>func</em>, <em>args</em><span class="optional">[</span>, <em>msg=None</em>, <em>verbose=0</em>, <em>dry_run=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.util.execute" title="Permalink to this definition">¶</a></dt> <dd><p>Perform some action that affects the outside world (for instance, writing to the filesystem). Such actions are special because they are disabled by the <em>dry_run</em> flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to embody the “external action” being performed), and an optional message to print.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.strtobool"> <tt class="descclassname">distutils.util.</tt><tt class="descname">strtobool</tt><big>(</big><em>val</em><big>)</big><a class="headerlink" href="#distutils.util.strtobool" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a string representation of truth to true (1) or false (0).</p> <p>True values are <tt class="docutils literal"><span class="pre">y</span></tt>, <tt class="docutils literal"><span class="pre">yes</span></tt>, <tt class="docutils literal"><span class="pre">t</span></tt>, <tt class="docutils literal"><span class="pre">true</span></tt>, <tt class="docutils literal"><span class="pre">on</span></tt> and <tt class="docutils literal"><span class="pre">1</span></tt>; false values are <tt class="docutils literal"><span class="pre">n</span></tt>, <tt class="docutils literal"><span class="pre">no</span></tt>, <tt class="docutils literal"><span class="pre">f</span></tt>, <tt class="docutils literal"><span class="pre">false</span></tt>, <tt class="docutils literal"><span class="pre">off</span></tt> and <tt class="docutils literal"><span class="pre">0</span></tt>. Raises <a class="reference internal" href="../library/exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> if <em>val</em> is anything else.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.byte_compile"> <tt class="descclassname">distutils.util.</tt><tt class="descname">byte_compile</tt><big>(</big><em>py_files</em><span class="optional">[</span>, <em>optimize=0</em>, <em>force=0</em>, <em>prefix=None</em>, <em>base_dir=None</em>, <em>verbose=1</em>, <em>dry_run=0</em>, <em>direct=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.util.byte_compile" title="Permalink to this definition">¶</a></dt> <dd><p>Byte-compile a collection of Python source files to either <tt class="file docutils literal"><span class="pre">.pyc</span></tt> or <tt class="file docutils literal"><span class="pre">.pyo</span></tt> files in the same directory. <em>py_files</em> is a list of files to compile; any files that don’t end in <tt class="file docutils literal"><span class="pre">.py</span></tt> are silently skipped. <em>optimize</em> must be one of the following:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">0</span></tt> - don’t optimize (generate <tt class="file docutils literal"><span class="pre">.pyc</span></tt>)</li> <li><tt class="docutils literal"><span class="pre">1</span></tt> - normal optimization (like <tt class="docutils literal"><span class="pre">python</span> <span class="pre">-O</span></tt>)</li> <li><tt class="docutils literal"><span class="pre">2</span></tt> - extra optimization (like <tt class="docutils literal"><span class="pre">python</span> <span class="pre">-OO</span></tt>)</li> </ul> <p>If <em>force</em> is true, all files are recompiled regardless of timestamps.</p> <p>The source filename encoded in each <a class="reference internal" href="../glossary.html#term-bytecode"><em class="xref std std-term">bytecode</em></a> file defaults to the filenames listed in <em>py_files</em>; you can modify these with <em>prefix</em> and <em>basedir</em>. <em>prefix</em> is a string that will be stripped off of each source filename, and <em>base_dir</em> is a directory name that will be prepended (after <em>prefix</em> is stripped). You can supply either or both (or neither) of <em>prefix</em> and <em>base_dir</em>, as you wish.</p> <p>If <em>dry_run</em> is true, doesn’t actually do anything that would affect the filesystem.</p> <p>Byte-compilation is either done directly in this interpreter process with the standard <a class="reference internal" href="../library/py_compile.html#module-py_compile" title="py_compile: Generate byte-code files from Python source files."><tt class="xref py py-mod docutils literal"><span class="pre">py_compile</span></tt></a> module, or indirectly by writing a temporary script and executing it. Normally, you should let <a class="reference internal" href="#distutils.util.byte_compile" title="distutils.util.byte_compile"><tt class="xref py py-func docutils literal"><span class="pre">byte_compile()</span></tt></a> figure out to use direct compilation or not (see the source for details). The <em>direct</em> flag is used by the script generated in indirect mode; unless you know what you’re doing, leave it set to <tt class="docutils literal"><span class="pre">None</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="distutils.util.rfc822_escape"> <tt class="descclassname">distutils.util.</tt><tt class="descname">rfc822_escape</tt><big>(</big><em>header</em><big>)</big><a class="headerlink" href="#distutils.util.rfc822_escape" title="Permalink to this definition">¶</a></dt> <dd><p>Return a version of <em>header</em> escaped for inclusion in an <span class="target" id="index-3"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc822.html"><strong>RFC 822</strong></a> header, by ensuring there are 8 spaces space after each newline. Note that it does no other modification of the string.</p> </dd></dl> </div> <div class="section" id="module-distutils.dist"> <span id="distutils-dist-the-distribution-class"></span><h2>10.13. <a class="reference internal" href="#module-distutils.dist" title="distutils.dist: Provides the Distribution class, which represents the module distribution being built/installed/distributed"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.dist</span></tt></a> — The Distribution class<a class="headerlink" href="#module-distutils.dist" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt> class, which represents the module distribution being built/installed/distributed.</p> </div> <div class="section" id="module-distutils.extension"> <span id="distutils-extension-the-extension-class"></span><h2>10.14. <a class="reference internal" href="#module-distutils.extension" title="distutils.extension: Provides the Extension class, used to describe C/C++ extension modules in setup scripts"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.extension</span></tt></a> — The Extension class<a class="headerlink" href="#module-distutils.extension" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-class docutils literal"><span class="pre">Extension</span></tt> class, used to describe C/C++ extension modules in setup scripts.</p> </div> <div class="section" id="module-distutils.debug"> <span id="distutils-debug-distutils-debug-mode"></span><h2>10.15. <a class="reference internal" href="#module-distutils.debug" title="distutils.debug: Provides the debug flag for distutils"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.debug</span></tt></a> — Distutils debug mode<a class="headerlink" href="#module-distutils.debug" title="Permalink to this headline">¶</a></h2> <p>This module provides the DEBUG flag.</p> </div> <div class="section" id="module-distutils.errors"> <span id="distutils-errors-distutils-exceptions"></span><h2>10.16. <a class="reference internal" href="#module-distutils.errors" title="distutils.errors: Provides standard distutils exceptions"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.errors</span></tt></a> — Distutils exceptions<a class="headerlink" href="#module-distutils.errors" title="Permalink to this headline">¶</a></h2> <p>Provides exceptions used by the Distutils modules. Note that Distutils modules may raise standard exceptions; in particular, SystemExit is usually raised for errors that are obviously the end-user’s fault (eg. bad command-line arguments).</p> <p>This module is safe to use in <tt class="docutils literal"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span> <span class="pre">*</span></tt> mode; it only exports symbols whose names start with <tt class="docutils literal"><span class="pre">Distutils</span></tt> and end with <tt class="docutils literal"><span class="pre">Error</span></tt>.</p> </div> <div class="section" id="module-distutils.fancy_getopt"> <span id="distutils-fancy-getopt-wrapper-around-the-standard-getopt-module"></span><h2>10.17. <a class="reference internal" href="#module-distutils.fancy_getopt" title="distutils.fancy_getopt: Additional getopt functionality"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.fancy_getopt</span></tt></a> — Wrapper around the standard getopt module<a class="headerlink" href="#module-distutils.fancy_getopt" title="Permalink to this headline">¶</a></h2> <p>This module provides a wrapper around the standard <a class="reference internal" href="../library/getopt.html#module-getopt" title="getopt: Portable parser for command line options; support both short and long option names."><tt class="xref py py-mod docutils literal"><span class="pre">getopt</span></tt></a> module that provides the following additional features:</p> <ul class="simple"> <li>short and long options are tied together</li> <li>options have help strings, so <a class="reference internal" href="#distutils.fancy_getopt.fancy_getopt" title="distutils.fancy_getopt.fancy_getopt"><tt class="xref py py-func docutils literal"><span class="pre">fancy_getopt()</span></tt></a> could potentially create a complete usage summary</li> <li>options set attributes of a passed-in object</li> <li>boolean options can have “negative aliases” — eg. if <em class="xref std std-option">--quiet</em> is the “negative alias” of <em class="xref std std-option">--verbose</em>, then <em class="xref std std-option">--quiet</em> on the command line sets <em>verbose</em> to false.</li> </ul> <dl class="function"> <dt id="distutils.fancy_getopt.fancy_getopt"> <tt class="descclassname">distutils.fancy_getopt.</tt><tt class="descname">fancy_getopt</tt><big>(</big><em>options</em>, <em>negative_opt</em>, <em>object</em>, <em>args</em><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.fancy_getopt" title="Permalink to this definition">¶</a></dt> <dd><p>Wrapper function. <em>options</em> is a list of <tt class="docutils literal"><span class="pre">(long_option,</span> <span class="pre">short_option,</span> <span class="pre">help_string)</span></tt> 3-tuples as described in the constructor for <a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><tt class="xref py py-class docutils literal"><span class="pre">FancyGetopt</span></tt></a>. <em>negative_opt</em> should be a dictionary mapping option names to option names, both the key and value should be in the <em>options</em> list. <em>object</em> is an object which will be used to store values (see the <a class="reference internal" href="../library/getopt.html#module-getopt" title="getopt: Portable parser for command line options; support both short and long option names."><tt class="xref py py-meth docutils literal"><span class="pre">getopt()</span></tt></a> method of the <a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><tt class="xref py py-class docutils literal"><span class="pre">FancyGetopt</span></tt></a> class). <em>args</em> is the argument list. Will use <tt class="docutils literal"><span class="pre">sys.argv[1:]</span></tt> if you pass <tt class="docutils literal"><span class="pre">None</span></tt> as <em>args</em>.</p> </dd></dl> <dl class="function"> <dt id="distutils.fancy_getopt.wrap_text"> <tt class="descclassname">distutils.fancy_getopt.</tt><tt class="descname">wrap_text</tt><big>(</big><em>text</em>, <em>width</em><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.wrap_text" title="Permalink to this definition">¶</a></dt> <dd><p>Wraps <em>text</em> to less than <em>width</em> wide.</p> </dd></dl> <dl class="class"> <dt id="distutils.fancy_getopt.FancyGetopt"> <em class="property">class </em><tt class="descclassname">distutils.fancy_getopt.</tt><tt class="descname">FancyGetopt</tt><big>(</big><span class="optional">[</span><em>option_table=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.FancyGetopt" title="Permalink to this definition">¶</a></dt> <dd><p>The option_table is a list of 3-tuples: <tt class="docutils literal"><span class="pre">(long_option,</span> <span class="pre">short_option,</span> <span class="pre">help_string)</span></tt></p> <p>If an option takes an argument, its <em>long_option</em> should have <tt class="docutils literal"><span class="pre">'='</span></tt> appended; <em>short_option</em> should just be a single character, no <tt class="docutils literal"><span class="pre">':'</span></tt> in any case. <em>short_option</em> should be <tt class="docutils literal"><span class="pre">None</span></tt> if a <em>long_option</em> doesn’t have a corresponding <em>short_option</em>. All option tuples must have long options.</p> </dd></dl> <p>The <a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><tt class="xref py py-class docutils literal"><span class="pre">FancyGetopt</span></tt></a> class provides the following methods:</p> <dl class="method"> <dt id="distutils.fancy_getopt.FancyGetopt.getopt"> <tt class="descclassname">FancyGetopt.</tt><tt class="descname">getopt</tt><big>(</big><span class="optional">[</span><em>args=None</em>, <em>object=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.FancyGetopt.getopt" title="Permalink to this definition">¶</a></dt> <dd><p>Parse command-line options in args. Store as attributes on <em>object</em>.</p> <p>If <em>args</em> is <tt class="docutils literal"><span class="pre">None</span></tt> or not supplied, uses <tt class="docutils literal"><span class="pre">sys.argv[1:]</span></tt>. If <em>object</em> is <tt class="docutils literal"><span class="pre">None</span></tt> or not supplied, creates a new <tt class="xref py py-class docutils literal"><span class="pre">OptionDummy</span></tt> instance, stores option values there, and returns a tuple <tt class="docutils literal"><span class="pre">(args,</span> <span class="pre">object)</span></tt>. If <em>object</em> is supplied, it is modified in place and <a class="reference internal" href="../library/getopt.html#module-getopt" title="getopt: Portable parser for command line options; support both short and long option names."><tt class="xref py py-func docutils literal"><span class="pre">getopt()</span></tt></a> just returns <em>args</em>; in both cases, the returned <em>args</em> is a modified copy of the passed-in <em>args</em> list, which is left untouched.</p> </dd></dl> <dl class="method"> <dt id="distutils.fancy_getopt.FancyGetopt.get_option_order"> <tt class="descclassname">FancyGetopt.</tt><tt class="descname">get_option_order</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.FancyGetopt.get_option_order" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the list of <tt class="docutils literal"><span class="pre">(option,</span> <span class="pre">value)</span></tt> tuples processed by the previous run of <a class="reference internal" href="../library/getopt.html#module-getopt" title="getopt: Portable parser for command line options; support both short and long option names."><tt class="xref py py-meth docutils literal"><span class="pre">getopt()</span></tt></a> Raises <a class="reference internal" href="../library/exceptions.html#exceptions.RuntimeError" title="exceptions.RuntimeError"><tt class="xref py py-exc docutils literal"><span class="pre">RuntimeError</span></tt></a> if <a class="reference internal" href="../library/getopt.html#module-getopt" title="getopt: Portable parser for command line options; support both short and long option names."><tt class="xref py py-meth docutils literal"><span class="pre">getopt()</span></tt></a> hasn’t been called yet.</p> </dd></dl> <dl class="method"> <dt id="distutils.fancy_getopt.FancyGetopt.generate_help"> <tt class="descclassname">FancyGetopt.</tt><tt class="descname">generate_help</tt><big>(</big><span class="optional">[</span><em>header=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.fancy_getopt.FancyGetopt.generate_help" title="Permalink to this definition">¶</a></dt> <dd><p>Generate help text (a list of strings, one per suggested line of output) from the option table for this <a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><tt class="xref py py-class docutils literal"><span class="pre">FancyGetopt</span></tt></a> object.</p> <p>If supplied, prints the supplied <em>header</em> at the top of the help.</p> </dd></dl> </div> <div class="section" id="module-distutils.filelist"> <span id="distutils-filelist-the-filelist-class"></span><h2>10.18. <a class="reference internal" href="#module-distutils.filelist" title="distutils.filelist: The FileList class, used for poking about the file system and building lists of files."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.filelist</span></tt></a> — The FileList class<a class="headerlink" href="#module-distutils.filelist" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-class docutils literal"><span class="pre">FileList</span></tt> class, used for poking about the filesystem and building lists of files.</p> </div> <div class="section" id="module-distutils.log"> <span id="distutils-log-simple-pep-282-style-logging"></span><h2>10.19. <a class="reference internal" href="#module-distutils.log" title="distutils.log: A simple logging mechanism, 282-style"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.log</span></tt></a> — Simple PEP 282-style logging<a class="headerlink" href="#module-distutils.log" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.spawn"> <span id="distutils-spawn-spawn-a-sub-process"></span><h2>10.20. <a class="reference internal" href="#module-distutils.spawn" title="distutils.spawn: Provides the spawn() function"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.spawn</span></tt></a> — Spawn a sub-process<a class="headerlink" href="#module-distutils.spawn" title="Permalink to this headline">¶</a></h2> <p>This module provides the <tt class="xref py py-func docutils literal"><span class="pre">spawn()</span></tt> function, a front-end to various platform-specific functions for launching another program in a sub-process. Also provides <tt class="xref py py-func docutils literal"><span class="pre">find_executable()</span></tt> to search the path for a given executable name.</p> </div> <div class="section" id="module-distutils.sysconfig"> <span id="distutils-sysconfig-system-configuration-information"></span><h2>10.21. <a class="reference internal" href="#module-distutils.sysconfig" title="distutils.sysconfig: Low-level access to configuration information of the Python interpreter."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.sysconfig</span></tt></a> — System configuration information<a class="headerlink" href="#module-distutils.sysconfig" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#module-distutils.sysconfig" title="distutils.sysconfig: Low-level access to configuration information of the Python interpreter."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.sysconfig</span></tt></a> module provides access to Python’s low-level configuration information. The specific configuration variables available depend heavily on the platform and configuration. The specific variables depend on the build process for the specific version of Python being run; the variables are those found in the <tt class="file docutils literal"><span class="pre">Makefile</span></tt> and configuration header that are installed with Python on Unix systems. The configuration header is called <tt class="file docutils literal"><span class="pre">pyconfig.h</span></tt> for Python versions starting with 2.2, and <tt class="file docutils literal"><span class="pre">config.h</span></tt> for earlier versions of Python.</p> <p>Some additional functions are provided which perform some useful manipulations for other parts of the <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><tt class="xref py py-mod docutils literal"><span class="pre">distutils</span></tt></a> package.</p> <dl class="data"> <dt id="distutils.sysconfig.PREFIX"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">PREFIX</tt><a class="headerlink" href="#distutils.sysconfig.PREFIX" title="Permalink to this definition">¶</a></dt> <dd><p>The result of <tt class="docutils literal"><span class="pre">os.path.normpath(sys.prefix)</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="distutils.sysconfig.EXEC_PREFIX"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">EXEC_PREFIX</tt><a class="headerlink" href="#distutils.sysconfig.EXEC_PREFIX" title="Permalink to this definition">¶</a></dt> <dd><p>The result of <tt class="docutils literal"><span class="pre">os.path.normpath(sys.exec_prefix)</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_config_var"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_config_var</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_config_var" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of a single variable. This is equivalent to <tt class="docutils literal"><span class="pre">get_config_vars().get(name)</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_config_vars"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_config_vars</tt><big>(</big><em>...</em><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_config_vars" title="Permalink to this definition">¶</a></dt> <dd><p>Return a set of variable definitions. If there are no arguments, this returns a dictionary mapping names of configuration variables to values. If arguments are provided, they should be strings, and the return value will be a sequence giving the associated values. If a given name does not have a corresponding value, <tt class="docutils literal"><span class="pre">None</span></tt> will be included for that variable.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_config_h_filename"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_config_h_filename</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_config_h_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Return the full path name of the configuration header. For Unix, this will be the header generated by the <strong class="program">configure</strong> script; for other platforms the header will have been supplied directly by the Python source distribution. The file is a platform-specific text file.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_makefile_filename"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_makefile_filename</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_makefile_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Return the full path name of the <tt class="file docutils literal"><span class="pre">Makefile</span></tt> used to build Python. For Unix, this will be a file generated by the <strong class="program">configure</strong> script; the meaning for other platforms will vary. The file is a platform-specific text file, if it exists. This function is only useful on POSIX platforms.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_python_inc"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_python_inc</tt><big>(</big><span class="optional">[</span><em>plat_specific</em><span class="optional">[</span>, <em>prefix</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_python_inc" title="Permalink to this definition">¶</a></dt> <dd><p>Return the directory for either the general or platform-dependent C include files. If <em>plat_specific</em> is true, the platform-dependent include directory is returned; if false or omitted, the platform-independent directory is returned. If <em>prefix</em> is given, it is used as either the prefix instead of <a class="reference internal" href="#distutils.sysconfig.PREFIX" title="distutils.sysconfig.PREFIX"><tt class="xref py py-const docutils literal"><span class="pre">PREFIX</span></tt></a>, or as the exec-prefix instead of <a class="reference internal" href="#distutils.sysconfig.EXEC_PREFIX" title="distutils.sysconfig.EXEC_PREFIX"><tt class="xref py py-const docutils literal"><span class="pre">EXEC_PREFIX</span></tt></a> if <em>plat_specific</em> is true.</p> </dd></dl> <dl class="function"> <dt id="distutils.sysconfig.get_python_lib"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">get_python_lib</tt><big>(</big><span class="optional">[</span><em>plat_specific</em><span class="optional">[</span>, <em>standard_lib</em><span class="optional">[</span>, <em>prefix</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.sysconfig.get_python_lib" title="Permalink to this definition">¶</a></dt> <dd><p>Return the directory for either the general or platform-dependent library installation. If <em>plat_specific</em> is true, the platform-dependent include directory is returned; if false or omitted, the platform-independent directory is returned. If <em>prefix</em> is given, it is used as either the prefix instead of <a class="reference internal" href="#distutils.sysconfig.PREFIX" title="distutils.sysconfig.PREFIX"><tt class="xref py py-const docutils literal"><span class="pre">PREFIX</span></tt></a>, or as the exec-prefix instead of <a class="reference internal" href="#distutils.sysconfig.EXEC_PREFIX" title="distutils.sysconfig.EXEC_PREFIX"><tt class="xref py py-const docutils literal"><span class="pre">EXEC_PREFIX</span></tt></a> if <em>plat_specific</em> is true. If <em>standard_lib</em> is true, the directory for the standard library is returned rather than the directory for the installation of third-party extensions.</p> </dd></dl> <p>The following function is only intended for use within the <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><tt class="xref py py-mod docutils literal"><span class="pre">distutils</span></tt></a> package.</p> <dl class="function"> <dt id="distutils.sysconfig.customize_compiler"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">customize_compiler</tt><big>(</big><em>compiler</em><big>)</big><a class="headerlink" href="#distutils.sysconfig.customize_compiler" title="Permalink to this definition">¶</a></dt> <dd><p>Do any platform-specific customization of a <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><tt class="xref py py-class docutils literal"><span class="pre">distutils.ccompiler.CCompiler</span></tt></a> instance.</p> <p>This function is only needed on Unix at this time, but should be called consistently to support forward-compatibility. It inserts the information that varies across Unix flavors and is stored in Python’s <tt class="file docutils literal"><span class="pre">Makefile</span></tt>. This information includes the selected compiler, compiler and linker options, and the extension used by the linker for shared objects.</p> </dd></dl> <p>This function is even more special-purpose, and should only be used from Python’s own build procedures.</p> <dl class="function"> <dt id="distutils.sysconfig.set_python_build"> <tt class="descclassname">distutils.sysconfig.</tt><tt class="descname">set_python_build</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.sysconfig.set_python_build" title="Permalink to this definition">¶</a></dt> <dd><p>Inform the <a class="reference internal" href="#module-distutils.sysconfig" title="distutils.sysconfig: Low-level access to configuration information of the Python interpreter."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.sysconfig</span></tt></a> module that it is being used as part of the build process for Python. This changes a lot of relative locations for files, allowing them to be located in the build area rather than in an installed Python.</p> </dd></dl> </div> <div class="section" id="module-distutils.text_file"> <span id="distutils-text-file-the-textfile-class"></span><h2>10.22. <a class="reference internal" href="#module-distutils.text_file" title="distutils.text_file: provides the TextFile class, a simple interface to text files"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.text_file</span></tt></a> — The TextFile class<a class="headerlink" href="#module-distutils.text_file" title="Permalink to this headline">¶</a></h2> <p>This module provides the <a class="reference internal" href="#distutils.text_file.TextFile" title="distutils.text_file.TextFile"><tt class="xref py py-class docutils literal"><span class="pre">TextFile</span></tt></a> class, which gives an interface to text files that (optionally) takes care of stripping comments, ignoring blank lines, and joining lines with backslashes.</p> <dl class="class"> <dt id="distutils.text_file.TextFile"> <em class="property">class </em><tt class="descclassname">distutils.text_file.</tt><tt class="descname">TextFile</tt><big>(</big><span class="optional">[</span><em>filename=None</em>, <em>file=None</em>, <em>**options</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile" title="Permalink to this definition">¶</a></dt> <dd><p>This class provides a file-like object that takes care of all the things you commonly want to do when processing a text file that has some line-by-line syntax: strip comments (as long as <tt class="docutils literal"><span class="pre">#</span></tt> is your comment character), skip blank lines, join adjacent lines by escaping the newline (ie. backslash at end of line), strip leading and/or trailing whitespace. All of these are optional and independently controllable.</p> <p>The class provides a <a class="reference internal" href="#distutils.text_file.TextFile.warn" title="distutils.text_file.TextFile.warn"><tt class="xref py py-meth docutils literal"><span class="pre">warn()</span></tt></a> method so you can generate warning messages that report physical line number, even if the logical line in question spans multiple physical lines. Also provides <a class="reference internal" href="#distutils.text_file.TextFile.unreadline" title="distutils.text_file.TextFile.unreadline"><tt class="xref py py-meth docutils literal"><span class="pre">unreadline()</span></tt></a> for implementing line-at-a-time lookahead.</p> <p><a class="reference internal" href="#distutils.text_file.TextFile" title="distutils.text_file.TextFile"><tt class="xref py py-class docutils literal"><span class="pre">TextFile</span></tt></a> instances are create with either <em>filename</em>, <em>file</em>, or both. <a class="reference internal" href="../library/exceptions.html#exceptions.RuntimeError" title="exceptions.RuntimeError"><tt class="xref py py-exc docutils literal"><span class="pre">RuntimeError</span></tt></a> is raised if both are <tt class="docutils literal"><span class="pre">None</span></tt>. <em>filename</em> should be a string, and <em>file</em> a file object (or something that provides <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> and <a class="reference internal" href="#distutils.text_file.TextFile.close" title="distutils.text_file.TextFile.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> methods). It is recommended that you supply at least <em>filename</em>, so that <a class="reference internal" href="#distutils.text_file.TextFile" title="distutils.text_file.TextFile"><tt class="xref py py-class docutils literal"><span class="pre">TextFile</span></tt></a> can include it in warning messages. If <em>file</em> is not supplied, <a class="reference internal" href="#distutils.text_file.TextFile" title="distutils.text_file.TextFile"><tt class="xref py py-class docutils literal"><span class="pre">TextFile</span></tt></a> creates its own using the <a class="reference internal" href="../library/functions.html#open" title="open"><tt class="xref py py-func docutils literal"><span class="pre">open()</span></tt></a> built-in function.</p> <p>The options are all boolean, and affect the values returned by <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a></p> <table border="1" class="docutils"> <colgroup> <col width="31%" /> <col width="54%" /> <col width="15%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option name</th> <th class="head">description</th> <th class="head">default</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>strip_comments</em></td> <td>strip from <tt class="docutils literal"><span class="pre">'#'</span></tt> to end-of- line, as well as any whitespace leading up to the <tt class="docutils literal"><span class="pre">'#'</span></tt>—unless it is escaped by a backslash</td> <td>true</td> </tr> <tr class="row-odd"><td><em>lstrip_ws</em></td> <td>strip leading whitespace from each line before returning it</td> <td>false</td> </tr> <tr class="row-even"><td><em>rstrip_ws</em></td> <td>strip trailing whitespace (including line terminator!) from each line before returning it.</td> <td>true</td> </tr> <tr class="row-odd"><td><em>skip_blanks</em></td> <td>skip lines that are empty *after* stripping comments and whitespace. (If both lstrip_ws and rstrip_ws are false, then some lines may consist of solely whitespace: these will *not* be skipped, even if <em>skip_blanks</em> is true.)</td> <td>true</td> </tr> <tr class="row-even"><td><em>join_lines</em></td> <td>if a backslash is the last non-newline character on a line after stripping comments and whitespace, join the following line to it to form one logical line; if N consecutive lines end with a backslash, then N+1 physical lines will be joined to form one logical line.</td> <td>false</td> </tr> <tr class="row-odd"><td><em>collapse_join</em></td> <td>strip leading whitespace from lines that are joined to their predecessor; only matters if <tt class="docutils literal"><span class="pre">(join_lines</span> <span class="pre">and</span> <span class="pre">not</span> <span class="pre">lstrip_ws)</span></tt></td> <td>false</td> </tr> </tbody> </table> <p>Note that since <em>rstrip_ws</em> can strip the trailing newline, the semantics of <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> must differ from those of the built-in file object’s <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> method! In particular, <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> returns <tt class="docutils literal"><span class="pre">None</span></tt> for end-of-file: an empty string might just be a blank line (or an all-whitespace line), if <em>rstrip_ws</em> is true but <em>skip_blanks</em> is not.</p> <dl class="method"> <dt id="distutils.text_file.TextFile.open"> <tt class="descname">open</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.open" title="Permalink to this definition">¶</a></dt> <dd><p>Open a new file <em>filename</em>. This overrides any <em>file</em> or <em>filename</em> constructor arguments.</p> </dd></dl> <dl class="method"> <dt id="distutils.text_file.TextFile.close"> <tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.close" title="Permalink to this definition">¶</a></dt> <dd><p>Close the current file and forget everything we know about it (including the filename and the current line number).</p> </dd></dl> <dl class="method"> <dt id="distutils.text_file.TextFile.warn"> <tt class="descname">warn</tt><big>(</big><em>msg</em><span class="optional">[</span>, <em>line=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.warn" title="Permalink to this definition">¶</a></dt> <dd><p>Print (to stderr) a warning message tied to the current logical line in the current file. If the current logical line in the file spans multiple physical lines, the warning refers to the whole range, such as <tt class="docutils literal"><span class="pre">"lines</span> <span class="pre">3-5"</span></tt>. If <em>line</em> is supplied, it overrides the current line number; it may be a list or tuple to indicate a range of physical lines, or an integer for a single physical line.</p> </dd></dl> <dl class="method"> <dt id="distutils.text_file.TextFile.readline"> <tt class="descname">readline</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.readline" title="Permalink to this definition">¶</a></dt> <dd><p>Read and return a single logical line from the current file (or from an internal buffer if lines have previously been “unread” with <a class="reference internal" href="#distutils.text_file.TextFile.unreadline" title="distutils.text_file.TextFile.unreadline"><tt class="xref py py-meth docutils literal"><span class="pre">unreadline()</span></tt></a>). If the <em>join_lines</em> option is true, this may involve reading multiple physical lines concatenated into a single string. Updates the current line number, so calling <a class="reference internal" href="#distutils.text_file.TextFile.warn" title="distutils.text_file.TextFile.warn"><tt class="xref py py-meth docutils literal"><span class="pre">warn()</span></tt></a> after <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> emits a warning about the physical line(s) just read. Returns <tt class="docutils literal"><span class="pre">None</span></tt> on end-of-file, since the empty string can occur if <em>rstrip_ws</em> is true but <em>strip_blanks</em> is not.</p> </dd></dl> <dl class="method"> <dt id="distutils.text_file.TextFile.readlines"> <tt class="descname">readlines</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.readlines" title="Permalink to this definition">¶</a></dt> <dd><p>Read and return the list of all logical lines remaining in the current file. This updates the current line number to the last line of the file.</p> </dd></dl> <dl class="method"> <dt id="distutils.text_file.TextFile.unreadline"> <tt class="descname">unreadline</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#distutils.text_file.TextFile.unreadline" title="Permalink to this definition">¶</a></dt> <dd><p>Push <em>line</em> (a string) onto an internal buffer that will be checked by future <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a> calls. Handy for implementing a parser with line-at-a-time lookahead. Note that lines that are “unread” with <a class="reference internal" href="#distutils.text_file.TextFile.unreadline" title="distutils.text_file.TextFile.unreadline"><tt class="xref py py-meth docutils literal"><span class="pre">unreadline()</span></tt></a> are not subsequently re-cleansed (whitespace stripped, or whatever) when read with <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a>. If multiple calls are made to <a class="reference internal" href="#distutils.text_file.TextFile.unreadline" title="distutils.text_file.TextFile.unreadline"><tt class="xref py py-meth docutils literal"><span class="pre">unreadline()</span></tt></a> before a call to <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a>, the lines will be returned most in most recent first order.</p> </dd></dl> </dd></dl> </div> <div class="section" id="module-distutils.version"> <span id="distutils-version-version-number-classes"></span><h2>10.23. <a class="reference internal" href="#module-distutils.version" title="distutils.version: implements classes that represent module version numbers."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.version</span></tt></a> — Version number classes<a class="headerlink" href="#module-distutils.version" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.cmd"> <span id="distutils-cmd-abstract-base-class-for-distutils-commands"></span><h2>10.24. <a class="reference internal" href="#module-distutils.cmd" title="distutils.cmd: This module provides the abstract base class Command. This class is subclassed by the modules in the distutils.command subpackage."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.cmd</span></tt></a> — Abstract base class for Distutils commands<a class="headerlink" href="#module-distutils.cmd" title="Permalink to this headline">¶</a></h2> <p>This module supplies the abstract base class <a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><tt class="xref py py-class docutils literal"><span class="pre">Command</span></tt></a>.</p> <dl class="class"> <dt id="distutils.cmd.Command"> <em class="property">class </em><tt class="descclassname">distutils.cmd.</tt><tt class="descname">Command</tt><big>(</big><em>dist</em><big>)</big><a class="headerlink" href="#distutils.cmd.Command" title="Permalink to this definition">¶</a></dt> <dd><p>Abstract base class for defining command classes, the “worker bees” of the Distutils. A useful analogy for command classes is to think of them as subroutines with local variables called <em>options</em>. The options are declared in <a class="reference internal" href="#distutils.cmd.Command.initialize_options" title="distutils.cmd.Command.initialize_options"><tt class="xref py py-meth docutils literal"><span class="pre">initialize_options()</span></tt></a> and defined (given their final values) in <a class="reference internal" href="#distutils.cmd.Command.finalize_options" title="distutils.cmd.Command.finalize_options"><tt class="xref py py-meth docutils literal"><span class="pre">finalize_options()</span></tt></a>, both of which must be defined by every command class. The distinction between the two is necessary because option values might come from the outside world (command line, config file, ...), and any options dependent on other options must be computed after these outside influences have been processed — hence <a class="reference internal" href="#distutils.cmd.Command.finalize_options" title="distutils.cmd.Command.finalize_options"><tt class="xref py py-meth docutils literal"><span class="pre">finalize_options()</span></tt></a>. The body of the subroutine, where it does all its work based on the values of its options, is the <a class="reference internal" href="#distutils.cmd.Command.run" title="distutils.cmd.Command.run"><tt class="xref py py-meth docutils literal"><span class="pre">run()</span></tt></a> method, which must also be implemented by every command class.</p> <p>The class constructor takes a single argument <em>dist</em>, a <tt class="xref py py-class docutils literal"><span class="pre">Distribution</span></tt> instance.</p> </dd></dl> </div> <div class="section" id="creating-a-new-distutils-command"> <h2>10.25. Creating a new Distutils command<a class="headerlink" href="#creating-a-new-distutils-command" title="Permalink to this headline">¶</a></h2> <p>This section outlines the steps to create a new Distutils command.</p> <p>A new command lives in a module in the <a class="reference internal" href="#module-distutils.command" title="distutils.command: This subpackage contains one module for each standard Distutils command."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command</span></tt></a> package. There is a sample template in that directory called <tt class="file docutils literal"><span class="pre">command_template</span></tt>. Copy this file to a new module with the same name as the new command you’re implementing. This module should implement a class with the same name as the module (and the command). So, for instance, to create the command <tt class="docutils literal"><span class="pre">peel_banana</span></tt> (so that users can run <tt class="docutils literal"><span class="pre">setup.py</span> <span class="pre">peel_banana</span></tt>), you’d copy <tt class="file docutils literal"><span class="pre">command_template</span></tt> to <tt class="file docutils literal"><span class="pre">distutils/command/peel_banana.py</span></tt>, then edit it so that it’s implementing the class <tt class="xref py py-class docutils literal"><span class="pre">peel_banana</span></tt>, a subclass of <a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><tt class="xref py py-class docutils literal"><span class="pre">distutils.cmd.Command</span></tt></a>.</p> <p>Subclasses of <a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><tt class="xref py py-class docutils literal"><span class="pre">Command</span></tt></a> must define the following methods.</p> <dl class="method"> <dt id="distutils.cmd.Command.initialize_options"> <tt class="descclassname">Command.</tt><tt class="descname">initialize_options</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.cmd.Command.initialize_options" title="Permalink to this definition">¶</a></dt> <dd><p>Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, <a class="reference internal" href="#distutils.cmd.Command.initialize_options" title="distutils.cmd.Command.initialize_options"><tt class="xref py py-meth docutils literal"><span class="pre">initialize_options()</span></tt></a> implementations are just a bunch of <tt class="docutils literal"><span class="pre">self.foo</span> <span class="pre">=</span> <span class="pre">None</span></tt> assignments.</p> </dd></dl> <dl class="method"> <dt id="distutils.cmd.Command.finalize_options"> <tt class="descclassname">Command.</tt><tt class="descname">finalize_options</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.cmd.Command.finalize_options" title="Permalink to this definition">¶</a></dt> <dd><p>Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if <em>foo</em> depends on <em>bar</em>, then it is safe to set <em>foo</em> from <em>bar</em> as long as <em>foo</em> still has the same value it was assigned in <a class="reference internal" href="#distutils.cmd.Command.initialize_options" title="distutils.cmd.Command.initialize_options"><tt class="xref py py-meth docutils literal"><span class="pre">initialize_options()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="distutils.cmd.Command.run"> <tt class="descclassname">Command.</tt><tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#distutils.cmd.Command.run" title="Permalink to this definition">¶</a></dt> <dd><p>A command’s raison d’etre: carry out the action it exists to perform, controlled by the options initialized in <a class="reference internal" href="#distutils.cmd.Command.initialize_options" title="distutils.cmd.Command.initialize_options"><tt class="xref py py-meth docutils literal"><span class="pre">initialize_options()</span></tt></a>, customized by other commands, the setup script, the command-line, and config files, and finalized in <a class="reference internal" href="#distutils.cmd.Command.finalize_options" title="distutils.cmd.Command.finalize_options"><tt class="xref py py-meth docutils literal"><span class="pre">finalize_options()</span></tt></a>. All terminal output and filesystem interaction should be done by <a class="reference internal" href="#distutils.cmd.Command.run" title="distutils.cmd.Command.run"><tt class="xref py py-meth docutils literal"><span class="pre">run()</span></tt></a>.</p> </dd></dl> <dl class="attribute"> <dt id="distutils.cmd.Command.sub_commands"> <tt class="descclassname">Command.</tt><tt class="descname">sub_commands</tt><a class="headerlink" href="#distutils.cmd.Command.sub_commands" title="Permalink to this definition">¶</a></dt> <dd><p><em>sub_commands</em> formalizes the notion of a “family” of commands, e.g. <tt class="docutils literal"><span class="pre">install</span></tt> as the parent with sub-commands <tt class="docutils literal"><span class="pre">install_lib</span></tt>, <tt class="docutils literal"><span class="pre">install_headers</span></tt>, etc. The parent of a family of commands defines <em>sub_commands</em> as a class attribute; it’s a list of 2-tuples <tt class="docutils literal"><span class="pre">(command_name,</span> <span class="pre">predicate)</span></tt>, with <em>command_name</em> a string and <em>predicate</em> a function, a string or <tt class="docutils literal"><span class="pre">None</span></tt>. <em>predicate</em> is a method of the parent command that determines whether the corresponding command is applicable in the current situation. (E.g. <tt class="docutils literal"><span class="pre">install_headers</span></tt> is only applicable if we have any C header files to install.) If <em>predicate</em> is <tt class="docutils literal"><span class="pre">None</span></tt>, that command is always applicable.</p> <p><em>sub_commands</em> is usually defined at the <em>end</em> of a class, because predicates can be methods of the class, so they must already have been defined. The canonical example is the <strong class="command">install</strong> command.</p> </dd></dl> </div> <div class="section" id="module-distutils.command"> <span id="distutils-command-individual-distutils-commands"></span><h2>10.26. <a class="reference internal" href="#module-distutils.command" title="distutils.command: This subpackage contains one module for each standard Distutils command."><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command</span></tt></a> — Individual Distutils commands<a class="headerlink" href="#module-distutils.command" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.bdist"> <span id="distutils-command-bdist-build-a-binary-installer"></span><h2>10.27. <a class="reference internal" href="#module-distutils.command.bdist" title="distutils.command.bdist: Build a binary installer for a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist</span></tt></a> — Build a binary installer<a class="headerlink" href="#module-distutils.command.bdist" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.bdist_packager"> <span id="distutils-command-bdist-packager-abstract-base-class-for-packagers"></span><h2>10.28. <a class="reference internal" href="#module-distutils.command.bdist_packager" title="distutils.command.bdist_packager: Abstract base class for packagers"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist_packager</span></tt></a> — Abstract base class for packagers<a class="headerlink" href="#module-distutils.command.bdist_packager" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.bdist_dumb"> <span id="distutils-command-bdist-dumb-build-a-dumb-installer"></span><h2>10.29. <a class="reference internal" href="#module-distutils.command.bdist_dumb" title="distutils.command.bdist_dumb: Build a "dumb" installer - a simple archive of files"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist_dumb</span></tt></a> — Build a “dumb” installer<a class="headerlink" href="#module-distutils.command.bdist_dumb" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.bdist_msi"> <span id="distutils-command-bdist-msi-build-a-microsoft-installer-binary-package"></span><h2>10.30. <a class="reference internal" href="#module-distutils.command.bdist_msi" title="distutils.command.bdist_msi: Build a binary distribution as a Windows MSI file"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist_msi</span></tt></a> — Build a Microsoft Installer binary package<a class="headerlink" href="#module-distutils.command.bdist_msi" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="distutils.command.bdist_msi.bdist_msi"> <em class="property">class </em><tt class="descclassname">distutils.command.bdist_msi.</tt><tt class="descname">bdist_msi</tt><a class="headerlink" href="#distutils.command.bdist_msi.bdist_msi" title="Permalink to this definition">¶</a></dt> <dd><p>Builds a <a class="reference external" href="http://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx">Windows Installer</a> (.msi) binary package.</p> <p>In most cases, the <tt class="docutils literal"><span class="pre">bdist_msi</span></tt> installer is a better choice than the <tt class="docutils literal"><span class="pre">bdist_wininst</span></tt> installer, because it provides better support for Win64 platforms, allows administrators to perform non-interactive installations, and allows installation through group policies.</p> </dd></dl> </div> <div class="section" id="module-distutils.command.bdist_rpm"> <span id="distutils-command-bdist-rpm-build-a-binary-distribution-as-a-redhat-rpm-and-srpm"></span><h2>10.31. <a class="reference internal" href="#module-distutils.command.bdist_rpm" title="distutils.command.bdist_rpm: Build a binary distribution as a Redhat RPM and SRPM"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist_rpm</span></tt></a> — Build a binary distribution as a Redhat RPM and SRPM<a class="headerlink" href="#module-distutils.command.bdist_rpm" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.bdist_wininst"> <span id="distutils-command-bdist-wininst-build-a-windows-installer"></span><h2>10.32. <a class="reference internal" href="#module-distutils.command.bdist_wininst" title="distutils.command.bdist_wininst: Build a Windows installer"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.bdist_wininst</span></tt></a> — Build a Windows installer<a class="headerlink" href="#module-distutils.command.bdist_wininst" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.sdist"> <span id="distutils-command-sdist-build-a-source-distribution"></span><h2>10.33. <a class="reference internal" href="#module-distutils.command.sdist" title="distutils.command.sdist: Build a source distribution"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.sdist</span></tt></a> — Build a source distribution<a class="headerlink" href="#module-distutils.command.sdist" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.build"> <span id="distutils-command-build-build-all-files-of-a-package"></span><h2>10.34. <a class="reference internal" href="#module-distutils.command.build" title="distutils.command.build: Build all files of a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.build</span></tt></a> — Build all files of a package<a class="headerlink" href="#module-distutils.command.build" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.build_clib"> <span id="distutils-command-build-clib-build-any-c-libraries-in-a-package"></span><h2>10.35. <a class="reference internal" href="#module-distutils.command.build_clib" title="distutils.command.build_clib: Build any C libraries in a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.build_clib</span></tt></a> — Build any C libraries in a package<a class="headerlink" href="#module-distutils.command.build_clib" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.build_ext"> <span id="distutils-command-build-ext-build-any-extensions-in-a-package"></span><h2>10.36. <a class="reference internal" href="#module-distutils.command.build_ext" title="distutils.command.build_ext: Build any extensions in a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.build_ext</span></tt></a> — Build any extensions in a package<a class="headerlink" href="#module-distutils.command.build_ext" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.build_py"> <span id="distutils-command-build-py-build-the-py-pyc-files-of-a-package"></span><h2>10.37. <a class="reference internal" href="#module-distutils.command.build_py" title="distutils.command.build_py: Build the .py/.pyc files of a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.build_py</span></tt></a> — Build the .py/.pyc files of a package<a class="headerlink" href="#module-distutils.command.build_py" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.build_scripts"> <span id="distutils-command-build-scripts-build-the-scripts-of-a-package"></span><h2>10.38. <a class="reference internal" href="#module-distutils.command.build_scripts" title="distutils.command.build_scripts: Build the scripts of a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.build_scripts</span></tt></a> — Build the scripts of a package<a class="headerlink" href="#module-distutils.command.build_scripts" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.clean"> <span id="distutils-command-clean-clean-a-package-build-area"></span><h2>10.39. <a class="reference internal" href="#module-distutils.command.clean" title="distutils.command.clean: Clean a package build area"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.clean</span></tt></a> — Clean a package build area<a class="headerlink" href="#module-distutils.command.clean" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.config"> <span id="distutils-command-config-perform-package-configuration"></span><h2>10.40. <a class="reference internal" href="#module-distutils.command.config" title="distutils.command.config: Perform package configuration"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.config</span></tt></a> — Perform package configuration<a class="headerlink" href="#module-distutils.command.config" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.install"> <span id="distutils-command-install-install-a-package"></span><h2>10.41. <a class="reference internal" href="#module-distutils.command.install" title="distutils.command.install: Install a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.install</span></tt></a> — Install a package<a class="headerlink" href="#module-distutils.command.install" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.install_data"> <span id="distutils-command-install-data-install-data-files-from-a-package"></span><h2>10.42. <a class="reference internal" href="#module-distutils.command.install_data" title="distutils.command.install_data: Install data files from a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.install_data</span></tt></a> — Install data files from a package<a class="headerlink" href="#module-distutils.command.install_data" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.install_headers"> <span id="distutils-command-install-headers-install-c-c-header-files-from-a-package"></span><h2>10.43. <a class="reference internal" href="#module-distutils.command.install_headers" title="distutils.command.install_headers: Install C/C++ header files from a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.install_headers</span></tt></a> — Install C/C++ header files from a package<a class="headerlink" href="#module-distutils.command.install_headers" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.install_lib"> <span id="distutils-command-install-lib-install-library-files-from-a-package"></span><h2>10.44. <a class="reference internal" href="#module-distutils.command.install_lib" title="distutils.command.install_lib: Install library files from a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.install_lib</span></tt></a> — Install library files from a package<a class="headerlink" href="#module-distutils.command.install_lib" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.install_scripts"> <span id="distutils-command-install-scripts-install-script-files-from-a-package"></span><h2>10.45. <a class="reference internal" href="#module-distutils.command.install_scripts" title="distutils.command.install_scripts: Install script files from a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.install_scripts</span></tt></a> — Install script files from a package<a class="headerlink" href="#module-distutils.command.install_scripts" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="module-distutils.command.register"> <span id="distutils-command-register-register-a-module-with-the-python-package-index"></span><h2>10.46. <a class="reference internal" href="#module-distutils.command.register" title="distutils.command.register: Register a module with the Python Package Index"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.register</span></tt></a> — Register a module with the Python Package Index<a class="headerlink" href="#module-distutils.command.register" title="Permalink to this headline">¶</a></h2> <p>The <tt class="docutils literal"><span class="pre">register</span></tt> command registers the package with the Python Package Index. This is described in more detail in <span class="target" id="index-4"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0301"><strong>PEP 301</strong></a>.</p> </div> <div class="section" id="module-distutils.command.check"> <span id="distutils-command-check-check-the-meta-data-of-a-package"></span><h2>10.47. <a class="reference internal" href="#module-distutils.command.check" title="distutils.command.check: Check the metadata of a package"><tt class="xref py py-mod docutils literal"><span class="pre">distutils.command.check</span></tt></a> — Check the meta-data of a package<a class="headerlink" href="#module-distutils.command.check" title="Permalink to this headline">¶</a></h2> <p>The <tt class="docutils literal"><span class="pre">check</span></tt> command performs some tests on the meta-data of a package. For example, it verifies that all required meta-data are provided as the arguments passed to the <tt class="xref py py-func docutils literal"><span class="pre">setup()</span></tt> function.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">10. API Reference</a><ul> <li><a class="reference internal" href="#module-distutils.core">10.1. <tt class="docutils literal"><span class="pre">distutils.core</span></tt> — Core Distutils functionality</a></li> <li><a class="reference internal" href="#module-distutils.ccompiler">10.2. <tt class="docutils literal"><span class="pre">distutils.ccompiler</span></tt> — CCompiler base class</a></li> <li><a class="reference internal" href="#module-distutils.unixccompiler">10.3. <tt class="docutils literal"><span class="pre">distutils.unixccompiler</span></tt> — Unix C Compiler</a></li> <li><a class="reference internal" href="#module-distutils.msvccompiler">10.4. <tt class="docutils literal"><span class="pre">distutils.msvccompiler</span></tt> — Microsoft Compiler</a></li> <li><a class="reference internal" href="#module-distutils.bcppcompiler">10.5. <tt class="docutils literal"><span class="pre">distutils.bcppcompiler</span></tt> — Borland Compiler</a></li> <li><a class="reference internal" href="#module-distutils.cygwinccompiler">10.6. <tt class="docutils literal"><span class="pre">distutils.cygwincompiler</span></tt> — Cygwin Compiler</a></li> <li><a class="reference internal" href="#module-distutils.emxccompiler">10.7. <tt class="docutils literal"><span class="pre">distutils.emxccompiler</span></tt> — OS/2 EMX Compiler</a></li> <li><a class="reference internal" href="#module-distutils.archive_util">10.8. <tt class="docutils literal"><span class="pre">distutils.archive_util</span></tt> — Archiving utilities</a></li> <li><a class="reference internal" href="#module-distutils.dep_util">10.9. <tt class="docutils literal"><span class="pre">distutils.dep_util</span></tt> — Dependency checking</a></li> <li><a class="reference internal" href="#module-distutils.dir_util">10.10. <tt class="docutils literal"><span class="pre">distutils.dir_util</span></tt> — Directory tree operations</a></li> <li><a class="reference internal" href="#module-distutils.file_util">10.11. <tt class="docutils literal"><span class="pre">distutils.file_util</span></tt> — Single file operations</a></li> <li><a class="reference internal" href="#module-distutils.util">10.12. <tt class="docutils literal"><span class="pre">distutils.util</span></tt> — Miscellaneous other utility functions</a></li> <li><a class="reference internal" href="#module-distutils.dist">10.13. <tt class="docutils literal"><span class="pre">distutils.dist</span></tt> — The Distribution class</a></li> <li><a class="reference internal" href="#module-distutils.extension">10.14. <tt class="docutils literal"><span class="pre">distutils.extension</span></tt> — The Extension class</a></li> <li><a class="reference internal" href="#module-distutils.debug">10.15. <tt class="docutils literal"><span class="pre">distutils.debug</span></tt> — Distutils debug mode</a></li> <li><a class="reference internal" href="#module-distutils.errors">10.16. <tt class="docutils literal"><span class="pre">distutils.errors</span></tt> — Distutils exceptions</a></li> <li><a class="reference internal" href="#module-distutils.fancy_getopt">10.17. <tt class="docutils literal"><span class="pre">distutils.fancy_getopt</span></tt> — Wrapper around the standard getopt module</a></li> <li><a class="reference internal" href="#module-distutils.filelist">10.18. <tt class="docutils literal"><span class="pre">distutils.filelist</span></tt> — The FileList class</a></li> <li><a class="reference internal" href="#module-distutils.log">10.19. <tt class="docutils literal"><span class="pre">distutils.log</span></tt> — Simple PEP 282-style logging</a></li> <li><a class="reference internal" href="#module-distutils.spawn">10.20. <tt class="docutils literal"><span class="pre">distutils.spawn</span></tt> — Spawn a sub-process</a></li> <li><a class="reference internal" href="#module-distutils.sysconfig">10.21. <tt class="docutils literal"><span class="pre">distutils.sysconfig</span></tt> — System configuration information</a></li> <li><a class="reference internal" href="#module-distutils.text_file">10.22. <tt class="docutils literal"><span class="pre">distutils.text_file</span></tt> — The TextFile class</a></li> <li><a class="reference internal" href="#module-distutils.version">10.23. <tt class="docutils literal"><span class="pre">distutils.version</span></tt> — Version number classes</a></li> <li><a class="reference internal" href="#module-distutils.cmd">10.24. <tt class="docutils literal"><span class="pre">distutils.cmd</span></tt> — Abstract base class for Distutils commands</a></li> <li><a class="reference internal" href="#creating-a-new-distutils-command">10.25. Creating a new Distutils command</a></li> <li><a class="reference internal" href="#module-distutils.command">10.26. <tt class="docutils literal"><span class="pre">distutils.command</span></tt> — Individual Distutils commands</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist">10.27. <tt class="docutils literal"><span class="pre">distutils.command.bdist</span></tt> — Build a binary installer</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist_packager">10.28. <tt class="docutils literal"><span class="pre">distutils.command.bdist_packager</span></tt> — Abstract base class for packagers</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist_dumb">10.29. <tt class="docutils literal"><span class="pre">distutils.command.bdist_dumb</span></tt> — Build a “dumb” installer</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist_msi">10.30. <tt class="docutils literal"><span class="pre">distutils.command.bdist_msi</span></tt> — Build a Microsoft Installer binary package</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist_rpm">10.31. <tt class="docutils literal"><span class="pre">distutils.command.bdist_rpm</span></tt> — Build a binary distribution as a Redhat RPM and SRPM</a></li> <li><a class="reference internal" href="#module-distutils.command.bdist_wininst">10.32. <tt class="docutils literal"><span class="pre">distutils.command.bdist_wininst</span></tt> — Build a Windows installer</a></li> <li><a class="reference internal" href="#module-distutils.command.sdist">10.33. <tt class="docutils literal"><span class="pre">distutils.command.sdist</span></tt> — Build a source distribution</a></li> <li><a class="reference internal" href="#module-distutils.command.build">10.34. <tt class="docutils literal"><span class="pre">distutils.command.build</span></tt> — Build all files of a package</a></li> <li><a class="reference internal" href="#module-distutils.command.build_clib">10.35. <tt class="docutils literal"><span class="pre">distutils.command.build_clib</span></tt> — Build any C libraries in a package</a></li> <li><a class="reference internal" href="#module-distutils.command.build_ext">10.36. <tt class="docutils literal"><span class="pre">distutils.command.build_ext</span></tt> — Build any extensions in a package</a></li> <li><a class="reference internal" href="#module-distutils.command.build_py">10.37. <tt class="docutils literal"><span class="pre">distutils.command.build_py</span></tt> — Build the .py/.pyc files of a package</a></li> <li><a class="reference internal" href="#module-distutils.command.build_scripts">10.38. <tt class="docutils literal"><span class="pre">distutils.command.build_scripts</span></tt> — Build the scripts of a package</a></li> <li><a class="reference internal" href="#module-distutils.command.clean">10.39. <tt class="docutils literal"><span class="pre">distutils.command.clean</span></tt> — Clean a package build area</a></li> <li><a class="reference internal" href="#module-distutils.command.config">10.40. <tt class="docutils literal"><span class="pre">distutils.command.config</span></tt> — Perform package configuration</a></li> <li><a class="reference internal" href="#module-distutils.command.install">10.41. <tt class="docutils literal"><span class="pre">distutils.command.install</span></tt> — Install a package</a></li> <li><a class="reference internal" href="#module-distutils.command.install_data">10.42. <tt class="docutils literal"><span class="pre">distutils.command.install_data</span></tt> — Install data files from a package</a></li> <li><a class="reference internal" href="#module-distutils.command.install_headers">10.43. <tt class="docutils literal"><span class="pre">distutils.command.install_headers</span></tt> — Install C/C++ header files from a package</a></li> <li><a class="reference internal" href="#module-distutils.command.install_lib">10.44. <tt class="docutils literal"><span class="pre">distutils.command.install_lib</span></tt> — Install library files from a package</a></li> <li><a class="reference internal" href="#module-distutils.command.install_scripts">10.45. <tt class="docutils literal"><span class="pre">distutils.command.install_scripts</span></tt> — Install script files from a package</a></li> <li><a class="reference internal" href="#module-distutils.command.register">10.46. <tt class="docutils literal"><span class="pre">distutils.command.register</span></tt> — Register a module with the Python Package Index</a></li> <li><a class="reference internal" href="#module-distutils.command.check">10.47. <tt class="docutils literal"><span class="pre">distutils.command.check</span></tt> — Check the meta-data of a package</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="commandref.html" title="previous chapter">9. Command Reference</a></p> <h4>Next topic</h4> <p class="topless"><a href="../install/index.html" title="next chapter">Installing Python Modules</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/distutils/apiref.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="../install/index.html" title="Installing Python Modules" >next</a> |</li> <li class="right" > <a href="commandref.html" title="9. Command Reference" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >Distributing Python Modules</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Close