Mercurial > parpg-core
view site_scons/site_tools/cpython/doc/manual.html @ 17:15107282d9eb
Redefined SYSCONFDIR installation path variable so that it appends APPNAME.
* Although this deviates from GNU standards this relatively minor change makes it easier to write paths that are portable to Windows.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Thu, 09 Jun 2011 21:40:51 -1000 |
parents | 4706e0194af3 |
children |
line wrap: on
line source
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>CPython, a binary builder for Python installs</title><link rel="stylesheet" href="scons.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2476347"></a>CPython, a binary builder for Python installs</h2></div><div><div class="author"><h3 class="author"><span class="surname">Dirk Baechle</span></h3></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#examples">1. Examples</a></span></dt></dl></div><p>This first version of a Python Binary Builder is based on the work of <a href="http://www.scons.org/wiki/GSoC2008/MatiGruca" target="_top">Mati Gruca's Google Summer of Code 2008 project</a> (<a href="http://scons.tigris.org/source/browse/scons/branches/py-builder/" target="_top">last SVN branch</a>). </p><p>The “<span class="quote"><code class="literal">InstallPython</code></span>” method creates <code class="literal">.pyc</code> or <code class="literal">.pyo</code> files for <code class="literal">.py</code> source files and adds them to the list of targets along with the source files. They are later copied to the destination (target) directory. </p><p>The “<span class="quote"><code class="literal">InstallPython</code></span>” Builder takes a target (destination) directory as its first argument and a list of source files/directories as a second argument. It returns the list of target files to copy to the target directory. </p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="examples"></a>1. Examples</h2></div></div></div><p>A simple example of an “<span class="quote"><code class="literal">SConstruct</code></span>” file: </p><pre class="screen">env = Environment() hello = File('hello.py') env.InstallPython('/usr/local/bin/', hello) env.Alias('install', '/usr/local/bin/') </pre><p>“<span class="quote"><code class="literal">SCons</code></span>” invoked with the “<span class="quote"><code class="literal">-Q install</code></span>” parameter will compile the “<span class="quote"><code class="literal">hello.py</code></span>” file into “<span class="quote"><code class="literal">hello.pyc</code></span>”, and copy both files into “<span class="quote"><code class="literal">/usr/local/bin/</code></span>” directory. </p><p>Sample output: </p><pre class="screen">$ scons -Q install Install file: "hello.py" as "/usr/local/bin/hello.py" Install file: "hello.pyc" as "/usr/local/bin/hello.pyc" </pre><p>“<span class="quote"><code class="literal">InstallPython</code></span>” can also compile Python source files into optimized binary files (“<span class="quote"><code class="literal">.pyo</code></span>” suffix) instead of ordinary binaries (“<span class="quote"><code class="literal">.pyc</code></span>” files). To achieve this, change the call to “<span class="quote"><code class="literal">Environment()</code></span>” and set the “<span class="quote"><code class="literal">CPYTHON_PYC</code></span>” variable to '<code class="literal">0</code>' (zero): </p><pre class="screen">env = Environment(CPYTHON_PYC=0) hello = File('hello.py') env.InstallPython('/usr/local/bin/', hello) env.Alias('install', '/usr/local/bin/') </pre><p>Sample output: </p><pre class="screen">$ scons -Q install Install file: "hello.py" as "/usr/local/bin/hello.py" Install file: "hello.pyo" as "/usr/local/bin/hello.pyo" </pre><p>The “<span class="quote"><code class="literal">InstallPython</code></span>” method accepts both, files and directories, as its source arguments: </p><pre class="screen">env = Environment() pyfiles = Dir('pyfiles/') env.InstallPython('/usr/local/bin/', pyfiles) env.Alias('install', '/usr/local/bin') </pre><p>Running “<span class="quote"><code class="literal">scons -Q install</code></span>” will copy all the “<span class="quote"><code class="literal">.py</code></span>” files from “<span class="quote"><code class="literal">pyfiles</code></span>” directory into “<span class="quote"><code class="literal">/usr/local/bin/pyfiles</code></span>” directory along with corresponding “<span class="quote"><code class="literal">.pyc</code></span>” files. </p><p>Sample output: </p><pre class="screen">$ scons -Q install Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py" Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc" Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py" Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc" </pre><p>Mixing files and directories is also possible: </p><pre class="screen">env = Environment() hello = File('hello.py') pyfiles = Dir('pyfiles/') env.InstallPython('/usr/local/bin/', [hello, pyfiles]) env.Alias('install', '/usr/local/bin') </pre><p>Sample output: </p><pre class="screen">$ scons -Q install Install file: "hello.py" as "/usr/local/bin/hello.py" Install file: "hello.pyc" as "/usr/local/bin/hello.pyc" Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py" Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc" Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py" Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc" </pre></div></div></body></html>