1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3
<!-- $Id: 3-install.html,v 2.44.2.12 2009/03/26 21:27:26 irmen Exp $ -->
5
<title>PYRO - Installation</title>
6
<link rel="stylesheet" type="text/css" href="pyromanual_print.css" media="print">
7
<link rel="stylesheet" type="text/css" href="pyromanual.css" media="screen">
14
<td align="left"><a href="2-concepts.html"><previous</a> | <a href="PyroManual.html">contents</a> | <a href=
15
"4-usage.html">next></a></td>
17
<td align="right">Pyro Manual</td>
22
<h2>3. Installation and Configuration</h2>
23
Please read this entire chapter before trying to install Pyro.
24
Not that it's complex, but just that you've seen the choices you have to make.
26
<p><strong>Installation</strong></p>
28
<p>Pyro distributions contain a "distutils" <code>setup.py</code> script that will install
29
Pyro for you; just enter the following command from a shell prompt: " <code>python setup.py
30
install</code>" and
31
off you go. The script will ask if you want to install the Pyro script tools, and where to put
32
them. If you want to do an automated (unattended) install, edit the <code>setup.cfg</code> file,
33
following the directions in that file. <em>It will not install the
34
documentation and the examples, only the core Pyro library and the scripts.</em></p>
36
<p>But I will explain what exactly is in the Pyro distribution. It has a few subdirectories:</p>
39
<dt><code>Pyro/</code></dt>
41
<dd>This is the actual Pyro package. If you do not use the supplied <code>setup.py</code> install script (see
42
above) you have to install it by hand. Install this directory somewhere in your Python search path. On most systems
43
(also Windows), the <code>lib/site-packages</code> directory is a nice place. The exact location might vary
44
according to your specific Python installation.</dd>
46
<dd>Alternatively, keep it where it is and manually add the Pyro root directory to your Python search path (e.g. in
47
the environment variable <code>PYTHONPATH</code>).</dd>
49
<dt><code>bin/</code></dt>
51
<dd>This directory contains the command-line utilities. Move the contents of this directory somewhere in your shell
54
<dd>Alternatively, keep it where it is and manually add it to your shell search path.</dd>
56
<dt><code>docs/</code> and <code>examples/</code></dt>
58
<dd>Put those wherever you like. In docs you can find the Pyro manual, and in examples there are some Pyro
62
<p><strong>Configuration</strong></p>
64
<p>The default settings will do nicely in most cases. But sooner or later you will have to change some parameters of
65
Pyro. Pyro's configuration is accessed through <code>Pyro.config</code>. This object has a lot of configuration
66
items, shown in the table below.<br></p>
67
<p>Use <code>python -m Pyro.configuration</code> to get a printout of Pyro's active configuration settings.</p>
71
<th>Configuration item</th>
77
<th>Default value</th>
81
<td><code>PYRO_CONFIG_FILE</code></td>
85
<td>The Pyro configuration file that is used. See below.</td>
87
<td>Special, see below</td>
91
<td><code>PYRO_STORAGE</code></td>
95
<td>Location where Pyro stores data like log files. <em>Read the notice at the end!</em></td>
97
<td><i>Current directory</i></td>
101
<td><code>PYRO_LOGFILE</code></td>
105
<td>Name of the logfile. If it's not an absolute path, it's relative to <code>$PYRO_STORAGE</code>. It's best to
106
modify this <em>before</em> importing <code>Pyro.util</code>!</td>
108
<td><code>Pyro_log</code></td>
112
<td><code>PYRO_USER_LOGFILE</code></td>
116
<td>Name of the user logfile. If it's not an absolute path, it's relative to <code>$PYRO_STORAGE</code>.</td>
118
<td><code>Pyro_userlog</code></td>
122
<td><code>PYRO_TRACELEVEL</code></td>
126
<td>The tracing level of Pyro, 0-3. 0=nothing, 1=only errors, 2=warnings too, 3=full: errors, warnings and
133
<td><code>PYRO_USER_TRACELEVEL</code></td>
137
<td>The user tracing level, 0-3. 0=nothing, 1=only errors, 2=warnings too, 3=full: errors, warnings and
144
<td><code>PYRO_DETAILED_TRACEBACK</code></td>
148
<td>Should Pyro dump detailed tracebacks (with dumps of local variable's values)? If set to 1 on the server, the
149
clients will get detailed tracebacks from inside the server's code. You may not want this (security)...</td>
155
<td><code>PYRO_STDLOGGING</code></td>
159
<td>Should Pyro use new-style logging using the <code>logging</code> module (Python 2.3+)?</td>
165
<td><code>PYRO_STDLOGGING_CFGFILE</code></td>
169
<td>Name of the configuration file that is used to configure the new-style logging. If it's not an absolute path,
170
it's relative to <code>$PYRO_STORAGE</code>. If this file doesn't exist, Pyro uses the default configuration that
171
resembles the classic Pyro logging style.</td>
173
<td><code>logging.cfg</code></td>
177
<td><code>PYRO_PICKLE_FORMAT</code></td>
181
<td>The pickle protocol format that Pyro will use for marshaling.</td>
183
<td><code>pickle.HIGHEST_PROTOCOL</code> on Python 2.3+, else 1</td>
187
<td><code>PYRO_XML_PICKLE</code></td>
191
<td>Whether the marshaling is done using the safe xml pickling or
192
the default pickle. The xml_pickle is not vulnerable for the <a href="9-security.html#pickle">pickle
193
trojan problem</a>, but
194
it is an order of a magnitude slower, and requires more bandwith.
195
Set to "gnosis" for Gnosis XML pickler. There are no other options available at this time.
196
You need to have installed <a href=
197
"http://gnosis.cx/download/">Gnosis_Utils</a> (at least version 1.2.x).
198
Note that you have to use the same Gnosis XML library version everywhere. You can't mix older versions with newer versions. </td>
199
<td><i>empty</i> (disabled)</td>
203
<td><code>PYRO_GNOSIS_PARANOIA</code></td>
205
<td>The 'paranoia' setting that will be used for the Gnosis XML pickler. Higher=more secure.
206
The default setting (0) prevents automatic imports of modules during unpickling.
207
Set it to -1 to enable automatic imports of user defined modules.
208
When you use the mobile code feature together with Gnosis XML pickling, you need
209
to set it to -1 as well.</td>
214
<td><code>PYRO_COMPRESSION</code></td>
218
<td>Whether the protocol should compress the data to save bandwidth (at the cost of CPU time). The
219
<code>zlib</code> module is used for compression. If you don't have <code>zlib</code>, Pyro still works, but
220
without compression.</td>
226
<td><code>PYRO_CHECKSUM</code></td>
230
<td>Whether the protocol should perform a checksum over the message data. This costs a little bit extra CPU time,
231
but you will be quite sure that your communication is without errors. The <code>zlib.adler32</code> function is
232
used for checksumming. If you don't have <code>zlib</code>, Pyro still works, but without checksumming. The
233
overhead of checksumming is very small, with regular messages less than 0.1%, but increasing with big messages
234
(15% for 5 Mb or so). <strong>Note:</strong> the checksum is by no means secure. If you want secure
235
transmissions, you'll have to use SSL or build your own encryption/secure hashing functions on top of Pyro.</td>
241
<td><code>PYRO_SOCK_KEEPALIVE</code></td>
245
<td>Whether Pyro should set the SO_KEEPALIVE socket option on the network sockets. This is used
246
to detect broken client connections, to let the Pyro server clean them up nicely. It is enabled
247
by default, but it could cause problems in certain situations so you can turn it off if you
248
want. The timeout period is system-dependent but usually around 2 hours. It depends on your
249
OS how to change this value, but have a look at "sysctl". (This
250
feature may not be available on all OS's, if your OS doesn't support it, Pyro will automatically
257
<td><code>PYRO_MAXCONNECTIONS</code></td>
261
<td>The maximum number of simultaneous connections to one Pyro server. Note that a custom connection validator
262
may or may not take this in account. The default validator does check for this limit.</td>
268
<td><code>PYRO_TCP_LISTEN_BACKLOG</code></td>
272
<td>The size of the TCP socket listen backlog for Pyro daemons.</td>
278
<td><code>PYRO_BROKEN_MSGWAITALL</code></td>
280
<td>Some systems have broken socket MSG_WAITALL support. Set this item to 1 if your system is one of these. When
281
set to 1, Pyro will use a different piece of code to receive data (slower, but working on these systems as well). </td>
285
<td><code>PYRO_MULTITHREADED</code></td>
289
<td>Whether Pyro servers should be multithreaded or not.</td>
291
<td>1 (if supported)</td>
295
<td><code>PYRO_MOBILE_CODE</code></td>
299
<td>On the server: whether Pyro should automatically download Python code from clients if it isn't available on
300
the server. On the client: whether Pyro should automatically download Python code from the server if it returns
301
objects that aren't available on the client.</td>
307
<td><code>PYRO_DNS_URI</code></td>
311
<td>Whether symbolic DNS host names should be used in URIs instead of fixed IP addresses.</td>
317
<td><code>PYRO_BC_RETRIES</code></td>
321
<td>How often a broadcast will be retried if no answer has been received. Currently only used by the Name Server
322
locator. A negative number (<0) means infinitely. </td>
328
<td><code>PYRO_BC_TIMEOUT</code></td>
332
<td>How long Pyro will wait (in seconds) for an answer to a broadcast request. Currently only used by the Name
333
Server locator. A negative number (<0) means infinitely.</td>
339
<td><code>PYRO_PORT</code></td>
343
<td>The base socket number of the range of socket numbers that the Pyro daemon can use to listen for incoming
344
requests (Pyro method calls). Set to 0 to let the operating system choose a random port.</td>
350
<td><code>PYRO_PORT_RANGE</code></td>
354
<td>The size of the socket port range. Pyro will try to claim a socket for its Deamons in the socket port range
355
PYRO_PORT to (but not including) PYRO_PORT+PYRO_PORT_RANGE. This means that if Pyro already has a Daemon listning
356
on socket N, a new Deamon will claim socket N+1, and so on. You can disable this by using a special argument when
357
construction a Daemon (or setting this item to 1).</td>
363
<td><code>PYRO_HOST</code></td>
367
<td>The hostname Pyro's daemon will bind on. Useful when your machine has multiple hostnames/network adapters
368
on which it can listen. (Also influences NameServer.)</td>
370
<td>'' <em>(default host)</em></td>
374
<td><code>PYRO_PUBLISHHOST</code></td>
378
<td>the hostname that Pyro daemons will use when publishing URIs. Useful in case of a firewall/NAT setup.
379
See the Features chapter for firewall info. </td>
381
<td>None <em>(same as normal hostname)</em></td>
385
<td><code>PYRO_NS_DEFAULTGROUP</code></td>
389
<td>The default group name in which names are located. <em>This must be an absolute name (starting with the root
390
character).</em></td>
392
<td><code>:Default</code></td>
396
<td><code>PYRO_NS_URIFILE</code></td>
400
<td>The file where the Name Server will write its URI. If it's not an absolute path, it's relative to
401
<code>$PYRO_STORAGE</code>.</td>
403
<td><code>Pyro_NS_URI</code></td>
407
<td><code>PYRO_NS_HOSTNAME</code></td>
411
<td>The hostname that is initially tried to find the NameServer on, or when the broadcast lookup mechanism fails.</td>
413
<td><i>empty</i></td>
417
<td><code>PYRO_NS_PORT</code></td>
421
<td>The socket number on which the Name Server will listen for incoming requests (Pyro method calls, in
422
fact). Set to 0 to let the operating system choose a random port. Note that if you set this to 0, a client cannot use
423
this config item to directly connect to the NS. It will have to use the broadcast lookup.</td>
428
<td><code>PYRO_NS_BC_ADDR</code></td>
430
<td>Overrides the default broadcast address. It is used by the nameserver to bind the broadcast
431
listener on this broadcast address, and by the name server locator when it uses broadcast discovery.
432
When empty, the default broadcast address is used (usually 255.255.255.255).</td>
433
<td><i>empty</i></td>
437
<td><code>PYRO_NS_BC_PORT</code></td>
439
<td>The socket number on which the Name Server will listen for broadcast requests (usually to find the
445
<td><code>PYRO_NS2_HOSTNAME</code></td>
449
<td>Like above, but for the second (paired) Name Server.</td>
451
<td><i>empty</i></td>
455
<td><code>PYRO_NS2_PORT</code></td>
459
<td>Like above, but for the second (paired) Name Server.</td>
465
<td><code>PYRO_NS2_BC_ADDR</code></td>
467
<td>Like above, but for the second (paired) Name Server.</td>
468
<td><i>empty</i></td>
472
<td><code>PYRO_NS2_BC_PORT</code></td>
476
<td>Like above, but for the second (paired) Name Server.</td>
482
<td><code>PYRO_ES_QUEUESIZE</code></td>
486
<td>The size of the message queues per subscriber that the Event Server allocates. Use 0 (zero) for infinite
493
<td><code>PYRO_ES_BLOCKQUEUE</code></td>
497
<td>If true (1), a publisher will block if an event queue on the server is full, and continue as soon as the
498
queue has some space again. If false (0), the publisher won't block, but <em>the event is lost</em>
499
(but only for the subscriber who has a full queue).</td>
505
<td><code>PYRO_ONEWAY_THREADED</code></td>
509
<td>If true (1), oneway method calls will execute in a new server thread.
510
This allows for the server to continue to process other method calls on this object in the meantime.
511
If false (0), oneway method calls will execute in the main server thread and need to complete before
512
the server can process other calls on that object.</td>
517
<td><code>PYROSSL_CERTDIR</code></td>
521
<td>The directory where openssl certificates are stored.</td>
523
<td>'certs' in the PYRO_STORAGE location.</td>
527
<td><code>PYROSSL_CA_CERT</code></td>
531
<td>Certificate of the Certificate Authority. Used to check if client and server certificates are valid (that
532
they are signed by the given CA)</td>
538
<td><code>PYROSSL_SERVER_CERT</code></td>
542
<td>Certificate for server side</td>
548
<td><code>PYROSSL_CLIENT_CERT</code></td>
552
<td>Certificate for client side</td>
557
<td><code>PYROSSL_POSTCONNCHECK</code></td>
561
<td>Tells the SSL layer if it should do 'post-connection' validations on the certificate(s) for instance.
562
Set it to 0 to disable these checks (not advised! But convenient to be able to use a
563
certificate that hasn't got a matching commonName or stuff like that) Default is 1:
564
the SSL layer will do its checks as enabled by its own default settings.</td>
570
<p>There are several ways to change the default settings:</p>
573
<li>Change the settings in your code, at runtime. You can change all settings before starting Pyro, and most
574
settings can be changed dynamically during execution too. <em>Note that you cannot use this to change
575
<code>Pyro.config.PYRO_STORAGE</code>! See below!</em><br>
576
... <code>Pyro.config.PYRO_PORT = 7000</code><br>
577
... <code>Pyro.config.PYRO_TRACELEVEL = 3</code></li>
579
<li>Define environment variables that override the default settings.<br>
580
Every configuration item has an equivalent environment variable. If you define this, you can override the default
581
setting for that item. For instance, it might be convenient to have your Pyro programs generate log files and put
582
them in a designated log directory:<br>
583
...<code>$ export PYRO_LOGFILE=/var/log/PYRO/logfile</code><br>
584
...<code>$ export PYRO_TRACELEVEL=3</code><br>
585
(This is for bash - syntax is different for other shells or Windows.)</li>
587
<li>Configuration files<br>
588
You can use a configuration file that can contain some small configuration changes or a fully new configuration
589
for all items. Pyro checks if the environment variable <code>PYRO_CONFIG_FILE</code> is set. If it isn't set, or
590
set to an empty string, Pyro checks for a <code>Pyro.conf</code> file in the current directory. If it exists,
591
Pyro uses it as a configuration file. If it doesn't exist, Pyro uses the default built-in configuration.<br>
592
If the environment variable is set, Pyro uses the value as the name for the configuration file. If the
593
configuration file can't be read, a PyroError exception occurs.
595
<p>The format of the configuration file is very simple. It is a text file, and each line can be empty, a comment,
596
or a configuration item setting. A comment starts with '#'. A config item setting is of the format 'ITEM=VALUE'.
597
If Pyro finds an unknown config item, a KeyError exception occurs.</p>
599
<p>Note that <code>PYRO_CONFIG_FILE</code> is useless inside a configuration file. After initialization, it is
600
set to the absolute path of the configuration file that was used (or the empty string, if no configuration file
601
was used). Note that setting <code>PYRO_CONFIG_FILE</code> from within your code is useless too because Pyro is
602
already initialized at that point.</p>
604
</ol>Environment variables override configuration file settings. Configuration file settings override the built-in
607
<p><code>PYRO_STORAGE</code> is used at initialization time, that is, as soon as a part of the Pyro package is
608
imported in your program. You can only change <code>PYRO_STORAGE</code> <em>beforehand</em> by either setting the
609
environment variable or making an entry in the configuration file. Changing <code>Pyro.config.PYRO_STORAGE</code> in
610
your program leads to unexpected results, because the initilization has already been done using the old value. So
611
don't do this, and use one of the two other ways.</p>
616
<td align="left"><a href="2-concepts.html"><previous</a> | <a href="PyroManual.html">contents</a> | <a href=
617
"4-usage.html">next></a></td>
619
<td align="right">Pyro Manual</td>