Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/python/pyste/doc/running_pyste.html @ 13

Last change on this file since 13 was 12, checked in by landauf, 17 years ago

added boost

File size: 10.0 KB
Line 
1<html>
2<head>
3<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
4<title>Running Pyste</title>
5<link rel="stylesheet" href="theme/style.css" type="text/css">
6<link rel="prev" href="introduction.html">
7<link rel="next" href="the_interface_files.html">
8</head>
9<body>
10<table width="100%" height="48" border="0" cellspacing="2">
11  <tr>
12    <td><img src="../../../../boost.png">
13    </td>
14    <td width="85%">
15      <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Running Pyste</b></font>
16    </td>
17  </tr>
18</table>
19<br>
20<table border="0">
21  <tr>
22    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
23    <td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" border="0"></a></td>
24    <td width="20"><a href="the_interface_files.html"><img src="theme/r_arr.gif" border="0"></a></td>
25   </tr>
26</table>
27<p>
28To run Pyste, you will need:</p>
29<ul><li>Python 2.2, available at <a href="http://www.python.org">
30python's website</a>.</li><li>The great <a href="http://effbot.org">
31elementtree</a> library, from Fredrik Lundh.</li><li>The excellent <a href="http://www.gccxml.org">
32GCCXML</a>, from Brad King.</li></ul><p>
33Installation for the tools is available in their respective webpages.</p>
34<table width="80%" border="0" align="center">
35  <tr>
36    <td class="note_box">
37
38<img src="theme/note.gif"></img> <a href="http://www.gccxml.org">
39GCCXML</a> must be accessible in the PATH environment variable, so
40that Pyste can call it. How to do this varies from platform to platform.
41    </td>
42  </tr>
43</table>
44<a name="ok__now_what_"></a><h2>Ok, now what?</h2><p>
45Well, now let's fire it up:</p>
46<code><pre>
47
48&gt;python pyste.py
49
50Pyste version 0.9.26
51
52Usage:
53    pyste [options] interface-files
54
55where options are:
56    --module=&lt;name&gt;         The name of the module that will be generated;
57                            defaults to the first interface filename, without
58                            the extension.
59    -I &lt;path&gt;               Add an include path
60    -D &lt;symbol&gt;             Define symbol
61    --multiple              Create various cpps, instead of only one
62                            (useful during development)
63    --out=&lt;name&gt;            Specify output filename (default: &lt;module&gt;.cpp)
64                            in --multiple mode, this will be a directory
65    --no-using              Do not declare &quot;using namespace boost&quot;;
66                            use explicit declarations instead
67    --pyste-ns=&lt;name&gt;       Set the namespace where new types will be declared;
68                            default is the empty namespace
69    --debug                 Writes the xml for each file parsed in the current
70                            directory
71    --cache-dir=&lt;dir&gt;       Directory for cache files (speeds up future runs)
72    --only-create-cache     Recreates all caches (doesn't generate code).
73    --generate-main         Generates the _main.cpp file (in multiple mode)
74    --file-list             A file with one pyste file per line. Use as a
75                            substitute for passing the files in the command
76                            line.
77    -h, --help              Print this help and exit
78    -v, --version           Print version information
79 
80                       
81</pre></code><p>
82Options explained:</p>
83<p>
84The <tt>-I</tt> and <tt>-D</tt> are preprocessor flags, which are needed by <a href="http://www.gccxml.org">
85GCCXML</a> to parse
86the header files correctly and by Pyste to find the header files declared in the
87interface files.</p>
88<p>
89<tt>--out</tt> names the output file (default: <tt>&lt;module&gt;.cpp</tt>), or in multiple mode,
90names a output directory for the files (default: <tt>&lt;module&gt;</tt>).</p>
91<p>
92<tt>--no-using</tt> tells Pyste to don't declare &quot;<tt>using namespace boost;</tt>&quot; in the
93generated cpp, using the namespace boost::python explicitly in all declarations.
94Use only if you're having a name conflict in one of the files.</p>
95<p>
96Use <tt>--pyste-ns</tt> to change the namespace where new types are declared (for
97instance, the virtual wrappers). Use only if you are having any problems. By
98default, Pyste uses the empty namespace.</p>
99<p>
100<tt>--debug</tt> will write in the current directory a xml file as outputted by <a href="http://www.gccxml.org">
101GCCXML</a>
102for each header parsed. Useful for bug reports.</p>
103<p>
104<tt>--file-list</tt> names a file where each line points to a Pyste file. Use this instead
105to pass the pyste files if you have a lot of them and your shell has some command line
106size limit.</p>
107<p>
108The other options are explained below, in <a href="#multiple_mode">
109<b>Multiple Mode</b></a> and
110<a href="#cache">
111<b>Cache</b></a>.</p>
112<p>
113<tt>-h, --help, -v, --version</tt> are self-explaining, I believe. ;)</p>
114<p>
115So, the usage is simple enough:</p>
116<code><pre>&gt;python pyste.py --module=mymodule file.pyste file2.pyste ...</pre></code><p>
117will generate a file <tt>mymodule.cpp</tt> in the same dir where the command was
118executed. Now you can compile the file using the same instructions of the
119<a href="../../doc/tutorial/doc/html/python/hello.html">
120tutorial</a>. </p>
121<a name="wait____how_do_i_set_those_i_and_d_flags_"></a><h2>Wait... how do I set those I and D flags?</h2><p>
122Don't worry: normally <a href="http://www.gccxml.org">
123GCCXML</a> is already configured correctly for your plataform,
124so the search path to the standard libraries and the standard defines should
125already be set. You only have to set the paths to other libraries that your code
126needs, like Boost, for example.</p>
127<p>
128Plus, Pyste automatically uses the contents of the environment variable
129<tt>INCLUDE</tt> if it exists. Visual C++ users should run the <tt>Vcvars32.bat</tt> file,
130which for Visual C++ 6 is normally located at:</p>
131<code><pre>
132    <span class=identifier>C</span><span class=special>:\</span><span class=identifier>Program </span><span class=identifier>Files</span><span class=special>\</span><span class=identifier>Microsoft </span><span class=identifier>Visual </span><span class=identifier>Studio</span><span class=special>\</span><span class=identifier>VC98</span><span class=special>\</span><span class=identifier>bin</span><span class=special>\</span><span class=identifier>Vcvars32</span><span class=special>.</span><span class=identifier>bat
133</span></pre></code>
134<p>
135with that, you should have little trouble setting up the flags.</p>
136<table width="80%" border="0" align="center">
137  <tr>
138    <td class="note_box">
139<img src="theme/note.gif"></img><b>A note about Psyco</b><br><br>
140Although you don't have to install <a href="http://psyco.sourceforge.net/">
141Psyco</a> to
142use Pyste, if you do, Pyste will make use of it to speed up the wrapper
143generation. Speed ups of 30% can be achieved, so it's highly recommended.
144    </td>
145  </tr>
146</table>
147<a name="multiple_mode"></a><h2>Multiple Mode</h2><p>
148The multiple mode is useful in large projects, where the presence of multiple
149classes in a single file makes the compilation unpractical (excessive memory
150usage, mostly). </p>
151<p>
152The solution is make Pyste generate multiple files, more specifically one cpp
153file for each Pyste file. This files will contain a function named after the
154file, for instance Export_MyPysteFile, which will contain all the code to export
155the classes, enums, etc. You can pass as much files as you want this way:</p>
156<code><pre>&gt;python pyste.py --module=mymodule file1.pyste file2.pyste</pre></code><p>
157This will create the files <tt>mymodule/file1.cpp</tt> and <tt>mymodule/file2.cpp</tt>. You
158can then later do:</p>
159<code><pre>&gt;python pyste.py --module=mymodule file3.pyste</pre></code><p>
160and <tt>mymodule/file3.cpp</tt> will be generated.</p>
161<p>
162But compiling and linking this files won't be sufficient to generate your
163extension. You have to also generate a file named <tt>main.cpp</tt>; call pyste with
164<b>all</b> the Pyste files of your extension, and use the <tt>--generate-main</tt> option:</p>
165<code><pre>&gt;python pyste.py --module=mymodule --generate-main file1.pyste file2.pyste file3.pyste</pre></code><p>
166Now compile and link all this files together and your extension is ready for
167use.</p>
168<a name="cache"></a><h2>Cache</h2><p>
169Pyste now supports a form of cache, which is a way to speed up the code
170generation. Most of the time that Pyste takes to generate the code comes from
171having to execute <a href="http://www.gccxml.org">
172GCCXML</a> (since being a front-end to GCC, it has to compile the
173header files) and reading back the XML generated. </p>
174<p>
175When you use the <tt>--cache-dir=&lt;dir&gt;</tt> option, Pyste will dump in the specified
176directory the generated XMLs to a file named after the Pyste file, with the
177extension <tt>.pystec</tt>.  The next time you run with this option, Pyste will use
178the cache, instead of calling <a href="http://www.gccxml.org">
179GCCXML</a> again:</p>
180<code><pre>&gt;python pyste.py --module=mymodule --cache-dir=cache file1.pyste</pre></code><p>
181Will generate <tt>file1.cpp</tt> and <tt>cache/file1.pystec</tt>. Next time you execute
182this command, the cache file will be used. Note that Pyste doesn't do any check
183to ensure that the cache is up to date, but you can configure your build system to do that for you.</p>
184<p>
185When you run Pyste with <tt>--only-create-cache</tt>, all the cache files will be
186created again, but no code will be generated.</p>
187<table border="0">
188  <tr>
189    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
190    <td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" border="0"></a></td>
191    <td width="20"><a href="the_interface_files.html"><img src="theme/r_arr.gif" border="0"></a></td>
192   </tr>
193</table>
194<br>
195<hr size="1"><p class="copyright">Copyright &copy; 2003 Bruno da Silva de Oliveira<br>Copyright &copy; 2002-2003 Joel de Guzman<br><br>
196<font size="2">Permission to copy, use, modify, sell and distribute this document
197 is granted provided this copyright notice appears in all copies. This document
198 is provided &quot;as is&quot; without express or implied warranty, and with
199 no claim as to its suitability for any purpose. </font> </p>
200</body>
201</html>
Note: See TracBrowser for help on using the repository browser.