Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 272358a29dcac700c15f72584b3d4e55 > files > 591

python3-docs-3.7.10-1.1.mga7.noarch.rpm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>9. API Reference &#8212; Python 3.7.10 documentation</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.7.10 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="Installing Python Modules (Legacy version)" href="../install/index.html" />
    <link rel="prev" title="8. Command Reference" href="commandref.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/distutils/apiref.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <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 (Legacy version)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="commandref.html" title="8. 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="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.10 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Distributing Python Modules (Legacy version)</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" 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>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="api-reference">
<span id="id1"></span><h1><span class="section-number">9. </span>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><span class="section-number">9.1. </span><a class="reference internal" href="#module-distutils.core" title="distutils.core: The core Distutils functionality"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.core</span></code></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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.core</span></code></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"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a> (which is called from the
setup script). Indirectly provides the  <code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.dist.Distribution</span></code> and
<a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.cmd.Command</span></code></a> class.</p>
<dl class="function">
<dt id="distutils.core.setup">
<code class="sig-prename descclassname">distutils.core.</code><code class="sig-name descname">setup</code><span class="sig-paren">(</span><em class="sig-param">arguments</em><span class="sig-paren">)</span><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 class="docutils align-default">
<colgroup>
<col style="width: 18%" />
<col style="width: 28%" />
<col style="width: 54%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>argument name</p></th>
<th class="head"><p>value</p></th>
<th class="head"><p>type</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>name</em></p></td>
<td><p>The name of the package</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>version</em></p></td>
<td><p>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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.version</span></code></a></p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>description</em></p></td>
<td><p>A single line describing the
package</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>long_description</em></p></td>
<td><p>Longer description of the
package</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>author</em></p></td>
<td><p>The name of the package author</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>author_email</em></p></td>
<td><p>The email address of the
package author</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>maintainer</em></p></td>
<td><p>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 <code class="file docutils literal notranslate"><span class="pre">PKG-INFO</span></code></p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>maintainer_email</em></p></td>
<td><p>The email address of the
current maintainer, if
different from the author</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>url</em></p></td>
<td><p>A URL for the package
(homepage)</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>download_url</em></p></td>
<td><p>A URL to download the package</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>packages</em></p></td>
<td><p>A list of Python packages that
distutils will manipulate</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>py_modules</em></p></td>
<td><p>A list of Python modules that
distutils will manipulate</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>scripts</em></p></td>
<td><p>A list of standalone script
files to be built and
installed</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>ext_modules</em></p></td>
<td><p>A list of Python extensions to
be built</p></td>
<td><p>a list of instances of
<a class="reference internal" href="#distutils.core.Extension" title="distutils.core.Extension"><code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.core.Extension</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><em>classifiers</em></p></td>
<td><p>A list of categories for the
package</p></td>
<td><p>a list of strings; valid classifiers are listed on <a class="reference external" href="https://pypi.org/classifiers">PyPI</a>.</p></td>
</tr>
<tr class="row-odd"><td><p><em>distclass</em></p></td>
<td><p>the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a>
class to use</p></td>
<td><p>a subclass of
<a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.core.Distribution</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><em>script_name</em></p></td>
<td><p>The name of the setup.py
script - defaults to
<code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code></p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>script_args</em></p></td>
<td><p>Arguments to supply to the
setup script</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>options</em></p></td>
<td><p>default options for the setup
script</p></td>
<td><p>a dictionary</p></td>
</tr>
<tr class="row-odd"><td><p><em>license</em></p></td>
<td><p>The license for the package</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>keywords</em></p></td>
<td><p>Descriptive meta-data, see
<span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0314"><strong>PEP 314</strong></a></p></td>
<td><p>a list of strings or a comma-separated string</p></td>
</tr>
<tr class="row-odd"><td><p><em>platforms</em></p></td>
<td></td>
<td><p>a list of strings or a comma-separated string</p></td>
</tr>
<tr class="row-even"><td><p><em>cmdclass</em></p></td>
<td><p>A mapping of command names to
<a class="reference internal" href="#distutils.core.Command" title="distutils.core.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a> subclasses</p></td>
<td><p>a dictionary</p></td>
</tr>
<tr class="row-odd"><td><p><em>data_files</em></p></td>
<td><p>A list of data files to
install</p></td>
<td><p>a list</p></td>
</tr>
<tr class="row-even"><td><p><em>package_dir</em></p></td>
<td><p>A mapping of package to
directory names</p></td>
<td><p>a dictionary</p></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="distutils.core.run_setup">
<code class="sig-prename descclassname">distutils.core.</code><code class="sig-name descname">run_setup</code><span class="sig-paren">(</span><em class="sig-param">script_name</em><span class="optional">[</span>, <em class="sig-param">script_args=None</em>, <em class="sig-param">stop_after='run'</em><span class="optional">]</span><span class="sig-paren">)</span><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
<code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.dist.Distribution</span></code> 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"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a>), or  the contents of the config files or
command-line.</p>
<p><em>script_name</em> is a file that will be read and run with <a class="reference internal" href="../library/functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a>.  <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code>
will be replaced with <em>script</em> for the duration of the call.  <em>script_args</em> is a
list of strings; if supplied, <code class="docutils literal notranslate"><span class="pre">sys.argv[1:]</span></code> 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"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a> when to stop processing; possible  values:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 75%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>value</p></th>
<th class="head"><p>description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>init</em></p></td>
<td><p>Stop after the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a>
instance has been created  and populated
with the keyword arguments to <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><em>config</em></p></td>
<td><p>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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a> instance)</p></td>
</tr>
<tr class="row-even"><td><p><em>commandline</em></p></td>
<td><p>Stop after the command-line
(<code class="docutils literal notranslate"><span class="pre">sys.argv[1:]</span></code> 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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a> instance.)</p></td>
</tr>
<tr class="row-odd"><td><p><em>run</em></p></td>
<td><p>Stop after all commands have been run (the
same as  if <a class="reference internal" href="#distutils.core.setup" title="distutils.core.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a> had been called
in the usual way). This is the default
value.</p></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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.core</span></code></a> module exposed a number of  classes that
live elsewhere.</p>
<ul class="simple">
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Extension</span></code> 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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.extension</span></code></a></p></li>
<li><p><a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a> from <a class="reference internal" href="#module-distutils.cmd" title="distutils.cmd: Provides the abstract base class :class:`~distutils.cmd.Command`. This class is subclassed by the modules in the distutils.command subpackage."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.cmd</span></code></a></p></li>
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code> 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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dist</span></code></a></p></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><code class="sig-prename descclassname">distutils.core.</code><code class="sig-name descname">Extension</code><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 class="docutils align-default">
<colgroup>
<col style="width: 29%" />
<col style="width: 39%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>argument name</p></th>
<th class="head"><p>value</p></th>
<th class="head"><p>type</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>name</em></p></td>
<td><p>the full name of the
extension, including any
packages — ie. <em>not</em> a
filename or pathname, but
Python dotted name</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-odd"><td><p><em>sources</em></p></td>
<td><p>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.</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>include_dirs</em></p></td>
<td><p>list of directories to search
for C/C++ header files (in
Unix form for portability)</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>define_macros</em></p></td>
<td><p>list of macros to define; each
macro is defined using a
2-tuple <code class="docutils literal notranslate"><span class="pre">(name,</span> <span class="pre">value)</span></code>,
where <em>value</em> is
either the string to define it
to or <code class="docutils literal notranslate"><span class="pre">None</span></code> to define it
without a particular value
(equivalent of <code class="docutils literal notranslate"><span class="pre">#define</span> <span class="pre">FOO</span></code>
in source or <code class="xref std std-option docutils literal notranslate"><span class="pre">-DFOO</span></code>
on Unix C compiler command
line)</p></td>
<td><p>a list of tuples</p></td>
</tr>
<tr class="row-even"><td><p><em>undef_macros</em></p></td>
<td><p>list of macros to undefine
explicitly</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>library_dirs</em></p></td>
<td><p>list of directories to search
for C/C++ libraries at link
time</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>libraries</em></p></td>
<td><p>list of library names (not
filenames or paths) to link
against</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>runtime_library_dirs</em></p></td>
<td><p>list of directories to search
for C/C++ libraries at run
time (for shared extensions,
this is when the extension is
loaded)</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>extra_objects</em></p></td>
<td><p>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.)</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>extra_compile_args</em></p></td>
<td><p>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.</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>extra_link_args</em></p></td>
<td><p>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’.</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>export_symbols</em></p></td>
<td><p>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:
<code class="docutils literal notranslate"><span class="pre">init</span></code> + extension_name.</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-even"><td><p><em>depends</em></p></td>
<td><p>list of files that the
extension depends on</p></td>
<td><p>a list of strings</p></td>
</tr>
<tr class="row-odd"><td><p><em>language</em></p></td>
<td><p>extension language (i.e.
<code class="docutils literal notranslate"><span class="pre">'c'</span></code>, <code class="docutils literal notranslate"><span class="pre">'c++'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'objc'</span></code>). Will be detected
from the source extensions if
not provided.</p></td>
<td><p>a string</p></td>
</tr>
<tr class="row-even"><td><p><em>optional</em></p></td>
<td><p>specifies that a build failure
in the extension should not
abort the build process, but
simply skip the extension.</p></td>
<td><p>a boolean</p></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="distutils.core.Distribution">
<em class="property">class </em><code class="sig-prename descclassname">distutils.core.</code><code class="sig-name descname">Distribution</code><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></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"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></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"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a> creates a Distribution instance.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.7: </span><a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a> now warns if <code class="docutils literal notranslate"><span class="pre">classifiers</span></code>,
<code class="docutils literal notranslate"><span class="pre">keywords</span></code> and <code class="docutils literal notranslate"><span class="pre">platforms</span></code> fields are not specified as a list or
a string.</p>
</div>
</dd></dl>

