Your IP : 216.73.216.48


Current Path : /usr/doc/sip-4.18/html/
Upload File :
Current File : //usr/doc/sip-4.18/html/installation.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Installation &mdash; SIP 4.18 Reference Guide</title>
    
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '4.18',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/logo_tn.ico"/>
    <link rel="top" title="SIP 4.18 Reference Guide" href="index.html" />
    <link rel="next" title="Using SIP" href="using.html" />
    <link rel="prev" title="Potential Incompatibilities with Earlier Versions" href="incompatibilities.html" /> 
  </head>
  <body role="document">
    <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="using.html" title="Using SIP"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="incompatibilities.html" title="Potential Incompatibilities with Earlier Versions"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">SIP 4.18 Reference Guide</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<div class="section" id="downloading">
<h2>Downloading<a class="headerlink" href="#downloading" title="Permalink to this headline">¶</a></h2>
<p>You can get the latest release of the SIP source code from
<a class="reference external" href="http://www.riverbankcomputing.com/software/sip/download">http://www.riverbankcomputing.com/software/sip/download</a>.</p>
<p>SIP is also included with all of the major Linux distributions.  However, it
may be a version or two out of date.</p>
</div>
<div class="section" id="configuring">
<h2>Configuring<a class="headerlink" href="#configuring" title="Permalink to this headline">¶</a></h2>
<p>After unpacking the source package (either a <code class="docutils literal"><span class="pre">.tar.gz</span></code> or a <code class="docutils literal"><span class="pre">.zip</span></code> file
depending on your platform) you should then check for any <code class="docutils literal"><span class="pre">README</span></code> files
that relate to your platform.</p>
<p>Next you need to configure SIP by executing the <strong class="program">configure.py</strong> script.
For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">configure</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>This assumes that the Python interpreter is on your path.  Something like the
following may be appropriate on Windows:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">c</span><span class="p">:</span>\<span class="n">python35</span>\<span class="n">python</span> <span class="n">configure</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>If you have multiple versions of Python installed then make sure you use the
interpreter for which you wish SIP to generate bindings for.</p>
<p>The full set of command line options is:</p>
<dl class="cmdoption">
<dt id="cmdoption-configure.py--version">
<code class="descname">--version</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--version" title="Permalink to this definition">¶</a></dt>
<dd><p>Display the SIP version number.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-h">
<span id="cmdoption-configure.py--help"></span><code class="descname">-h</code><code class="descclassname"></code><code class="descclassname">, </code><code class="descname">--help</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py-h" title="Permalink to this definition">¶</a></dt>
<dd><p>Display a help message.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--arch">
<code class="descname">--arch</code><code class="descclassname"> &lt;ARCH&gt;</code><a class="headerlink" href="#cmdoption-configure.py--arch" title="Permalink to this definition">¶</a></dt>
<dd><p>Binaries for the MacOS/X architecture <code class="docutils literal"><span class="pre">&lt;ARCH&gt;</span></code> will be built.  This
option should be given once for each architecture to be built.  Specifying
more than one architecture will cause a universal binary to be created.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-b">
<span id="cmdoption-configure.py--bindir"></span><code class="descname">-b</code><code class="descclassname"> &lt;DIR&gt;</code><code class="descclassname">, </code><code class="descname">--bindir</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py-b" title="Permalink to this definition">¶</a></dt>
<dd><p>The SIP code generator will be installed in the directory <code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--configuration">
<code class="descname">--configuration</code><code class="descclassname"> &lt;FILE&gt;</code><a class="headerlink" href="#cmdoption-configure.py--configuration" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.16.</span></p>
</div>
<p><code class="docutils literal"><span class="pre">&lt;FILE&gt;</span></code> contains the configuration of the SIP build to be used instead
of dynamically introspecting the system and is typically used when
cross-compiling.  See <a class="reference internal" href="#ref-configuration-files"><span class="std std-ref">Configuring with Configuration Files</span></a>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-d">
<span id="cmdoption-configure.py--destdir"></span><code class="descname">-d</code><code class="descclassname"> &lt;DIR&gt;</code><code class="descclassname">, </code><code class="descname">--destdir</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py-d" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module will be installed in the directory <code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--deployment-target">
<code class="descname">--deployment-target</code><code class="descclassname"> &lt;VERSION&gt;</code><a class="headerlink" href="#cmdoption-configure.py--deployment-target" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.12.1.</span></p>
</div>
<p>Each generated Makefile will set the <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal"><span class="pre">MACOSX_DEPLOYMENT_TARGET</span></code>
environment variable to <code class="docutils literal"><span class="pre">&lt;VERSION&gt;</span></code>.  In order to work around bugs in
some versions of Python, this should be used instead of setting the
environment variable in the shell.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-e">
<span id="cmdoption-configure.py--incdir"></span><code class="descname">-e</code><code class="descclassname"> &lt;DIR&gt;</code><code class="descclassname">, </code><code class="descname">--incdir</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py-e" title="Permalink to this definition">¶</a></dt>
<dd><p>The SIP header file will be installed in the directory <code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-k">
<span id="cmdoption-configure.py--static"></span><code class="descname">-k</code><code class="descclassname"></code><code class="descclassname">, </code><code class="descname">--static</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py-k" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module will be built as a static library.  This is useful
when building the <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module as a Python builtin.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-n">
<span id="cmdoption-configure.py--universal"></span><code class="descname">-n</code><code class="descclassname"></code><code class="descclassname">, </code><code class="descname">--universal</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py-n" title="Permalink to this definition">¶</a></dt>
<dd><p>The SIP code generator and module will be built as universal binaries
under MacOS/X.  If the <a class="reference internal" href="#cmdoption-configure.py--arch"><code class="xref std std-option docutils literal"><span class="pre">--arch</span></code></a> option has
not been specified then the universal binary will include the <code class="docutils literal"><span class="pre">i386</span></code> and
<code class="docutils literal"><span class="pre">ppc</span></code> architectures.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--no-pyi">
<code class="descname">--no-pyi</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--no-pyi" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.18.</span></p>
</div>
<p>This disables the installation of the <code class="docutils literal"><span class="pre">sip.pyi</span></code> type hints stub file.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--no-tools">
<code class="descname">--no-tools</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--no-tools" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.16.</span></p>
</div>
<p>The SIP code generator and <a class="reference internal" href="build_system.html#module-sipconfig" title="sipconfig"><code class="xref py py-mod docutils literal"><span class="pre">sipconfig</span></code></a> module will not be installed.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-p">
<span id="cmdoption-configure.py--platform"></span><code class="descname">-p</code><code class="descclassname"> &lt;PLATFORM&gt;</code><code class="descclassname">, </code><code class="descname">--platform</code><code class="descclassname"> &lt;PLATFORM&gt;</code><a class="headerlink" href="#cmdoption-configure.py-p" title="Permalink to this definition">¶</a></dt>
<dd><p>Explicitly specify the platform/compiler to be used by the build system,
otherwise a platform specific default will be used.  The
<a class="reference internal" href="#cmdoption-configure.py--show-platforms"><code class="xref std std-option docutils literal"><span class="pre">--show-platforms</span></code></a> option will
display all the supported platform/compilers.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--pyi-dir">
<code class="descname">--pyi-dir</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py--pyi-dir" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.18.</span></p>
</div>
<p><code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code> is the name of the directory where the <code class="docutils literal"><span class="pre">sip.pyi</span></code> type hints
stub file is installed.  By default this is the directory where the
<a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module is installed.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-s">
<span id="cmdoption-configure.py--sdk"></span><code class="descname">-s</code><code class="descclassname"> &lt;SDK&gt;</code><code class="descclassname">, </code><code class="descname">--sdk</code><code class="descclassname"> &lt;SDK&gt;</code><a class="headerlink" href="#cmdoption-configure.py-s" title="Permalink to this definition">¶</a></dt>
<dd><p>If the <a class="reference internal" href="#cmdoption-configure.py-n"><code class="xref std std-option docutils literal"><span class="pre">--universal</span></code></a> option was given then this
specifies the name of the SDK directory.  If a path is not given then it is
assumed to be a sub-directory of
<code class="docutils literal"><span class="pre">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs</span></code>
or <code class="docutils literal"><span class="pre">/Developer/SDKs</span></code>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-u">
<span id="cmdoption-configure.py--debug"></span><code class="descname">-u</code><code class="descclassname"></code><code class="descclassname">, </code><code class="descname">--debug</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py-u" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module will be built with debugging symbols.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py-v">
<span id="cmdoption-configure.py--sipdir"></span><code class="descname">-v</code><code class="descclassname"> &lt;DIR&gt;</code><code class="descclassname">, </code><code class="descname">--sipdir</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py-v" title="Permalink to this definition">¶</a></dt>
<dd><p>By default <code class="docutils literal"><span class="pre">.sip</span></code> files will be installed in the directory <code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--show-platforms">
<code class="descname">--show-platforms</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--show-platforms" title="Permalink to this definition">¶</a></dt>
<dd><p>The list of all supported platform/compilers will be displayed.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--show-build-macros">
<code class="descname">--show-build-macros</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--show-build-macros" title="Permalink to this definition">¶</a></dt>
<dd><p>The list of all available build macros will be displayed.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--sip-module">
<code class="descname">--sip-module</code><code class="descclassname"> &lt;NAME&gt;</code><a class="headerlink" href="#cmdoption-configure.py--sip-module" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module will be created with the name <code class="docutils literal"><span class="pre">&lt;NAME&gt;</span></code> rather than
the default <code class="docutils literal"><span class="pre">sip</span></code>.  <code class="docutils literal"><span class="pre">&lt;NAME&gt;</span></code> may be of the form
<code class="docutils literal"><span class="pre">package.sub-package.module</span></code>.  See <a class="reference internal" href="using.html#ref-private-sip"><span class="std std-ref">Building a Private Copy of the sip Module</span></a> for how to use
this to create a private copy of the <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--sysroot">
<code class="descname">--sysroot</code><code class="descclassname"> &lt;DIR&gt;</code><a class="headerlink" href="#cmdoption-configure.py--sysroot" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.16.</span></p>
</div>
<p><code class="docutils literal"><span class="pre">&lt;DIR&gt;</span></code> is the name of an optional directory that replaces <code class="docutils literal"><span class="pre">sys.prefix</span></code>
in the names of other directories (specifically those specifying where the
various SIP components will be installed and where the Python include
directories can be found).  It is typically used when cross-compiling or
when building a static version of SIP.  See <a class="reference internal" href="#ref-configuration-files"><span class="std std-ref">Configuring with Configuration Files</span></a>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--target-py-version">
<code class="descname">--target-py-version</code><code class="descclassname"> &lt;VERSION&gt;</code><a class="headerlink" href="#cmdoption-configure.py--target-py-version" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.16.</span></p>
</div>
<p><code class="docutils literal"><span class="pre">&lt;VERSION&gt;</span></code> is the major and minor version (e.g. <code class="docutils literal"><span class="pre">3.4</span></code>) of the version
of Python being targetted.  By default the version of Python being used to
run the <strong class="program">configure.py</strong> script is used.  It is typically used when
cross-compiling.  See <a class="reference internal" href="#ref-configuration-files"><span class="std std-ref">Configuring with Configuration Files</span></a>.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure.py--use-qmake">
<code class="descname">--use-qmake</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure.py--use-qmake" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 4.16.</span></p>
</div>
<p>Normally the <strong class="program">configure.py</strong> script uses SIP&#8217;s own build system to
create the Makefiles for the code generator and module.  This option causes
project files (<code class="docutils literal"><span class="pre">.pro</span></code> files) used by Qt&#8217;s <strong class="program">qmake</strong> program to be
generated instead.  <strong class="program">qmake</strong> should then be run to generate the
Makefiles.  This is particularly useful when cross-compiling.</p>
</dd></dl>

