annotate site_scons/site_tools/cpython/doc/manual.html @ 11:4706e0194af3

Various improvements to the build process including support for self-contained builds. * Note that despite all of these changes PARPG still does not run because asset paths are not standardized, * Modified the SCons script so that by default running `scons` with no arguments creates a self-contained "build" under a build subdirectory to make in-source testing easier. To install PARPG, use `scons install` instead. * Got rid of the binary launcher and replaced it with a shell script for unix and a batch script for Windows (batch script is untested). The binary turned out to be too much trouble to maintain. * Modified the parpg.settings module and parpg.main entry script so that PARPG searches through several default search paths for configuration file(s). PARPG thus no longer crashes if it can't find a configuration file in any particular search path, but will crash it if can't find any configuration files. * Paths supplied to parpg.main are now appended as search paths for the configuration file(s). * Changed the default configuration file name to "parpg.cfg" to simplify searches. * Created the site_scons directory tree where SCons extensions and tools should be placed. * Created a new SCons builder, CopyRecurse, which can copy only certain files and folders from a directory tree using filters (files and folders that start with a leading dot "." e.g. ".svn" are ignored by default). * Added the CPython SCons tool (stands for Compile-Python - I didn't name it!), which provides the InstallPython builder for pre-compiling python sources before they are installed. However, it is currently broken and only installs the python sources.
author M. George Hansen <technopolitica@gmail.com>
date Tue, 31 May 2011 02:46:20 -0700
parents
children
rev   line source
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 <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
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2 <a href="http://www.scons.org/wiki/GSoC2008/MatiGruca" target="_top">Mati Gruca's Google Summer of Code 2008 project</a>
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 (<a href="http://scons.tigris.org/source/browse/scons/branches/py-builder/" target="_top">last SVN branch</a>).
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 </p><p>The &#8220;<span class="quote"><code class="literal">InstallPython</code></span>&#8221; method creates <code class="literal">.pyc</code> or <code class="literal">.pyo</code> files for <code class="literal">.py</code> source files
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 and adds them to the list of targets along with the source files.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 They are later copied to the destination (target) directory.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7 </p><p>The &#8220;<span class="quote"><code class="literal">InstallPython</code></span>&#8221; Builder takes a target (destination) directory as its first
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 argument and a list of source files/directories as a second argument.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 It returns the list of target files to copy to the
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 target directory.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 </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 &#8220;<span class="quote"><code class="literal">SConstruct</code></span>&#8221; file:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12 </p><pre class="screen">env = Environment()
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 hello = File('hello.py')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 env.InstallPython('/usr/local/bin/', hello)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
15 env.Alias('install', '/usr/local/bin/')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
16 </pre><p>&#8220;<span class="quote"><code class="literal">SCons</code></span>&#8221; invoked with the &#8220;<span class="quote"><code class="literal">-Q install</code></span>&#8221; parameter will compile the &#8220;<span class="quote"><code class="literal">hello.py</code></span>&#8221; file into
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17 &#8220;<span class="quote"><code class="literal">hello.pyc</code></span>&#8221;, and copy both files into &#8220;<span class="quote"><code class="literal">/usr/local/bin/</code></span>&#8221; directory.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18 </p><p>Sample output:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
19 </p><pre class="screen">$ scons -Q install
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
20 Install file: "hello.py" as "/usr/local/bin/hello.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 Install file: "hello.pyc" as "/usr/local/bin/hello.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22 </pre><p>&#8220;<span class="quote"><code class="literal">InstallPython</code></span>&#8221; can also compile Python source files into optimized
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
23 binary files (&#8220;<span class="quote"><code class="literal">.pyo</code></span>&#8221; suffix) instead of ordinary binaries (&#8220;<span class="quote"><code class="literal">.pyc</code></span>&#8221; files). To
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24 achieve this, change the call to &#8220;<span class="quote"><code class="literal">Environment()</code></span>&#8221; and set the &#8220;<span class="quote"><code class="literal">CPYTHON_PYC</code></span>&#8221;
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
25 variable to '<code class="literal">0</code>' (zero):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
26 </p><pre class="screen">env = Environment(CPYTHON_PYC=0)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
27 hello = File('hello.py')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28 env.InstallPython('/usr/local/bin/', hello)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 env.Alias('install', '/usr/local/bin/')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30 </pre><p>Sample output:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 </p><pre class="screen">$ scons -Q install
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32 Install file: "hello.py" as "/usr/local/bin/hello.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 Install file: "hello.pyo" as "/usr/local/bin/hello.pyo"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 </pre><p>The &#8220;<span class="quote"><code class="literal">InstallPython</code></span>&#8221; method accepts both, files and directories, as its source arguments:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 </p><pre class="screen">env = Environment()
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36 pyfiles = Dir('pyfiles/')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37 env.InstallPython('/usr/local/bin/', pyfiles)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 env.Alias('install', '/usr/local/bin')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39 </pre><p>Running &#8220;<span class="quote"><code class="literal">scons -Q install</code></span>&#8221; will copy all the &#8220;<span class="quote"><code class="literal">.py</code></span>&#8221; files from &#8220;<span class="quote"><code class="literal">pyfiles</code></span>&#8221; directory
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 into &#8220;<span class="quote"><code class="literal">/usr/local/bin/pyfiles</code></span>&#8221; directory along with corresponding &#8220;<span class="quote"><code class="literal">.pyc</code></span>&#8221; files.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 </p><p>Sample output:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 </p><pre class="screen">$ scons -Q install
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 </pre><p>Mixing files and directories is also possible:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48 </p><pre class="screen">env = Environment()
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
49 hello = File('hello.py')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 pyfiles = Dir('pyfiles/')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 env.InstallPython('/usr/local/bin/', [hello, pyfiles])
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 env.Alias('install', '/usr/local/bin')
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 </pre><p>Sample output:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 </p><pre class="screen">$ scons -Q install
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55 Install file: "hello.py" as "/usr/local/bin/hello.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56 Install file: "hello.pyc" as "/usr/local/bin/hello.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc"
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 </pre></div></div></body></html>