Mercurial > parpg-core
comparison 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 |
comparison
equal
deleted
inserted
replaced
10:5deaf494934a | 11:4706e0194af3 |
---|---|
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 | |
2 <a href="http://www.scons.org/wiki/GSoC2008/MatiGruca" target="_top">Mati Gruca's Google Summer of Code 2008 project</a> | |
3 (<a href="http://scons.tigris.org/source/browse/scons/branches/py-builder/" target="_top">last SVN branch</a>). | |
4 </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 | |
5 and adds them to the list of targets along with the source files. | |
6 They are later copied to the destination (target) directory. | |
7 </p><p>The “<span class="quote"><code class="literal">InstallPython</code></span>” Builder takes a target (destination) directory as its first | |
8 argument and a list of source files/directories as a second argument. | |
9 It returns the list of target files to copy to the | |
10 target directory. | |
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 “<span class="quote"><code class="literal">SConstruct</code></span>” file: | |
12 </p><pre class="screen">env = Environment() | |
13 hello = File('hello.py') | |
14 env.InstallPython('/usr/local/bin/', hello) | |
15 env.Alias('install', '/usr/local/bin/') | |
16 </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 | |
17 “<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. | |
18 </p><p>Sample output: | |
19 </p><pre class="screen">$ scons -Q install | |
20 Install file: "hello.py" as "/usr/local/bin/hello.py" | |
21 Install file: "hello.pyc" as "/usr/local/bin/hello.pyc" | |
22 </pre><p>“<span class="quote"><code class="literal">InstallPython</code></span>” can also compile Python source files into optimized | |
23 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 | |
24 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>” | |
25 variable to '<code class="literal">0</code>' (zero): | |
26 </p><pre class="screen">env = Environment(CPYTHON_PYC=0) | |
27 hello = File('hello.py') | |
28 env.InstallPython('/usr/local/bin/', hello) | |
29 env.Alias('install', '/usr/local/bin/') | |
30 </pre><p>Sample output: | |
31 </p><pre class="screen">$ scons -Q install | |
32 Install file: "hello.py" as "/usr/local/bin/hello.py" | |
33 Install file: "hello.pyo" as "/usr/local/bin/hello.pyo" | |
34 </pre><p>The “<span class="quote"><code class="literal">InstallPython</code></span>” method accepts both, files and directories, as its source arguments: | |
35 </p><pre class="screen">env = Environment() | |
36 pyfiles = Dir('pyfiles/') | |
37 env.InstallPython('/usr/local/bin/', pyfiles) | |
38 env.Alias('install', '/usr/local/bin') | |
39 </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 | |
40 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. | |
41 </p><p>Sample output: | |
42 </p><pre class="screen">$ scons -Q install | |
43 Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py" | |
44 Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc" | |
45 Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py" | |
46 Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc" | |
47 </pre><p>Mixing files and directories is also possible: | |
48 </p><pre class="screen">env = Environment() | |
49 hello = File('hello.py') | |
50 pyfiles = Dir('pyfiles/') | |
51 env.InstallPython('/usr/local/bin/', [hello, pyfiles]) | |
52 env.Alias('install', '/usr/local/bin') | |
53 </pre><p>Sample output: | |
54 </p><pre class="screen">$ scons -Q install | |
55 Install file: "hello.py" as "/usr/local/bin/hello.py" | |
56 Install file: "hello.pyc" as "/usr/local/bin/hello.pyc" | |
57 Install file: "pyfiles/hello.py" as "/usr/local/bin/pyfiles/hello.py" | |
58 Install file: "pyfiles/hello.pyc" as "/usr/local/bin/pyfiles/hello.pyc" | |
59 Install file: "pyfiles/hello2.py" as "/usr/local/bin/pyfiles/hello2.py" | |
60 Install file: "pyfiles/hello2.pyc" as "/usr/local/bin/pyfiles/hello2.pyc" | |
61 </pre></div></div></body></html> |