<p>The <strong class="program">configure.py</strong> script takes many other options that allows the
build system to be finely tuned.  These are of the form <code class="docutils literal"><span class="pre">name=value</span></code> or
<code class="docutils literal"><span class="pre">name+=value</span></code>.  The <a class="reference internal" href="#cmdoption-configure.py--show-build-macros"><code class="xref std std-option docutils literal"><span class="pre">--show-build-macros</span></code></a> option will display each supported <code class="docutils literal"><span class="pre">name</span></code>, although not
all are applicable to all platforms.</p>
<p>The <code class="docutils literal"><span class="pre">name=value</span></code> form means that <code class="docutils literal"><span class="pre">value</span></code> will replace the existing value of
<code class="docutils literal"><span class="pre">name</span></code>.</p>
<p>The <code class="docutils literal"><span class="pre">name+=value</span></code> form means that <code class="docutils literal"><span class="pre">value</span></code> will be appended to the existing
value of <code class="docutils literal"><span class="pre">name</span></code>.</p>
<p>For example, the following will disable support for C++ exceptions (and so
reduce the size of module binaries) when used with GCC:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">configure</span><span class="o">.</span><span class="n">py</span> <span class="n">CXXFLAGS</span><span class="o">+=-</span><span class="n">fno</span><span class="o">-</span><span class="n">exceptions</span>
</pre></div>
</div>
<p>A pure Python module called <code class="docutils literal"><span class="pre">sipconfig.py</span></code> is generated by
<strong class="program">configure.py</strong>.  This defines each <code class="docutils literal"><span class="pre">name</span></code> and its corresponding
<code class="docutils literal"><span class="pre">value</span></code>.  Looking at it will give you a good idea of how the build system
uses the different options.  It is covered in detail in
<a class="reference internal" href="build_system.html#ref-build-system"><span class="std std-ref">The Build System</span></a>.</p>
<div class="section" id="configuring-for-mingw">
<h3>Configuring for MinGW<a class="headerlink" href="#configuring-for-mingw" title="Permalink to this headline">¶</a></h3>
<p>SIP, and the modules it generates, can be built with MinGW, the Windows port of
GCC.  You must use the <a class="reference internal" href="#cmdoption-configure.py-p"><code class="xref std std-option docutils literal"><span class="pre">--platform</span></code></a> command line
option to specify the correct platform.  For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">c</span><span class="p">:</span>\<span class="n">python35</span>\<span class="n">python</span> <span class="n">configure</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">platform</span> <span class="n">win32</span><span class="o">-</span><span class="n">g</span><span class="o">++</span>
</pre></div>
</div>
</div>
<div class="section" id="configuring-for-the-borland-c-compiler">
<h3>Configuring for the Borland C++ Compiler<a class="headerlink" href="#configuring-for-the-borland-c-compiler" title="Permalink to this headline">¶</a></h3>
<p>SIP, and the modules it generates, can be built with the free Borland C++
compiler.  You must use the <a class="reference internal" href="#cmdoption-configure.py-p"><code class="xref std std-option docutils literal"><span class="pre">--platform</span></code></a> command line
option to specify the correct platform.  For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">c</span><span class="p">:</span>\<span class="n">python35</span>\<span class="n">python</span> <span class="n">configure</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">platform</span> <span class="n">win32</span><span class="o">-</span><span class="n">borland</span>
</pre></div>
</div>
<p>You must also make sure you have a Borland-compatible version of the Python
library.  If you are using the standard Python distribution (built using the
Microsoft compiler) then you must convert the format of the Python library.
For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">coff2omf</span> <span class="n">python35</span><span class="o">.</span><span class="n">lib</span> <span class="n">python35_bcpp</span><span class="o">.</span><span class="n">lib</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="building">
<h2>Building<a class="headerlink" href="#building" title="Permalink to this headline">¶</a></h2>
<p>The next step is to build SIP by running your platform&#8217;s <code class="docutils literal"><span class="pre">make</span></code> command.  For
example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">make</span>
</pre></div>
</div>
<p>The final step is to install SIP by running the following command:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
<p>(Depending on your system you may require root or administrator privileges.)</p>
<p>This will install the various SIP components.</p>
</div>
<div class="section" id="configuring-with-configuration-files">
<span id="ref-configuration-files"></span><h2>Configuring with Configuration Files<a class="headerlink" href="#configuring-with-configuration-files" title="Permalink to this headline">¶</a></h2>
<p>The <strong class="program">configure.py</strong> script normally introspects the Python installation
of the interpreter running it in order to determine the names of the various
files and directories it needs.  This is fine for a native build of SIP but
isn&#8217;t appropriate when cross-compiling.  In this case it is possible to supply
a configuration file, specified using the
<a class="reference internal" href="#cmdoption-configure.py--configuration"><code class="xref std std-option docutils literal"><span class="pre">--configuration</span></code></a> option, which contains
definitions of all the required values.</p>
<p>The format of a configuration file is as follows:</p>
<ul class="simple">
<li>a configuration item is a single line containing a name/value pair separated
by <code class="docutils literal"><span class="pre">=</span></code></li>
<li>a value may include another value by embedding the name of that value
surrounded by <code class="docutils literal"><span class="pre">%(</span></code> and <code class="docutils literal"><span class="pre">)</span></code></li>
<li>comments begin with <code class="docutils literal"><span class="pre">#</span></code> and continue to the end of the line</li>
<li>blank lines are ignored.</li>
</ul>
<p><strong class="program">configure.py</strong> provides the following preset values for a
configuration:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">py_major</span></code></dt>
<dd>is the major version number of the target Python installation.</dd>
<dt><code class="docutils literal"><span class="pre">py_minor</span></code></dt>
<dd>is the minor version number of the target Python installation.</dd>
<dt><code class="docutils literal"><span class="pre">sysroot</span></code></dt>
<dd>is the name of the system root directory.  This is specified with the
<a class="reference internal" href="#cmdoption-configure.py--sysroot"><code class="xref std std-option docutils literal"><span class="pre">--sysroot</span></code></a> option.</dd>
</dl>
<p>The following is an example configuration file:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># The target Python installation.</span>
<span class="n">py_platform</span> <span class="o">=</span> <span class="n">linux</span>
<span class="n">py_inc_dir</span> <span class="o">=</span> <span class="o">%</span><span class="p">(</span><span class="n">sysroot</span><span class="p">)</span><span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">python</span><span class="o">%</span><span class="p">(</span><span class="n">py_major</span><span class="p">)</span><span class="o">%</span><span class="p">(</span><span class="n">py_minor</span><span class="p">)</span>