<dl class="class">
<dt id="distutils.core.Command">
<em class="property">class </em><code class="sig-prename descclassname">distutils.core.</code><code class="sig-name descname">Command</code><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></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><span class="section-number">9.2. </span><a class="reference internal" href="#module-distutils.ccompiler" title="distutils.ccompiler: Abstract CCompiler class"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.ccompiler</span></code></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></a>
classes.  A <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></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">
<code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">gen_lib_options</code><span class="sig-paren">(</span><em class="sig-param">compiler</em>, <em class="sig-param">library_dirs</em>, <em class="sig-param">runtime_library_dirs</em>, <em class="sig-param">libraries</em><span class="sig-paren">)</span><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">
<code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">gen_preprocess_options</code><span class="sig-paren">(</span><em class="sig-param">macros</em>, <em class="sig-param">include_dirs</em><span class="sig-paren">)</span><a class="headerlink" href="#distutils.ccompiler.gen_preprocess_options" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate C pre-processor options (<code class="xref std std-option docutils literal notranslate"><span class="pre">-D</span></code>, <code class="xref std std-option docutils literal notranslate"><span class="pre">-U</span></code>, <code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code>) 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 <code class="docutils literal notranslate"><span class="pre">(name,)</span></code>
means undefine (<code class="xref std std-option docutils literal notranslate"><span class="pre">-U</span></code>) macro <em>name</em>, and <code class="docutils literal notranslate"><span class="pre">(name,</span> <span class="pre">value)</span></code> means define
(<code class="xref std std-option docutils literal notranslate"><span class="pre">-D</span></code>) 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 (<code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code>).
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">
<code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">get_default_compiler</code><span class="sig-paren">(</span><em class="sig-param">osname</em>, <em class="sig-param">platform</em><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">os.name</span></code>) and <em>platform</em> the common value returned by <code class="docutils literal notranslate"><span class="pre">sys.platform</span></code> for
the platform in question.</p>
<p>The default values are <code class="docutils literal notranslate"><span class="pre">os.name</span></code> and <code class="docutils literal notranslate"><span class="pre">sys.platform</span></code> in case the parameters
are not given.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.ccompiler.new_compiler">
<code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">new_compiler</code><span class="sig-paren">(</span><em class="sig-param">plat=None</em>, <em class="sig-param">compiler=None</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em>, <em class="sig-param">force=0</em><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">os.name</span></code> (eg.
<code class="docutils literal notranslate"><span class="pre">'posix'</span></code>, <code class="docutils literal notranslate"><span class="pre">'nt'</span></code>), and <em>compiler</em>  defaults to the default compiler for
that platform. Currently only <code class="docutils literal notranslate"><span class="pre">'posix'</span></code> and <code class="docutils literal notranslate"><span class="pre">'nt'</span></code> are supported, and the
default compilers are “traditional Unix interface” (<code class="xref py py-class docutils literal notranslate"><span class="pre">UnixCCompiler</span></code>
class) and Visual C++ (<code class="xref py py-class docutils literal notranslate"><span class="pre">MSVCCompiler</span></code> 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">
<code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">show_compilers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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 <code class="xref std std-option docutils literal notranslate"><span class="pre">--help-compiler</span></code> 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><code class="sig-prename descclassname">distutils.ccompiler.</code><code class="sig-name descname">CCompiler</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em>, <em class="sig-param">force=0</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></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 <code class="docutils literal notranslate"><span class="pre">0</span></code> (off). Note that you probably don’t want to
instantiate <a class="reference internal" href="#distutils.ccompiler.CCompiler" title="distutils.ccompiler.CCompiler"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></a> or one of its subclasses directly - use the
<code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.CCompiler.new_compiler()</span></code> 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">
<code class="sig-name descname">add_include_dir</code><span class="sig-paren">(</span><em class="sig-param">dir</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_include_dir()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.set_include_dirs">
<code class="sig-name descname">set_include_dirs</code><span class="sig-paren">(</span><em class="sig-param">dirs</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_include_dir()</span></code></a>; subsequent calls to
<a class="reference internal" href="#distutils.ccompiler.CCompiler.add_include_dir" title="distutils.ccompiler.CCompiler.add_include_dir"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_include_dir()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_include_dirs()</span></code></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">
<code class="sig-name descname">add_library</code><span class="sig-paren">(</span><em class="sig-param">libname</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_library()</span></code></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_libraries()</span></code></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">
<code class="sig-name descname">set_libraries</code><span class="sig-paren">(</span><em class="sig-param">libnames</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">add_library_dir</code><span class="sig-paren">(</span><em class="sig-param">dir</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_library()</span></code></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_libraries()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_library_dir()</span></code></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_library_dirs" title="distutils.ccompiler.CCompiler.set_library_dirs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_library_dirs()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.set_library_dirs">
<code class="sig-name descname">set_library_dirs</code><span class="sig-paren">(</span><em class="sig-param">dirs</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">add_runtime_library_dir</code><span class="sig-paren">(</span><em class="sig-param">dir</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">set_runtime_library_dirs</code><span class="sig-paren">(</span><em class="sig-param">dirs</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">define_macro</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="optional">[</span>, <em class="sig-param">value=None</em><span class="optional">]</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">undefine_macro</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">define_macro()</span></code></a> and
undefined by <a class="reference internal" href="#distutils.ccompiler.CCompiler.undefine_macro" title="distutils.ccompiler.CCompiler.undefine_macro"><code class="xref py py-meth docutils literal notranslate"><span class="pre">undefine_macro()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">compile()</span></code></a>), then that takes precedence.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.add_link_object">
<code class="sig-name descname">add_link_object</code><span class="sig-paren">(</span><em class="sig-param">object</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">set_link_objects</code><span class="sig-paren">(</span><em class="sig-param">objects</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">detect_language</code><span class="sig-paren">(</span><em class="sig-param">sources</em><span class="sig-paren">)</span><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 <code class="xref py py-attr docutils literal notranslate"><span class="pre">language_map</span></code> (a dictionary), and  <code class="xref py py-attr docutils literal notranslate"><span class="pre">language_order</span></code> (a
list) to do the job.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.find_library_file">
<code class="sig-name descname">find_library_file</code><span class="sig-paren">(</span><em class="sig-param">dirs</em>, <em class="sig-param">lib</em><span class="optional">[</span>, <em class="sig-param">debug=0</em><span class="optional">]</span><span class="sig-paren">)</span><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
<code class="docutils literal notranslate"><span class="pre">None</span></code> 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">
<code class="sig-name descname">has_function</code><span class="sig-paren">(</span><em class="sig-param">funcname</em><span class="optional">[</span>, <em class="sig-param">includes=None</em>, <em class="sig-param">include_dirs=None</em>, <em class="sig-param">libraries=None</em>, <em class="sig-param">library_dirs=None</em><span class="optional">]</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">library_dir_option</code><span class="sig-paren">(</span><em class="sig-param">dir</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">library_option</code><span class="sig-paren">(</span><em class="sig-param">lib</em><span class="sig-paren">)</span><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>lib</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">
<code class="sig-name descname">runtime_library_dir_option</code><span class="sig-paren">(</span><em class="sig-param">dir</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">set_executables</code><span class="sig-paren">(</span><em class="sig-param">**args</em><span class="sig-paren">)</span><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 class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 75%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>attribute</p></th>
<th class="head"><p>description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>compiler</em></p></td>
<td><p>the C/C++ compiler</p></td>
</tr>
<tr class="row-odd"><td><p><em>linker_so</em></p></td>
<td><p>linker used to create shared objects and
libraries</p></td>
</tr>
<tr class="row-even"><td><p><em>linker_exe</em></p></td>
<td><p>linker used to create binary executables</p></td>
</tr>
<tr class="row-odd"><td><p><em>archiver</em></p></td>
<td><p>static library creator</p></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"><code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.util.split_quoted()</span></code></a>.)</p>
</dd></dl>

<p>The following methods invoke stages in the build process.</p>
<dl class="method">
<dt id="distutils.ccompiler.CCompiler.compile">
<code class="sig-name descname">compile</code><span class="sig-paren">(</span><em class="sig-param">sources</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">macros=None</em>, <em class="sig-param">include_dirs=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em>, <em class="sig-param">depends=None</em><span class="optional">]</span><span class="sig-paren">)</span><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
<code class="file docutils literal notranslate"><span class="pre">.c</span></code> file to a <code class="file docutils literal notranslate"><span class="pre">.o</span></code> 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.
<code class="xref py py-class docutils literal notranslate"><span class="pre">MSVCCompiler</span></code> 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, <code class="file docutils literal notranslate"><span class="pre">foo/bar.c</span></code> normally compiles to
<code class="file docutils literal notranslate"><span class="pre">foo/bar.o</span></code> (for a Unix implementation); if <em>output_dir</em> is <em>build</em>, then
it would compile to <code class="file docutils literal notranslate"><span class="pre">build/foo/bar.o</span></code>.</p>
<p><em>macros</em>, if given, must be a list of macro definitions.  A macro definition is
either a <code class="docutils literal notranslate"><span class="pre">(name,</span> <span class="pre">value)</span></code> 2-tuple or a <code class="docutils literal notranslate"><span class="pre">(name,)</span></code> 1-tuple. The former defines
a macro; if the value is <code class="docutils literal notranslate"><span class="pre">None</span></code>, 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 <code class="xref py py-exc docutils literal notranslate"><span class="pre">CompileError</span></code> on failure.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.create_static_lib">
<code class="sig-name descname">create_static_lib</code><span class="sig-paren">(</span><em class="sig-param">objects</em>, <em class="sig-param">output_libname</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">target_lang=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_link_object()</span></code></a> and/or
<a class="reference internal" href="#distutils.ccompiler.CCompiler.set_link_objects" title="distutils.ccompiler.CCompiler.set_link_objects"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_link_objects()</span></code></a>, the libraries supplied to <a class="reference internal" href="#distutils.ccompiler.CCompiler.add_library" title="distutils.ccompiler.CCompiler.add_library"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_library()</span></code></a> and/or
<a class="reference internal" href="#distutils.ccompiler.CCompiler.set_libraries" title="distutils.ccompiler.CCompiler.set_libraries"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_libraries()</span></code></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 <code class="xref py py-exc docutils literal notranslate"><span class="pre">LibError</span></code> on failure.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.link">
<code class="sig-name descname">link</code><span class="sig-paren">(</span><em class="sig-param">target_desc</em>, <em class="sig-param">objects</em>, <em class="sig-param">output_filename</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">libraries=None</em>, <em class="sig-param">library_dirs=None</em>, <em class="sig-param">runtime_library_dirs=None</em>, <em class="sig-param">export_symbols=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em>, <em class="sig-param">build_temp=None</em>, <em class="sig-param">target_lang=None</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="file docutils literal notranslate"><span class="pre">libfoo.a</span></code> on Unix and <code class="file docutils literal notranslate"><span class="pre">foo.lib</span></code> 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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_library_dir()</span></code></a> and/or <a class="reference internal" href="#distutils.ccompiler.CCompiler.set_library_dirs" title="distutils.ccompiler.CCompiler.set_library_dirs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_library_dirs()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">compile()</span></code></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.create_static_lib" title="distutils.ccompiler.CCompiler.create_static_lib"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_static_lib()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_static_lib()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">compile()</span></code></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 <code class="xref py py-exc docutils literal notranslate"><span class="pre">LinkError</span></code> on failure.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.link_executable">
<code class="sig-name descname">link_executable</code><span class="sig-paren">(</span><em class="sig-param">objects</em>, <em class="sig-param">output_progname</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">libraries=None</em>, <em class="sig-param">library_dirs=None</em>, <em class="sig-param">runtime_library_dirs=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em>, <em class="sig-param">target_lang=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">link()</span></code></a> method.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.link_shared_lib">
<code class="sig-name descname">link_shared_lib</code><span class="sig-paren">(</span><em class="sig-param">objects</em>, <em class="sig-param">output_libname</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">libraries=None</em>, <em class="sig-param">library_dirs=None</em>, <em class="sig-param">runtime_library_dirs=None</em>, <em class="sig-param">export_symbols=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em>, <em class="sig-param">build_temp=None</em>, <em class="sig-param">target_lang=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">link()</span></code></a> method.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.link_shared_object">
<code class="sig-name descname">link_shared_object</code><span class="sig-paren">(</span><em class="sig-param">objects</em>, <em class="sig-param">output_filename</em><span class="optional">[</span>, <em class="sig-param">output_dir=None</em>, <em class="sig-param">libraries=None</em>, <em class="sig-param">library_dirs=None</em>, <em class="sig-param">runtime_library_dirs=None</em>, <em class="sig-param">export_symbols=None</em>, <em class="sig-param">debug=0</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em>, <em class="sig-param">build_temp=None</em>, <em class="sig-param">target_lang=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">link()</span></code></a> method.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.preprocess">
<code class="sig-name descname">preprocess</code><span class="sig-paren">(</span><em class="sig-param">source</em><span class="optional">[</span>, <em class="sig-param">output_file=None</em>, <em class="sig-param">macros=None</em>, <em class="sig-param">include_dirs=None</em>, <em class="sig-param">extra_preargs=None</em>, <em class="sig-param">extra_postargs=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">compile()</span></code></a>, which will
augment the macros set with <a class="reference internal" href="#distutils.ccompiler.CCompiler.define_macro" title="distutils.ccompiler.CCompiler.define_macro"><code class="xref py py-meth docutils literal notranslate"><span class="pre">define_macro()</span></code></a> and <a class="reference internal" href="#distutils.ccompiler.CCompiler.undefine_macro" title="distutils.ccompiler.CCompiler.undefine_macro"><code class="xref py py-meth docutils literal notranslate"><span class="pre">undefine_macro()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_include_dir()</span></code></a>.</p>
<p>Raises <code class="xref py py-exc docutils literal notranslate"><span class="pre">PreprocessError</span></code> 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"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></a> class, for
use by the various concrete subclasses.</p>
<dl class="method">
<dt id="distutils.ccompiler.CCompiler.executable_filename">
<code class="sig-name descname">executable_filename</code><span class="sig-paren">(</span><em class="sig-param">basename</em><span class="optional">[</span>, <em class="sig-param">strip_dir=0</em>, <em class="sig-param">output_dir=''</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="file docutils literal notranslate"><span class="pre">.exe</span></code> added.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.library_filename">
<code class="sig-name descname">library_filename</code><span class="sig-paren">(</span><em class="sig-param">libname</em><span class="optional">[</span>, <em class="sig-param">lib_type='static'</em>, <em class="sig-param">strip_dir=0</em>, <em class="sig-param">output_dir=''</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">'static'</span></code> will typically  be of the form
<code class="file docutils literal notranslate"><span class="pre">liblibname.a</span></code>, while a <em>lib_type</em> of <code class="docutils literal notranslate"><span class="pre">'dynamic'</span></code>  will be of the form
<code class="file docutils literal notranslate"><span class="pre">liblibname.so</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.object_filenames">
<code class="sig-name descname">object_filenames</code><span class="sig-paren">(</span><em class="sig-param">source_filenames</em><span class="optional">[</span>, <em class="sig-param">strip_dir=0</em>, <em class="sig-param">output_dir=''</em><span class="optional">]</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">shared_object_filename</code><span class="sig-paren">(</span><em class="sig-param">basename</em><span class="optional">[</span>, <em class="sig-param">strip_dir=0</em>, <em class="sig-param">output_dir=''</em><span class="optional">]</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">execute</code><span class="sig-paren">(</span><em class="sig-param">func</em>, <em class="sig-param">args</em><span class="optional">[</span>, <em class="sig-param">msg=None</em>, <em class="sig-param">level=1</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.util.execute()</span></code></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">
<code class="sig-name descname">spawn</code><span class="sig-paren">(</span><em class="sig-param">cmd</em><span class="sig-paren">)</span><a class="headerlink" href="#distutils.ccompiler.CCompiler.spawn" title="Permalink to this definition">¶</a></dt>
<dd><p>Invokes <code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.util.spawn()</span></code>. This invokes an external  process to run
the given command.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.mkpath">
<code class="sig-name descname">mkpath</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="optional">[</span>, <em class="sig-param">mode=511</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.dir_util.mkpath()</span></code></a>. This creates a directory  and any
missing ancestor directories.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.move_file">
<code class="sig-name descname">move_file</code><span class="sig-paren">(</span><em class="sig-param">src</em>, <em class="sig-param">dst</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">distutils.file_util.move_file()</span></code></a>. Renames <em>src</em> to  <em>dst</em>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.announce">
<code class="sig-name descname">announce</code><span class="sig-paren">(</span><em class="sig-param">msg</em><span class="optional">[</span>, <em class="sig-param">level=1</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#distutils.ccompiler.CCompiler.announce" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a message using <code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.log.debug()</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.ccompiler.CCompiler.warn">
<code class="sig-name descname">warn</code><span class="sig-paren">(</span><em class="sig-param">msg</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">debug_print</code><span class="sig-paren">(</span><em class="sig-param">msg</em><span class="sig-paren">)</span><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code></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><span class="section-number">9.3. </span><a class="reference internal" href="#module-distutils.unixccompiler" title="distutils.unixccompiler: UNIX C Compiler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.unixccompiler</span></code></a> — Unix C Compiler<a class="headerlink" href="#module-distutils.unixccompiler" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <code class="xref py py-class docutils literal notranslate"><span class="pre">UnixCCompiler</span></code> class, a subclass of
<code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code> that handles the typical Unix-style command-line  C compiler:</p>
<ul class="simple">
<li><p>macros defined with <code class="xref std std-option docutils literal notranslate"><span class="pre">-Dname[=value]</span></code></p></li>
<li><p>macros undefined with <code class="xref std std-option docutils literal notranslate"><span class="pre">-Uname</span></code></p></li>
<li><p>include search directories specified with <code class="xref std std-option docutils literal notranslate"><span class="pre">-Idir</span></code></p></li>
<li><p>libraries specified with <code class="xref std std-option docutils literal notranslate"><span class="pre">-llib</span></code></p></li>
<li><p>library search directories specified with <code class="xref std std-option docutils literal notranslate"><span class="pre">-Ldir</span></code></p></li>
<li><p>compile handled by <strong class="program">cc</strong> (or similar) executable with <code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code>
option: compiles <code class="file docutils literal notranslate"><span class="pre">.c</span></code> to <code class="file docutils literal notranslate"><span class="pre">.o</span></code></p></li>
<li><p>link static library handled by <strong class="program">ar</strong> command (possibly with
<strong class="program">ranlib</strong>)</p></li>
<li><p>link shared library handled by <strong class="program">cc</strong> <code class="xref std std-option docutils literal notranslate"><span class="pre">-shared</span></code></p></li>
</ul>
</div>
<div class="section" id="module-distutils.msvccompiler">
<span id="distutils-msvccompiler-microsoft-compiler"></span><h2><span class="section-number">9.4. </span><a class="reference internal" href="#module-distutils.msvccompiler" title="distutils.msvccompiler: Microsoft Compiler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.msvccompiler</span></code></a> — Microsoft Compiler<a class="headerlink" href="#module-distutils.msvccompiler" title="Permalink to this headline">¶</a></h2>
<p>This module provides <code class="xref py py-class docutils literal notranslate"><span class="pre">MSVCCompiler</span></code>, an implementation of the abstract
<code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code> 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.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">MSVCCompiler</span></code> 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 <code class="docutils literal notranslate"><span class="pre">SetEnv.Cmd</span></code> 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 <code class="xref py py-class docutils literal notranslate"><span class="pre">MSVCCompiler</span></code>.</p>
</div>
<div class="section" id="module-distutils.bcppcompiler">
<span id="distutils-bcppcompiler-borland-compiler"></span><h2><span class="section-number">9.5. </span><a class="reference internal" href="#module-distutils.bcppcompiler" title="distutils.bcppcompiler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.bcppcompiler</span></code></a> — Borland Compiler<a class="headerlink" href="#module-distutils.bcppcompiler" title="Permalink to this headline">¶</a></h2>
<p>This module provides <code class="xref py py-class docutils literal notranslate"><span class="pre">BorlandCCompiler</span></code>, a subclass of the abstract
<code class="xref py py-class docutils literal notranslate"><span class="pre">CCompiler</span></code> class for the Borland C++ compiler.</p>
</div>
<div class="section" id="module-distutils.cygwinccompiler">
<span id="distutils-cygwincompiler-cygwin-compiler"></span><h2><span class="section-number">9.6. </span><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.cygwincompiler</span></code> — Cygwin Compiler<a class="headerlink" href="#module-distutils.cygwinccompiler" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <code class="xref py py-class docutils literal notranslate"><span class="pre">CygwinCCompiler</span></code> class, a subclass of
<code class="xref py py-class docutils literal notranslate"><span class="pre">UnixCCompiler</span></code> 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.archive_util">
<span id="distutils-archive-util-archiving-utilities"></span><h2><span class="section-number">9.7. </span><a class="reference internal" href="#module-distutils.archive_util" title="distutils.archive_util: Utility functions for creating archive files (tarballs, zip files, ...)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.archive_util</span></code></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">
<code class="sig-prename descclassname">distutils.archive_util.</code><code class="sig-name descname">make_archive</code><span class="sig-paren">(</span><em class="sig-param">base_name</em>, <em class="sig-param">format</em><span class="optional">[</span>, <em class="sig-param">root_dir=None</em>, <em class="sig-param">base_dir=None</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#distutils.archive_util.make_archive" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an archive file (eg. <code class="docutils literal notranslate"><span class="pre">zip</span></code> or <code class="docutils literal notranslate"><span class="pre">tar</span></code>).  <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 <code class="docutils literal notranslate"><span class="pre">zip</span></code>, <code class="docutils literal notranslate"><span class="pre">tar</span></code>, <code class="docutils literal notranslate"><span class="pre">gztar</span></code>, <code class="docutils literal notranslate"><span class="pre">bztar</span></code>, <code class="docutils literal notranslate"><span class="pre">xztar</span></code>, or
<code class="docutils literal notranslate"><span class="pre">ztar</span></code>. <em>root_dir</em> is a directory that will be the root directory of the
archive; ie. we typically <code class="docutils literal notranslate"><span class="pre">chdir</span></code> 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>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.5: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">xztar</span></code> format.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="distutils.archive_util.make_tarball">
<code class="sig-prename descclassname">distutils.archive_util.</code><code class="sig-name descname">make_tarball</code><span class="sig-paren">(</span><em class="sig-param">base_name</em>, <em class="sig-param">base_dir</em><span class="optional">[</span>, <em class="sig-param">compress='gzip'</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">'gzip'</span></code> (the default),
<code class="docutils literal notranslate"><span class="pre">'bzip2'</span></code>, <code class="docutils literal notranslate"><span class="pre">'xz'</span></code>, <code class="docutils literal notranslate"><span class="pre">'compress'</span></code>, or <code class="docutils literal notranslate"><span class="pre">None</span></code>.  For the <code class="docutils literal notranslate"><span class="pre">'compress'</span></code>
method the compression utility named by <strong class="program">compress</strong> must be on the
default program search path, so this is probably Unix-specific.  The output
tar file will be named <code class="file docutils literal notranslate"><span class="pre">base_dir.tar</span></code>, possibly plus the appropriate
compression extension (<code class="docutils literal notranslate"><span class="pre">.gz</span></code>, <code class="docutils literal notranslate"><span class="pre">.bz2</span></code>, <code class="docutils literal notranslate"><span class="pre">.xz</span></code> or <code class="docutils literal notranslate"><span class="pre">.Z</span></code>).  Return the
output filename.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.5: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">xz</span></code> compression.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="distutils.archive_util.make_zipfile">
<code class="sig-prename descclassname">distutils.archive_util.</code><code class="sig-name descname">make_zipfile</code><span class="sig-paren">(</span><em class="sig-param">base_name</em>, <em class="sig-param">base_dir</em><span class="optional">[</span>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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> + <code class="file docutils literal notranslate"><span class="pre">.zip</span></code>.  Uses either the  <a class="reference internal" href="../library/zipfile.html#module-zipfile" title="zipfile: Read and write ZIP-format archive files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipfile</span></code></a> Python
module (if available) or the InfoZIP <code class="file docutils literal notranslate"><span class="pre">zip</span></code>  utility (if installed and
found on the default search path).  If neither  tool is available, raises
<code class="xref py py-exc docutils literal notranslate"><span class="pre">DistutilsExecError</span></code>.   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><span class="section-number">9.8. </span><a class="reference internal" href="#module-distutils.dep_util" title="distutils.dep_util: Utility functions for simple dependency checking"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dep_util</span></code></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">
<code class="sig-prename descclassname">distutils.dep_util.</code><code class="sig-name descname">newer</code><span class="sig-paren">(</span><em class="sig-param">source</em>, <em class="sig-param">target</em><span class="sig-paren">)</span><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 <code class="xref py py-exc docutils literal notranslate"><span class="pre">DistutilsFileError</span></code> if
<em>source</em> does not exist.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.dep_util.newer_pairwise">
<code class="sig-prename descclassname">distutils.dep_util.</code><code class="sig-name descname">newer_pairwise</code><span class="sig-paren">(</span><em class="sig-param">sources</em>, <em class="sig-param">targets</em><span class="sig-paren">)</span><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"><code class="xref py py-func docutils literal notranslate"><span class="pre">newer()</span></code></a>.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.dep_util.newer_group">
<code class="sig-prename descclassname">distutils.dep_util.</code><code class="sig-name descname">newer_group</code><span class="sig-paren">(</span><em class="sig-param">sources</em>, <em class="sig-param">target</em><span class="optional">[</span>, <em class="sig-param">missing='error'</em><span class="optional">]</span><span class="sig-paren">)</span><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 (<code class="docutils literal notranslate"><span class="pre">'error'</span></code>) is to blow up with an
<a class="reference internal" href="../library/exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> from  inside <a class="reference internal" href="../library/os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a>; if it is <code class="docutils literal notranslate"><span class="pre">'ignore'</span></code>, we silently
drop any missing source files; if it is <code class="docutils literal notranslate"><span class="pre">'newer'</span></code>, 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><span class="section-number">9.9. </span><a class="reference internal" href="#module-distutils.dir_util" title="distutils.dir_util: Utility functions for operating on directories and directory trees"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dir_util</span></code></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">
<code class="sig-prename descclassname">distutils.dir_util.</code><code class="sig-name descname">mkpath</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="optional">[</span>, <em class="sig-param">mode=0o777</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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
<code class="xref py py-exc docutils literal notranslate"><span class="pre">DistutilsFileError</span></code> 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">
<code class="sig-prename descclassname">distutils.dir_util.</code><code class="sig-name descname">create_tree</code><span class="sig-paren">(</span><em class="sig-param">base_dir</em>, <em class="sig-param">files</em><span class="optional">[</span>, <em class="sig-param">mode=0o777</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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 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"><code class="xref py py-func docutils literal notranslate"><span class="pre">mkpath()</span></code></a>.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.dir_util.copy_tree">
<code class="sig-prename descclassname">distutils.dir_util.</code><code class="sig-name descname">copy_tree</code><span class="sig-paren">(</span><em class="sig-param">src</em>, <em class="sig-param">dst</em><span class="optional">[</span>, <em class="sig-param">preserve_mode=1</em>, <em class="sig-param">preserve_times=1</em>, <em class="sig-param">preserve_symlinks=0</em>, <em class="sig-param">update=0</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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
<code class="xref py py-exc docutils literal notranslate"><span class="pre">DistutilsFileError</span></code>.  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"><code class="xref py py-func docutils literal notranslate"><span class="pre">mkpath()</span></code></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
<a class="reference internal" href="#distutils.file_util.copy_file" title="distutils.file_util.copy_file"><code class="xref py py-func docutils literal notranslate"><span class="pre">distutils.file_util.copy_file()</span></code></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 <code class="xref py py-func docutils literal notranslate"><span class="pre">copy_file()</span></code>.</p>
<p>Files in <em>src</em> that begin with <code class="file docutils literal notranslate"><span class="pre">.nfs</span></code> 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>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.3.1: </span>NFS files are ignored.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="distutils.dir_util.remove_tree">
<code class="sig-prename descclassname">distutils.dir_util.</code><code class="sig-name descname">remove_tree</code><span class="sig-paren">(</span><em class="sig-param">directory</em><span class="optional">[</span>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> 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><span class="section-number">9.10. </span><a class="reference internal" href="#module-distutils.file_util" title="distutils.file_util: Utility functions for operating on single files"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.file_util</span></code></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">
<code class="sig-prename descclassname">distutils.file_util.</code><code class="sig-name descname">copy_file</code><span class="sig-paren">(</span><em class="sig-param">src</em>, <em class="sig-param">dst</em><span class="optional">[</span>, <em class="sig-param">preserve_mode=1</em>, <em class="sig-param">preserve_times=1</em>, <em class="sig-param">update=0</em>, <em class="sig-param">link=None</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.link()</span></code></a>) or symbolic links
(using <a class="reference internal" href="../library/os.html#os.symlink" title="os.symlink"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.symlink()</span></code></a>) instead of copying: set it to <code class="docutils literal notranslate"><span class="pre">'hard'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'sym'</span></code>; if it is <code class="docutils literal notranslate"><span class="pre">None</span></code> (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"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy_file()</span></code></a> doesn’t check if hard or
symbolic linking is available.  It uses <code class="xref py py-func docutils literal notranslate"><span class="pre">_copy_file_contents()</span></code> to copy file
contents.</p>
<p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(dest_name,</span> <span class="pre">copied)</span></code>: <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">
<code class="sig-prename descclassname">distutils.file_util.</code><code class="sig-name descname">move_file</code><span class="sig-paren">(</span><em class="sig-param">src</em>, <em class="sig-param">dst</em><span class="optional">[</span>, <em class="sig-param">verbose</em>, <em class="sig-param">dry_run</em><span class="optional">]</span><span class="sig-paren">)</span><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="admonition-title">Warning</p>
<p>Handles cross-device moves on Unix using <a class="reference internal" href="#distutils.file_util.copy_file" title="distutils.file_util.copy_file"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy_file()</span></code></a>.  What about
other systems?</p>
</div>
</dd></dl>

<dl class="function">
<dt id="distutils.file_util.write_file">
<code class="sig-prename descclassname">distutils.file_util.</code><code class="sig-name descname">write_file</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">contents</em><span class="sig-paren">)</span><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><span class="section-number">9.11. </span><a class="reference internal" href="#module-distutils.util" title="distutils.util: Miscellaneous other utility functions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.util</span></code></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">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">get_platform</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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; e.g., on Linux, the kernel version isn’t
particularly important.</p>
<p>Examples of returned values:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">linux-i586</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">linux-alpha</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">solaris-2.6-sun4u</span></code></p></li>
</ul>
<p>For non-POSIX platforms, currently just returns <code class="docutils literal notranslate"><span class="pre">sys.platform</span></code>.</p>
<p>For Mac OS X systems the OS version reflects the minimal version on which
binaries will run (that is, the value of <code class="docutils literal notranslate"><span class="pre">MACOSX_DEPLOYMENT_TARGET</span></code>
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 universal binary status instead of the architecture of the current
processor. For 32-bit universal binaries the architecture is <code class="docutils literal notranslate"><span class="pre">fat</span></code>,
for 64-bit universal binaries the architecture is <code class="docutils literal notranslate"><span class="pre">fat64</span></code>, and
for 4-way universal binaries the architecture is <code class="docutils literal notranslate"><span class="pre">universal</span></code>. Starting
from Python 2.7 and Python 3.2 the architecture <code class="docutils literal notranslate"><span class="pre">fat3</span></code> is used for
a 3-way universal build (ppc, i386, x86_64) and <code class="docutils literal notranslate"><span class="pre">intel</span></code> is used for
a universal build with the i386 and x86_64 architectures</p>
<p>Examples of returned values on Mac OS X:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">macosx-10.3-ppc</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">macosx-10.3-fat</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">macosx-10.5-universal</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">macosx-10.6-intel</span></code></p></li>
</ul>
</dd></dl>

<dl class="function">
<dt id="distutils.util.convert_path">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">convert_path</code><span class="sig-paren">(</span><em class="sig-param">pathname</em><span class="sig-paren">)</span><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#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></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">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">change_root</code><span class="sig-paren">(</span><em class="sig-param">new_root</em>, <em class="sig-param">pathname</em><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">os.path.join(new_root,pathname)</span></code> 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">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">check_environ</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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><p><span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">HOME</span></code> - user’s home directory (Unix only)</p></li>
<li><p><span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PLAT</span></code> - description of the current platform, including hardware and
OS (see <a class="reference internal" href="#distutils.util.get_platform" title="distutils.util.get_platform"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_platform()</span></code></a>)</p></li>
</ul>
</dd></dl>

<dl class="function">
<dt id="distutils.util.subst_vars">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">subst_vars</code><span class="sig-paren">(</span><em class="sig-param">s</em>, <em class="sig-param">local_vars</em><span class="sig-paren">)</span><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
<code class="docutils literal notranslate"><span class="pre">$</span></code> 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 <code class="docutils literal notranslate"><span class="pre">os.environ</span></code> 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"><code class="xref py py-func docutils literal notranslate"><span class="pre">check_environ()</span></code></a>.  Raise <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>
for any variables not found in either <em>local_vars</em> or <code class="docutils literal notranslate"><span class="pre">os.environ</span></code>.</p>
<p>Note that this is not a fully-fledged string interpolation function. A valid
<code class="docutils literal notranslate"><span class="pre">$variable</span></code> 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.split_quoted">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">split_quoted</code><span class="sig-paren">(</span><em class="sig-param">s</em><span class="sig-paren">)</span><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">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">execute</code><span class="sig-paren">(</span><em class="sig-param">func</em>, <em class="sig-param">args</em><span class="optional">[</span>, <em class="sig-param">msg=None</em>, <em class="sig-param">verbose=0</em>, <em class="sig-param">dry_run=0</em><span class="optional">]</span><span class="sig-paren">)</span><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">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">strtobool</code><span class="sig-paren">(</span><em class="sig-param">val</em><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">y</span></code>, <code class="docutils literal notranslate"><span class="pre">yes</span></code>, <code class="docutils literal notranslate"><span class="pre">t</span></code>, <code class="docutils literal notranslate"><span class="pre">true</span></code>, <code class="docutils literal notranslate"><span class="pre">on</span></code>  and <code class="docutils literal notranslate"><span class="pre">1</span></code>; false values
are <code class="docutils literal notranslate"><span class="pre">n</span></code>, <code class="docutils literal notranslate"><span class="pre">no</span></code>, <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">false</span></code>,  <code class="docutils literal notranslate"><span class="pre">off</span></code> and <code class="docutils literal notranslate"><span class="pre">0</span></code>.  Raises
<a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if <em>val</em>  is anything else.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.util.byte_compile">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">byte_compile</code><span class="sig-paren">(</span><em class="sig-param">py_files</em><span class="optional">[</span>, <em class="sig-param">optimize=0</em>, <em class="sig-param">force=0</em>, <em class="sig-param">prefix=None</em>, <em class="sig-param">base_dir=None</em>, <em class="sig-param">verbose=1</em>, <em class="sig-param">dry_run=0</em>, <em class="sig-param">direct=None</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="file docutils literal notranslate"><span class="pre">.pyc</span></code> files in a
<code class="file docutils literal notranslate"><span class="pre">__pycache__</span></code> subdirectory (see <span class="target" id="index-3"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-3147"><strong>PEP 3147</strong></a> and <span class="target" id="index-4"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0488"><strong>PEP 488</strong></a>).
<em>py_files</em> is a list of files to compile; any files that don’t end in
<code class="file docutils literal notranslate"><span class="pre">.py</span></code> are silently skipped.  <em>optimize</em> must be one of the following:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">0</span></code> - don’t optimize</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">1</span></code> - normal optimization (like <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-O</span></code>)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">2</span></code> - extra optimization (like <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-OO</span></code>)</p></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"><span class="xref std std-term">bytecode</span></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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code></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"><code class="xref py py-func docutils literal notranslate"><span class="pre">byte_compile()</span></code></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 <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.2.3: </span>Create <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with an <a class="reference internal" href="../library/imp.html#imp.get_tag" title="imp.get_tag"><code class="xref py py-func docutils literal notranslate"><span class="pre">import</span> <span class="pre">magic</span> <span class="pre">tag</span></code></a> in their name, in a <code class="file docutils literal notranslate"><span class="pre">__pycache__</span></code> subdirectory
instead of files without tag in the current directory.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.5: </span>Create <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files according to <span class="target" id="index-5"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0488"><strong>PEP 488</strong></a>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="distutils.util.rfc822_escape">
<code class="sig-prename descclassname">distutils.util.</code><code class="sig-name descname">rfc822_escape</code><span class="sig-paren">(</span><em class="sig-param">header</em><span class="sig-paren">)</span><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-6"></span><a class="rfc reference external" href="https://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><span class="section-number">9.12. </span><a class="reference internal" href="#module-distutils.dist" title="distutils.dist: Provides the Distribution class, which represents the module distribution being built/installed/distributed"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dist</span></code></a> — The Distribution class<a class="headerlink" href="#module-distutils.dist" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a> 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><span class="section-number">9.13. </span><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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.extension</span></code></a> — The Extension class<a class="headerlink" href="#module-distutils.extension" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <code class="xref py py-class docutils literal notranslate"><span class="pre">Extension</span></code> 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><span class="section-number">9.14. </span><a class="reference internal" href="#module-distutils.debug" title="distutils.debug: Provides the debug flag for distutils"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.debug</span></code></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><span class="section-number">9.15. </span><a class="reference internal" href="#module-distutils.errors" title="distutils.errors: Provides standard distutils exceptions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.errors</span></code></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 <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span> <span class="pre">*</span></code> mode; it only exports
symbols whose names start with <code class="docutils literal notranslate"><span class="pre">Distutils</span></code> and end with <code class="docutils literal notranslate"><span class="pre">Error</span></code>.</p>
</div>
<div class="section" id="module-distutils.fancy_getopt">
<span id="distutils-fancy-getopt-wrapper-around-the-standard-getopt-module"></span><h2><span class="section-number">9.16. </span><a class="reference internal" href="#module-distutils.fancy_getopt" title="distutils.fancy_getopt: Additional getopt functionality"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.fancy_getopt</span></code></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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">getopt</span></code></a>  module that
provides the following additional features:</p>
<ul class="simple">
<li><p>short and long options are tied together</p></li>
<li><p>options have help strings, so <a class="reference internal" href="#distutils.fancy_getopt.fancy_getopt" title="distutils.fancy_getopt.fancy_getopt"><code class="xref py py-func docutils literal notranslate"><span class="pre">fancy_getopt()</span></code></a> could potentially  create a
complete usage summary</p></li>
<li><p>options set attributes of a passed-in object</p></li>
<li><p>boolean options can have “negative aliases” — eg. if <code class="xref std std-option docutils literal notranslate"><span class="pre">--quiet</span></code> is
the “negative alias” of <code class="xref std std-option docutils literal notranslate"><span class="pre">--verbose</span></code>, then <code class="xref std std-option docutils literal notranslate"><span class="pre">--quiet</span></code> on the
command line sets <em>verbose</em> to false.</p></li>
</ul>
<dl class="function">
<dt id="distutils.fancy_getopt.fancy_getopt">
<code class="sig-prename descclassname">distutils.fancy_getopt.</code><code class="sig-name descname">fancy_getopt</code><span class="sig-paren">(</span><em class="sig-param">options</em>, <em class="sig-param">negative_opt</em>, <em class="sig-param">object</em>, <em class="sig-param">args</em><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">(long_option,</span> <span class="pre">short_option,</span>
<span class="pre">help_string)</span></code> 3-tuples as described in the constructor for
<a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><code class="xref py py-class docutils literal notranslate"><span class="pre">FancyGetopt</span></code></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."><code class="xref py py-meth docutils literal notranslate"><span class="pre">getopt()</span></code></a>
method of the <a class="reference internal" href="#distutils.fancy_getopt.FancyGetopt" title="distutils.fancy_getopt.FancyGetopt"><code class="xref py py-class docutils literal notranslate"><span class="pre">FancyGetopt</span></code></a> class). <em>args</em> is the argument list. Will use
<code class="docutils literal notranslate"><span class="pre">sys.argv[1:]</span></code> if you  pass <code class="docutils literal notranslate"><span class="pre">None</span></code> as <em>args</em>.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.fancy_getopt.wrap_text">
<code class="sig-prename descclassname">distutils.fancy_getopt.</code><code class="sig-name descname">wrap_text</code><span class="sig-paren">(</span><em class="sig-param">text</em>, <em class="sig-param">width</em><span class="sig-paren">)</span><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><code class="sig-prename descclassname">distutils.fancy_getopt.</code><code class="sig-name descname">FancyGetopt</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">option_table=None</em><span class="optional">]</span><span class="sig-paren">)</span><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: <code class="docutils literal notranslate"><span class="pre">(long_option,</span> <span class="pre">short_option,</span>
<span class="pre">help_string)</span></code></p>
<p>If an option takes an argument, its <em>long_option</em> should have <code class="docutils literal notranslate"><span class="pre">'='</span></code> appended;
<em>short_option</em> should just be a single character, no <code class="docutils literal notranslate"><span class="pre">':'</span></code> in any case.
<em>short_option</em> should be <code class="docutils literal notranslate"><span class="pre">None</span></code> 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"><code class="xref py py-class docutils literal notranslate"><span class="pre">FancyGetopt</span></code></a> class provides the following methods:</p>
<dl class="method">
<dt id="distutils.fancy_getopt.FancyGetopt.getopt">
<code class="sig-prename descclassname">FancyGetopt.</code><code class="sig-name descname">getopt</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">args=None</em>, <em class="sig-param">object=None</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">None</span></code> or not supplied, uses <code class="docutils literal notranslate"><span class="pre">sys.argv[1:]</span></code>.  If <em>object</em> is
<code class="docutils literal notranslate"><span class="pre">None</span></code> or not supplied, creates a new <code class="xref py py-class docutils literal notranslate"><span class="pre">OptionDummy</span></code> instance, stores
option values there, and returns a tuple <code class="docutils literal notranslate"><span class="pre">(args,</span> <span class="pre">object)</span></code>.  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."><code class="xref py py-func docutils literal notranslate"><span class="pre">getopt()</span></code></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">
<code class="sig-prename descclassname">FancyGetopt.</code><code class="sig-name descname">get_option_order</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#distutils.fancy_getopt.FancyGetopt.get_option_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the list of <code class="docutils literal notranslate"><span class="pre">(option,</span> <span class="pre">value)</span></code> 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."><code class="xref py py-meth docutils literal notranslate"><span class="pre">getopt()</span></code></a>  Raises <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></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."><code class="xref py py-meth docutils literal notranslate"><span class="pre">getopt()</span></code></a> hasn’t been called
yet.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.fancy_getopt.FancyGetopt.generate_help">
<code class="sig-prename descclassname">FancyGetopt.</code><code class="sig-name descname">generate_help</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">header=None</em><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">FancyGetopt</span></code></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><span class="section-number">9.17. </span><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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.filelist</span></code></a> — The FileList class<a class="headerlink" href="#module-distutils.filelist" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <code class="xref py py-class docutils literal notranslate"><span class="pre">FileList</span></code> 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><span class="section-number">9.18. </span><a class="reference internal" href="#module-distutils.log" title="distutils.log: A simple logging mechanism, 282-style"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.log</span></code></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><span class="section-number">9.19. </span><a class="reference internal" href="#module-distutils.spawn" title="distutils.spawn: Provides the spawn() function"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.spawn</span></code></a> — Spawn a sub-process<a class="headerlink" href="#module-distutils.spawn" title="Permalink to this headline">¶</a></h2>
<p>This module provides the <code class="xref py py-func docutils literal notranslate"><span class="pre">spawn()</span></code> function, a front-end to  various
platform-specific functions for launching another program in a  sub-process.
Also provides <code class="xref py py-func docutils literal notranslate"><span class="pre">find_executable()</span></code> 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><span class="section-number">9.20. </span><a class="reference internal" href="#module-distutils.sysconfig" title="distutils.sysconfig: Low-level access to configuration information of the Python interpreter."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.sysconfig</span></code></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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.sysconfig</span></code></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 <code class="file docutils literal notranslate"><span class="pre">Makefile</span></code> and configuration header that are
installed with Python on Unix systems.  The configuration header is called
<code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code> for Python versions starting with 2.2, and <code class="file docutils literal notranslate"><span class="pre">config.h</span></code>
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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> package.</p>
<dl class="data">
<dt id="distutils.sysconfig.PREFIX">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">PREFIX</code><a class="headerlink" href="#distutils.sysconfig.PREFIX" title="Permalink to this definition">¶</a></dt>
<dd><p>The result of <code class="docutils literal notranslate"><span class="pre">os.path.normpath(sys.prefix)</span></code>.</p>
</dd></dl>

<dl class="data">
<dt id="distutils.sysconfig.EXEC_PREFIX">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">EXEC_PREFIX</code><a class="headerlink" href="#distutils.sysconfig.EXEC_PREFIX" title="Permalink to this definition">¶</a></dt>
<dd><p>The result of <code class="docutils literal notranslate"><span class="pre">os.path.normpath(sys.exec_prefix)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.sysconfig.get_config_var">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_config_var</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="sig-paren">)</span><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
<code class="docutils literal notranslate"><span class="pre">get_config_vars().get(name)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.sysconfig.get_config_vars">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_config_vars</code><span class="sig-paren">(</span><em class="sig-param">...</em><span class="sig-paren">)</span><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,
<code class="docutils literal notranslate"><span class="pre">None</span></code> will be included for that variable.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.sysconfig.get_config_h_filename">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_config_h_filename</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_makefile_filename</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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 <code class="file docutils literal notranslate"><span class="pre">Makefile</span></code> 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">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_python_inc</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">plat_specific</em><span class="optional">[</span>, <em class="sig-param">prefix</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-const docutils literal notranslate"><span class="pre">PREFIX</span></code></a>, or as the exec-prefix instead of <a class="reference internal" href="#distutils.sysconfig.EXEC_PREFIX" title="distutils.sysconfig.EXEC_PREFIX"><code class="xref py py-const docutils literal notranslate"><span class="pre">EXEC_PREFIX</span></code></a> if
<em>plat_specific</em> is true.</p>
</dd></dl>

<dl class="function">
<dt id="distutils.sysconfig.get_python_lib">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">get_python_lib</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">plat_specific</em><span class="optional">[</span>, <em class="sig-param">standard_lib</em><span class="optional">[</span>, <em class="sig-param">prefix</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><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"><code class="xref py py-const docutils literal notranslate"><span class="pre">PREFIX</span></code></a>, or as the exec-prefix instead of <a class="reference internal" href="#distutils.sysconfig.EXEC_PREFIX" title="distutils.sysconfig.EXEC_PREFIX"><code class="xref py py-const docutils literal notranslate"><span class="pre">EXEC_PREFIX</span></code></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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a>
package.</p>
<dl class="function">
<dt id="distutils.sysconfig.customize_compiler">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">customize_compiler</code><span class="sig-paren">(</span><em class="sig-param">compiler</em><span class="sig-paren">)</span><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"><code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.ccompiler.CCompiler</span></code></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 <code class="file docutils literal notranslate"><span class="pre">Makefile</span></code>.  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">
<code class="sig-prename descclassname">distutils.sysconfig.</code><code class="sig-name descname">set_python_build</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.sysconfig</span></code></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><span class="section-number">9.21. </span><a class="reference internal" href="#module-distutils.text_file" title="distutils.text_file: Provides the TextFile class, a simple interface to text files"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.text_file</span></code></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextFile</span></code></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><code class="sig-prename descclassname">distutils.text_file.</code><code class="sig-name descname">TextFile</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">filename=None</em>, <em class="sig-param">file=None</em>, <em class="sig-param">**options</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">#</span></code>  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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">warn()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unreadline()</span></code></a> for implementing
line-at-a-time lookahead.</p>
<p><a class="reference internal" href="#distutils.text_file.TextFile" title="distutils.text_file.TextFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextFile</span></code></a> instances are create with either <em>filename</em>, <em>file</em>, or both.
<a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> is raised if both are <code class="docutils literal notranslate"><span class="pre">None</span></code>. <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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a>
and <a class="reference internal" href="#distutils.text_file.TextFile.close" title="distutils.text_file.TextFile.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextFile</span></code></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextFile</span></code></a> creates its own using the
<a class="reference internal" href="../library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 31%" />
<col style="width: 54%" />
<col style="width: 15%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>option name</p></th>
<th class="head"><p>description</p></th>
<th class="head"><p>default</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>strip_comments</em></p></td>
<td><p>strip from <code class="docutils literal notranslate"><span class="pre">'#'</span></code> to
end-of-line, as well as any
whitespace leading up to the
<code class="docutils literal notranslate"><span class="pre">'#'</span></code>—unless it is
escaped by a backslash</p></td>
<td><p>true</p></td>
</tr>
<tr class="row-odd"><td><p><em>lstrip_ws</em></p></td>
<td><p>strip leading whitespace from
each line before returning it</p></td>
<td><p>false</p></td>
</tr>
<tr class="row-even"><td><p><em>rstrip_ws</em></p></td>
<td><p>strip trailing whitespace
(including line terminator!)
from each line before
returning it.</p></td>
<td><p>true</p></td>
</tr>
<tr class="row-odd"><td><p><em>skip_blanks</em></p></td>
<td><p>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.)</p></td>
<td><p>true</p></td>
</tr>
<tr class="row-even"><td><p><em>join_lines</em></p></td>
<td><p>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.</p></td>
<td><p>false</p></td>
</tr>
<tr class="row-odd"><td><p><em>collapse_join</em></p></td>
<td><p>strip leading whitespace from
lines that are joined to their
predecessor; only matters if
<code class="docutils literal notranslate"><span class="pre">(join_lines</span> <span class="pre">and</span> <span class="pre">not</span>
<span class="pre">lstrip_ws)</span></code></p></td>
<td><p>false</p></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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a> method!  In particular, <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a>  returns <code class="docutils literal notranslate"><span class="pre">None</span></code> 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">
<code class="sig-name descname">open</code><span class="sig-paren">(</span><em class="sig-param">filename</em><span class="sig-paren">)</span><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">
<code class="sig-name descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">warn</code><span class="sig-paren">(</span><em class="sig-param">msg</em><span class="optional">[</span>, <em class="sig-param">line=None</em><span class="optional">]</span><span class="sig-paren">)</span><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 <code class="docutils literal notranslate"><span class="pre">&quot;lines</span> <span class="pre">3-5&quot;</span></code>.  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">
<code class="sig-name descname">readline</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unreadline()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">warn()</span></code></a> after <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a> emits a warning  about the physical line(s)
just read.  Returns <code class="docutils literal notranslate"><span class="pre">None</span></code> 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">
<code class="sig-name descname">readlines</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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">
<code class="sig-name descname">unreadline</code><span class="sig-paren">(</span><em class="sig-param">line</em><span class="sig-paren">)</span><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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unreadline()</span></code></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)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a>. If multiple calls are made to <a class="reference internal" href="#distutils.text_file.TextFile.unreadline" title="distutils.text_file.TextFile.unreadline"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unreadline()</span></code></a> before a call
to <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></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><span class="section-number">9.22. </span><a class="reference internal" href="#module-distutils.version" title="distutils.version: Implements classes that represent module version numbers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.version</span></code></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><span class="section-number">9.23. </span><a class="reference internal" href="#module-distutils.cmd" title="distutils.cmd: Provides the abstract base class :class:`~distutils.cmd.Command`. This class is subclassed by the modules in the distutils.command subpackage."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.cmd</span></code></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a>.</p>
<dl class="class">
<dt id="distutils.cmd.Command">
<em class="property">class </em><code class="sig-prename descclassname">distutils.cmd.</code><code class="sig-name descname">Command</code><span class="sig-paren">(</span><em class="sig-param">dist</em><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize_options()</span></code></a> and defined (given their final values) in
<a class="reference internal" href="#distutils.cmd.Command.finalize_options" title="distutils.cmd.Command.finalize_options"><code class="xref py py-meth docutils literal notranslate"><span class="pre">finalize_options()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">finalize_options()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">run()</span></code></a> method, which must also be implemented by every
command class.</p>
<p>The class constructor takes a single argument <em>dist</em>, a
<a class="reference internal" href="#distutils.core.Distribution" title="distutils.core.Distribution"><code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code></a> instance.</p>
</dd></dl>

</div>
<div class="section" id="creating-a-new-distutils-command">
<h2><span class="section-number">9.24. </span>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: Contains one module for each standard Distutils command."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command</span></code></a> package. There
is a sample template in that directory called <code class="file docutils literal notranslate"><span class="pre">command_template</span></code>.  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
<code class="docutils literal notranslate"><span class="pre">peel_banana</span></code> (so that users can run <code class="docutils literal notranslate"><span class="pre">setup.py</span> <span class="pre">peel_banana</span></code>), you’d copy
<code class="file docutils literal notranslate"><span class="pre">command_template</span></code> to <code class="file docutils literal notranslate"><span class="pre">distutils/command/peel_banana.py</span></code>, then edit
it so that it’s implementing the class <code class="xref py py-class docutils literal notranslate"><span class="pre">peel_banana</span></code>, a subclass of
<a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.cmd.Command</span></code></a>.</p>
<p>Subclasses of <a class="reference internal" href="#distutils.cmd.Command" title="distutils.cmd.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a> must define the following methods.</p>
<dl class="method">
<dt id="distutils.cmd.Command.initialize_options">
<code class="sig-prename descclassname">Command.</code><code class="sig-name descname">initialize_options</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize_options()</span></code></a>
implementations are just a bunch of <code class="docutils literal notranslate"><span class="pre">self.foo</span> <span class="pre">=</span> <span class="pre">None</span></code> assignments.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.cmd.Command.finalize_options">
<code class="sig-prename descclassname">Command.</code><code class="sig-name descname">finalize_options</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize_options()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="distutils.cmd.Command.run">
<code class="sig-prename descclassname">Command.</code><code class="sig-name descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize_options()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">finalize_options()</span></code></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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">run()</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="distutils.cmd.Command.sub_commands">
<code class="sig-prename descclassname">Command.</code><code class="sig-name descname">sub_commands</code><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. <code class="docutils literal notranslate"><span class="pre">install</span></code> as the parent with sub-commands <code class="docutils literal notranslate"><span class="pre">install_lib</span></code>,
<code class="docutils literal notranslate"><span class="pre">install_headers</span></code>, etc.  The parent of a family of commands defines
<em>sub_commands</em> as a class attribute; it’s a list of 2-tuples <code class="docutils literal notranslate"><span class="pre">(command_name,</span>
<span class="pre">predicate)</span></code>, with <em>command_name</em> a string and <em>predicate</em> a function, a
string or <code class="docutils literal notranslate"><span class="pre">None</span></code>.  <em>predicate</em> is a method of the parent command that
determines whether the corresponding command is applicable in the current
situation.  (E.g. <code class="docutils literal notranslate"><span class="pre">install_headers</span></code> is only applicable if we have any C
header files to install.)  If <em>predicate</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, 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><span class="section-number">9.25. </span><a class="reference internal" href="#module-distutils.command" title="distutils.command: Contains one module for each standard Distutils command."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command</span></code></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><span class="section-number">9.26. </span><a class="reference internal" href="#module-distutils.command.bdist" title="distutils.command.bdist: Build a binary installer for a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist</span></code></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><span class="section-number">9.27. </span><a class="reference internal" href="#module-distutils.command.bdist_packager" title="distutils.command.bdist_packager: Abstract base class for packagers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_packager</span></code></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><span class="section-number">9.28. </span><a class="reference internal" href="#module-distutils.command.bdist_dumb" title="distutils.command.bdist_dumb: Build a &quot;dumb&quot; installer - a simple archive of files"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_dumb</span></code></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><span class="section-number">9.29. </span><a class="reference internal" href="#module-distutils.command.bdist_msi" title="distutils.command.bdist_msi: Build a binary distribution as a Windows MSI file"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_msi</span></code></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><code class="sig-prename descclassname">distutils.command.bdist_msi.</code><code class="sig-name descname">bdist_msi</code><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="https://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx">Windows Installer</a> (.msi) binary package.</p>
<p>In most cases, the <code class="docutils literal notranslate"><span class="pre">bdist_msi</span></code> installer is a better choice than the
<code class="docutils literal notranslate"><span class="pre">bdist_wininst</span></code> 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><span class="section-number">9.30. </span><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"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_rpm</span></code></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><span class="section-number">9.31. </span><a class="reference internal" href="#module-distutils.command.bdist_wininst" title="distutils.command.bdist_wininst: Build a Windows installer"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_wininst</span></code></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><span class="section-number">9.32. </span><a class="reference internal" href="#module-distutils.command.sdist" title="distutils.command.sdist: Build a source distribution"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.sdist</span></code></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><span class="section-number">9.33. </span><a class="reference internal" href="#module-distutils.command.build" title="distutils.command.build: Build all files of a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build</span></code></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><span class="section-number">9.34. </span><a class="reference internal" href="#module-distutils.command.build_clib" title="distutils.command.build_clib: Build any C libraries in a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_clib</span></code></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><span class="section-number">9.35. </span><a class="reference internal" href="#module-distutils.command.build_ext" title="distutils.command.build_ext: Build any extensions in a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_ext</span></code></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><span class="section-number">9.36. </span><a class="reference internal" href="#module-distutils.command.build_py" title="distutils.command.build_py: Build the .py/.pyc files of a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_py</span></code></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>
<dl class="class">
<dt id="distutils.command.build_py.build_py">
<em class="property">class </em><code class="sig-prename descclassname">distutils.command.build_py.</code><code class="sig-name descname">build_py</code><a class="headerlink" href="#distutils.command.build_py.build_py" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="class">
<dt id="distutils.command.build_py.build_py_2to3">
<em class="property">class </em><code class="sig-prename descclassname">distutils.command.build_py.</code><code class="sig-name descname">build_py_2to3</code><a class="headerlink" href="#distutils.command.build_py.build_py_2to3" title="Permalink to this definition">¶</a></dt>
<dd><p>Alternative implementation of build_py which also runs the
2to3 conversion library on each .py file that is going to be
installed. To use this in a setup.py file for a distribution
that is designed to run with both Python 2.x and 3.x, add:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">distutils.command.build_py</span> <span class="kn">import</span> <span class="n">build_py_2to3</span> <span class="k">as</span> <span class="n">build_py</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">distutils.command.build_py</span> <span class="kn">import</span> <span class="n">build_py</span>
</pre></div>
</div>
<p>to your setup.py, and later:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cmdclass</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;build_py&#39;</span><span class="p">:</span> <span class="n">build_py</span><span class="p">}</span>
</pre></div>
</div>
<p>to the invocation of setup().</p>
</dd></dl>

</div>
<div class="section" id="module-distutils.command.build_scripts">
<span id="distutils-command-build-scripts-build-the-scripts-of-a-package"></span><h2><span class="section-number">9.37. </span><a class="reference internal" href="#module-distutils.command.build_scripts" title="distutils.command.build_scripts: Build the scripts of a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_scripts</span></code></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><span class="section-number">9.38. </span><a class="reference internal" href="#module-distutils.command.clean" title="distutils.command.clean: Clean a package build area"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.clean</span></code></a> — Clean a package build area<a class="headerlink" href="#module-distutils.command.clean" title="Permalink to this headline">¶</a></h2>
<p>This command removes the temporary files created by <strong class="command">build</strong>
and its subcommands, like intermediary compiled object files.  With
the <code class="docutils literal notranslate"><span class="pre">--all</span></code> option, the complete build directory will be removed.</p>
<p>Extension modules built <a class="reference internal" href="configfile.html#distutils-build-ext-inplace"><span class="std std-ref">in place</span></a>
will not be cleaned, as they are not in the build directory.</p>
</div>
<div class="section" id="module-distutils.command.config">
<span id="distutils-command-config-perform-package-configuration"></span><h2><span class="section-number">9.39. </span><a class="reference internal" href="#module-distutils.command.config" title="distutils.command.config: Perform package configuration"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.config</span></code></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><span class="section-number">9.40. </span><a class="reference internal" href="#module-distutils.command.install" title="distutils.command.install: Install a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install</span></code></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><span class="section-number">9.41. </span><a class="reference internal" href="#module-distutils.command.install_data" title="distutils.command.install_data: Install data files from a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_data</span></code></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><span class="section-number">9.42. </span><a class="reference internal" href="#module-distutils.command.install_headers" title="distutils.command.install_headers: Install C/C++ header files from a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_headers</span></code></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><span class="section-number">9.43. </span><a class="reference internal" href="#module-distutils.command.install_lib" title="distutils.command.install_lib: Install library files from a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_lib</span></code></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><span class="section-number">9.44. </span><a class="reference internal" href="#module-distutils.command.install_scripts" title="distutils.command.install_scripts: Install script files from a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_scripts</span></code></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><span class="section-number">9.45. </span><a class="reference internal" href="#module-distutils.command.register" title="distutils.command.register: Register a module with the Python Package Index"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.register</span></code></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 <code class="docutils literal notranslate"><span class="pre">register</span></code> command registers the package with the Python Package  Index.
This is described in more detail in <span class="target" id="index-7"></span><a class="pep reference external" href="https://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><span class="section-number">9.46. </span><a class="reference internal" href="#module-distutils.command.check" title="distutils.command.check: Check the meta-data of a package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.check</span></code></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 <code class="docutils literal notranslate"><span class="pre">check</span></code> 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 <code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code> function.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">9. API Reference</a><ul>
<li><a class="reference internal" href="#module-distutils.core">9.1. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.core</span></code> — Core Distutils functionality</a></li>
<li><a class="reference internal" href="#module-distutils.ccompiler">9.2. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.ccompiler</span></code> — CCompiler base class</a></li>
<li><a class="reference internal" href="#module-distutils.unixccompiler">9.3. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.unixccompiler</span></code> — Unix C Compiler</a></li>
<li><a class="reference internal" href="#module-distutils.msvccompiler">9.4. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.msvccompiler</span></code> — Microsoft Compiler</a></li>
<li><a class="reference internal" href="#module-distutils.bcppcompiler">9.5. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.bcppcompiler</span></code> — Borland Compiler</a></li>
<li><a class="reference internal" href="#module-distutils.cygwinccompiler">9.6. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.cygwincompiler</span></code> — Cygwin Compiler</a></li>
<li><a class="reference internal" href="#module-distutils.archive_util">9.7. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.archive_util</span></code> —  Archiving utilities</a></li>
<li><a class="reference internal" href="#module-distutils.dep_util">9.8. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dep_util</span></code> — Dependency checking</a></li>
<li><a class="reference internal" href="#module-distutils.dir_util">9.9. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dir_util</span></code> — Directory tree operations</a></li>
<li><a class="reference internal" href="#module-distutils.file_util">9.10. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.file_util</span></code> — Single file operations</a></li>
<li><a class="reference internal" href="#module-distutils.util">9.11. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.util</span></code> — Miscellaneous other utility functions</a></li>
<li><a class="reference internal" href="#module-distutils.dist">9.12. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.dist</span></code> — The Distribution class</a></li>
<li><a class="reference internal" href="#module-distutils.extension">9.13. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.extension</span></code> — The Extension class</a></li>
<li><a class="reference internal" href="#module-distutils.debug">9.14. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.debug</span></code> — Distutils debug mode</a></li>
<li><a class="reference internal" href="#module-distutils.errors">9.15. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.errors</span></code> — Distutils exceptions</a></li>
<li><a class="reference internal" href="#module-distutils.fancy_getopt">9.16. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.fancy_getopt</span></code> — Wrapper around the standard getopt module</a></li>
<li><a class="reference internal" href="#module-distutils.filelist">9.17. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.filelist</span></code> — The FileList class</a></li>
<li><a class="reference internal" href="#module-distutils.log">9.18. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.log</span></code> — Simple PEP 282-style logging</a></li>
<li><a class="reference internal" href="#module-distutils.spawn">9.19. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.spawn</span></code> — Spawn a sub-process</a></li>
<li><a class="reference internal" href="#module-distutils.sysconfig">9.20. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.sysconfig</span></code> — System configuration information</a></li>
<li><a class="reference internal" href="#module-distutils.text_file">9.21. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.text_file</span></code> — The TextFile class</a></li>
<li><a class="reference internal" href="#module-distutils.version">9.22. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.version</span></code> — Version number classes</a></li>
<li><a class="reference internal" href="#module-distutils.cmd">9.23. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.cmd</span></code> — Abstract base class for Distutils commands</a></li>
<li><a class="reference internal" href="#creating-a-new-distutils-command">9.24. Creating a new Distutils command</a></li>
<li><a class="reference internal" href="#module-distutils.command">9.25. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command</span></code> — Individual Distutils commands</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist">9.26. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist</span></code> — Build a binary installer</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist_packager">9.27. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_packager</span></code> — Abstract base class for packagers</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist_dumb">9.28. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_dumb</span></code> — Build a “dumb” installer</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist_msi">9.29. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_msi</span></code> — Build a Microsoft Installer binary package</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist_rpm">9.30. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_rpm</span></code> — Build a binary distribution as a Redhat RPM and SRPM</a></li>
<li><a class="reference internal" href="#module-distutils.command.bdist_wininst">9.31. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.bdist_wininst</span></code> — Build a Windows installer</a></li>
<li><a class="reference internal" href="#module-distutils.command.sdist">9.32. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.sdist</span></code> — Build a source distribution</a></li>
<li><a class="reference internal" href="#module-distutils.command.build">9.33. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build</span></code> — Build all files of a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.build_clib">9.34. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_clib</span></code> — Build any C libraries in a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.build_ext">9.35. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_ext</span></code> — Build any extensions in a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.build_py">9.36. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_py</span></code> — Build the .py/.pyc files of a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.build_scripts">9.37. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.build_scripts</span></code> — Build the scripts of a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.clean">9.38. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.clean</span></code> — Clean a package build area</a></li>
<li><a class="reference internal" href="#module-distutils.command.config">9.39. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.config</span></code> — Perform package configuration</a></li>
<li><a class="reference internal" href="#module-distutils.command.install">9.40. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install</span></code> — Install a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.install_data">9.41. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_data</span></code> — Install data files from a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.install_headers">9.42. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_headers</span></code> — Install C/C++ header files from a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.install_lib">9.43. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_lib</span></code> — Install library files from a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.install_scripts">9.44. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.install_scripts</span></code> — Install script files from a package</a></li>
<li><a class="reference internal" href="#module-distutils.command.register">9.45. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.register</span></code> — Register a module with the Python Package Index</a></li>
<li><a class="reference internal" href="#module-distutils.command.check">9.46. <code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils.command.check</span></code> — 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"><span class="section-number">8. </span>Command Reference</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../install/index.html"
                        title="next chapter">Installing Python Modules (Legacy version)</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/distutils/apiref.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <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 (Legacy version)"
             >next</a> |</li>
        <li class="right" >
          <a href="commandref.html" title="8. Command Reference"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.10 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Distributing Python Modules (Legacy version)</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" 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>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2021, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Feb 26, 2021.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.3.1.
    </div>

  </body>
</html>