<span class="c1"># Where SIP will be installed.</span>
<span class="n">sip_bin_dir</span> <span class="o">=</span> <span class="o">%</span><span class="p">(</span><span class="n">sysroot</span><span class="p">)</span><span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="nb">bin</span>
<span class="n">sip_module_dir</span> <span class="o">=</span> <span class="o">%</span><span class="p">(</span><span class="n">sysroot</span><span class="p">)</span><span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">python</span><span class="o">%</span><span class="p">(</span><span class="n">py_major</span><span class="p">)</span><span class="o">/</span><span class="n">dist</span><span class="o">-</span><span class="n">packages</span>
</pre></div>
</div>
<p>The following values can be specified in the configuration file:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">py_platform</span></code></dt>
<dd>is the target Python platform.</dd>
<dt><code class="docutils literal"><span class="pre">py_inc_dir</span></code></dt>
<dd>is the target Python include directory containing the <code class="docutils literal"><span class="pre">Python.h</span></code> file.</dd>
<dt><code class="docutils literal"><span class="pre">py_conf_inc_dir</span></code></dt>
<dd>is the target Python include directory containing the <code class="docutils literal"><span class="pre">pyconfig.h</span></code> file.
If this isn&#8217;t specified then it defaults to the value of <code class="docutils literal"><span class="pre">py_inc_dir</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">py_pylib_dir</span></code></dt>
<dd>is the target Python library directory.</dd>
<dt><code class="docutils literal"><span class="pre">sip_bin_dir</span></code></dt>
<dd>is the name of the target directory where the SIP code generator will be
installed.  It can be overridden by the
<a class="reference internal" href="#cmdoption-configure.py-b"><code class="xref std std-option docutils literal"><span class="pre">--bindir</span></code></a> option.</dd>
<dt><code class="docutils literal"><span class="pre">sip_inc_dir</span></code></dt>
<dd>is the name of the target directory where the <code class="docutils literal"><span class="pre">sip.h</span></code> file will be
installed.  If this isn&#8217;t specified then it defaults to the value of
<code class="docutils literal"><span class="pre">py_inc_dir</span></code>.  It can be overridden by the
<a class="reference internal" href="#cmdoption-configure.py-e"><code class="xref std std-option docutils literal"><span class="pre">--incdir</span></code></a> option.</dd>
<dt><code class="docutils literal"><span class="pre">sip_module_dir</span></code></dt>
<dd>is the target directory where the <a class="reference internal" href="python_api.html#module-sip" title="sip"><code class="xref py py-mod docutils literal"><span class="pre">sip</span></code></a> module will be installed.  It
can be overridden by the <a class="reference internal" href="#cmdoption-configure.py-d"><code class="xref std std-option docutils literal"><span class="pre">--destdir</span></code></a> option.</dd>
<dt><code class="docutils literal"><span class="pre">sip_sip_dir</span></code></dt>
<dd>is the name of the target directory where generated <code class="docutils literal"><span class="pre">.sip</span></code> files will be
installed by default.  It is only used when creating the <a class="reference internal" href="build_system.html#module-sipconfig" title="sipconfig"><code class="xref py py-mod docutils literal"><span class="pre">sipconfig</span></code></a>
module.  It can be overridden by the <a class="reference internal" href="#cmdoption-configure.py-v"><code class="xref std std-option docutils literal"><span class="pre">--sipdir</span></code></a>
option.</dd>
</dl>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Installation</a><ul>
<li><a class="reference internal" href="#downloading">Downloading</a></li>
<li><a class="reference internal" href="#configuring">Configuring</a><ul>
<li><a class="reference internal" href="#configuring-for-mingw">Configuring for MinGW</a></li>
<li><a class="reference internal" href="#configuring-for-the-borland-c-compiler">Configuring for the Borland C++ Compiler</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building">Building</a></li>
<li><a class="reference internal" href="#configuring-with-configuration-files">Configuring with Configuration Files</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="incompatibilities.html"
                        title="previous chapter">Potential Incompatibilities with Earlier Versions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="using.html"
                        title="next chapter">Using SIP</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </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="using.html" title="Using SIP"
             >next</a> |</li>
        <li class="right" >
          <a href="incompatibilities.html" title="Potential Incompatibilities with Earlier Versions"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">SIP 4.18 Reference Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &copy; Copyright 2015 Riverbank Computing Limited.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.
    </div>
  </body>
</html>