3. Installation and Configuration

Please read this entire chapter before trying to install Pyro.  Not that it's complex, but just that you've seen the choices you have to make.

Installation

Pyro distributions contain a "distutils" setup.py script that will install Pyro for you; just enter the following command from a shell prompt: " python setup.py install" and off you go. The script will ask if you want to install the Pyro script tools, and where to put them. If you want to do an automated (unattended) install, edit the setup.cfg file, following the directions in that file. It will not install the documentation and the examples, only the core Pyro library and the scripts.

But I will explain what exactly is in the Pyro distribution. It has a few subdirectories:

Pyro/
This is the actual Pyro package. If you do not use the supplied setup.py install script (see above) you have to install it by hand. Install this directory somewhere in your Python search path. On most systems (also Windows), the lib/site-packages directory is a nice place. The exact location might vary according to your specific Python installation.
Alternatively, keep it where it is and manually add the Pyro root directory to your Python search path (e.g. in the environment variable PYTHONPATH).
bin/
This directory contains the command-line utilities. Move the contents of this directory somewhere in your shell search path.
Alternatively, keep it where it is and manually add it to your shell search path.
docs/   and   examples/
Put those wherever you like. In docs you can find the Pyro manual, and in examples there are some Pyro examples.

Configuration

The default settings will do nicely in most cases. But sooner or later you will have to change some parameters of Pyro. Pyro's configuration is accessed through Pyro.config. This object has a lot of configuration items, shown in the table below.

Use python -m Pyro.configuration to get a printout of Pyro's active configuration settings.

Configuration item Type Description Default value
PYRO_CONFIG_FILE string The Pyro configuration file that is used. See below. Special, see below
PYRO_STORAGE string Location where Pyro stores data like log files. Read the notice at the end! Current directory
PYRO_LOGFILE string Name of the logfile. If it's not an absolute path, it's relative to $PYRO_STORAGE. It's best to modify this before importing Pyro.util! Pyro_log
PYRO_USER_LOGFILE string Name of the user logfile. If it's not an absolute path, it's relative to $PYRO_STORAGE. Pyro_userlog
PYRO_TRACELEVEL number The tracing level of Pyro, 0-3. 0=nothing, 1=only errors, 2=warnings too, 3=full: errors, warnings and notes. 0
PYRO_USER_TRACELEVEL number The user tracing level, 0-3. 0=nothing, 1=only errors, 2=warnings too, 3=full: errors, warnings and notes. 0
PYRO_DETAILED_TRACEBACK boolean Should Pyro dump detailed tracebacks (with dumps of local variable's values)? If set to 1 on the server, the clients will get detailed tracebacks from inside the server's code. You may not want this (security)... 0
PYRO_STDLOGGING boolean Should Pyro use new-style logging using the logging module (Python 2.3+)? 0
PYRO_STDLOGGING_CFGFILE string Name of the configuration file that is used to configure the new-style logging. If it's not an absolute path, it's relative to $PYRO_STORAGE. If this file doesn't exist, Pyro uses the default configuration that resembles the classic Pyro logging style. logging.cfg
PYRO_PICKLE_FORMAT integer The pickle protocol format that Pyro will use for marshaling. pickle.HIGHEST_PROTOCOL on Python 2.3+, else 1
PYRO_XML_PICKLE string Whether the marshaling is done using the safe xml pickling or the default pickle. The xml_pickle is not vulnerable for the pickle trojan problem, but it is an order of a magnitude slower, and requires more bandwith. Set to "gnosis" for Gnosis XML pickler. There are no other options available at this time. You need to have installed Gnosis_Utils (at least version 1.2.x). Note that you have to use the same Gnosis XML library version everywhere. You can't mix older versions with newer versions. empty (disabled)
PYRO_GNOSIS_PARANOIA number The 'paranoia' setting that will be used for the Gnosis XML pickler. Higher=more secure. The default setting (0) prevents automatic imports of modules during unpickling. Set it to -1 to enable automatic imports of user defined modules. When you use the mobile code feature together with Gnosis XML pickling, you need to set it to -1 as well. 0
PYRO_COMPRESSION boolean Whether the protocol should compress the data to save bandwidth (at the cost of CPU time). The zlib module is used for compression. If you don't have zlib, Pyro still works, but without compression. 0
PYRO_CHECKSUM boolean Whether the protocol should perform a checksum over the message data. This costs a little bit extra CPU time, but you will be quite sure that your communication is without errors. The zlib.adler32 function is used for checksumming. If you don't have zlib, Pyro still works, but without checksumming. The overhead of checksumming is very small, with regular messages less than 0.1%, but increasing with big messages (15% for 5 Mb or so). Note: the checksum is by no means secure. If you want secure transmissions, you'll have to use SSL or build your own encryption/secure hashing functions on top of Pyro. 0
PYRO_SOCK_KEEPALIVE boolean Whether Pyro should set the SO_KEEPALIVE socket option on the network sockets. This is used to detect broken client connections, to let the Pyro server clean them up nicely. It is enabled by default, but it could cause problems in certain situations so you can turn it off if you want. The timeout period is system-dependent but usually around 2 hours. It depends on your OS how to change this value, but have a look at "sysctl". (This feature may not be available on all OS's, if your OS doesn't support it, Pyro will automatically switch it off). 1
PYRO_MAXCONNECTIONS number The maximum number of simultaneous connections to one Pyro server. Note that a custom connection validator may or may not take this in account. The default validator does check for this limit. 200
PYRO_TCP_LISTEN_BACKLOG number The size of the TCP socket listen backlog for Pyro daemons. 200
PYRO_BROKEN_MSGWAITALL boolean Some systems have broken socket MSG_WAITALL support. Set this item to 1 if your system is one of these. When set to 1, Pyro will use a different piece of code to receive data (slower, but working on these systems as well). 0
PYRO_MULTITHREADED boolean Whether Pyro servers should be multithreaded or not. 1 (if supported)
PYRO_MOBILE_CODE boolean On the server: whether Pyro should automatically download Python code from clients if it isn't available on the server. On the client: whether Pyro should automatically download Python code from the server if it returns objects that aren't available on the client. 0
PYRO_DNS_URI boolean Whether symbolic DNS host names should be used in URIs instead of fixed IP addresses. 0
PYRO_BC_RETRIES number How often a broadcast will be retried if no answer has been received. Currently only used by the Name Server locator. A negative number (<0) means infinitely. 2
PYRO_BC_TIMEOUT number How long Pyro will wait (in seconds) for an answer to a broadcast request. Currently only used by the Name Server locator. A negative number (<0) means infinitely. 2
PYRO_PORT number The base socket number of the range of socket numbers that the Pyro daemon can use to listen for incoming requests (Pyro method calls). Set to 0 to let the operating system choose a random port. 7766
PYRO_PORT_RANGE number The size of the socket port range. Pyro will try to claim a socket for its Deamons in the socket port range PYRO_PORT to (but not including) PYRO_PORT+PYRO_PORT_RANGE. This means that if Pyro already has a Daemon listning on socket N, a new Deamon will claim socket N+1, and so on. You can disable this by using a special argument when construction a Daemon (or setting this item to 1). 100
PYRO_HOST string The hostname Pyro's daemon will bind on. Useful when your machine has multiple hostnames/network adapters on which it can listen. (Also influences NameServer.) '' (default host)
PYRO_PUBLISHHOST string the hostname that Pyro daemons will use when publishing URIs. Useful in case of a firewall/NAT setup. See the Features chapter for firewall info. None (same as normal hostname)
PYRO_NS_DEFAULTGROUP string The default group name in which names are located. This must be an absolute name (starting with the root character). :Default
PYRO_NS_URIFILE string The file where the Name Server will write its URI. If it's not an absolute path, it's relative to $PYRO_STORAGE. Pyro_NS_URI
PYRO_NS_HOSTNAME string The hostname that is initially tried to find the NameServer on, or when the broadcast lookup mechanism fails. empty
PYRO_NS_PORT number The socket number on which the Name Server will listen for incoming requests (Pyro method calls, in 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 this config item to directly connect to the NS. It will have to use the broadcast lookup. 9090
PYRO_NS_BC_ADDR string Overrides the default broadcast address. It is used by the nameserver to bind the broadcast listener on this broadcast address, and by the name server locator when it uses broadcast discovery. When empty, the default broadcast address is used (usually 255.255.255.255). empty
PYRO_NS_BC_PORT number The socket number on which the Name Server will listen for broadcast requests (usually to find the location). 9090
PYRO_NS2_HOSTNAME string Like above, but for the second (paired) Name Server. empty
PYRO_NS2_PORT number Like above, but for the second (paired) Name Server. 9091
PYRO_NS2_BC_ADDR string Like above, but for the second (paired) Name Server. empty
PYRO_NS2_BC_PORT number Like above, but for the second (paired) Name Server. 9091
PYRO_ES_QUEUESIZE number The size of the message queues per subscriber that the Event Server allocates. Use 0 (zero) for infinite size. 1000
PYRO_ES_BLOCKQUEUE boolean If true (1), a publisher will block if an event queue on the server is full, and continue as soon as the queue has some space again. If false (0), the publisher won't block, but the event is lost (but only for the subscriber who has a full queue). 1
PYRO_ONEWAY_THREADED boolean If true (1), oneway method calls will execute in a new server thread. This allows for the server to continue to process other method calls on this object in the meantime. If false (0), oneway method calls will execute in the main server thread and need to complete before the server can process other calls on that object. 1
PYROSSL_CERTDIR string The directory where openssl certificates are stored. 'certs' in the PYRO_STORAGE location.
PYROSSL_CA_CERT string Certificate of the Certificate Authority. Used to check if client and server certificates are valid (that they are signed by the given CA) ca.pem
PYROSSL_CERT string Certificate file for SSL host.pem
PYROSSL_KEY string Optional SSL key file (required if your host key is not part of the certificate file) None
PYROSSL_POSTCONNCHECK boolean Tells the SSL layer if it should do 'post-connection' validations on the certificate(s) for instance. Set it to 0 to disable these checks (not advised! But convenient to be able to use a certificate that hasn't got a matching commonName or stuff like that) Default is 1: the SSL layer will do its checks as enabled by its own default settings. 1

There are several ways to change the default settings:

  1. Change the settings in your code, at runtime. You can change all settings before starting Pyro, and most settings can be changed dynamically during execution too. Note that you cannot use this to change Pyro.config.PYRO_STORAGE! See below!
    ... Pyro.config.PYRO_PORT = 7000
    ... Pyro.config.PYRO_TRACELEVEL = 3
  2. Define environment variables that override the default settings.
    Every configuration item has an equivalent environment variable. If you define this, you can override the default setting for that item. For instance, it might be convenient to have your Pyro programs generate log files and put them in a designated log directory:
    ...$ export PYRO_LOGFILE=/var/log/PYRO/logfile
    ...$ export PYRO_TRACELEVEL=3
    (This is for bash - syntax is different for other shells or Windows.)
  3. Configuration files
    You can use a configuration file that can contain some small configuration changes or a fully new configuration for all items. Pyro checks if the environment variable PYRO_CONFIG_FILE is set. If it isn't set, or set to an empty string, Pyro checks for a Pyro.conf file in the current directory. If it exists, Pyro uses it as a configuration file. If it doesn't exist, Pyro uses the default built-in configuration.
    If the environment variable is set, Pyro uses the value as the name for the configuration file. If the configuration file can't be read, a PyroError exception occurs.

    The format of the configuration file is very simple. It is a text file, and each line can be empty, a comment, or a configuration item setting. A comment starts with '#'. A config item setting is of the format 'ITEM=VALUE'. If Pyro finds an unknown config item, a KeyError exception occurs.

    Note that PYRO_CONFIG_FILE is useless inside a configuration file. After initialization, it is set to the absolute path of the configuration file that was used (or the empty string, if no configuration file was used). Note that setting PYRO_CONFIG_FILE from within your code is useless too because Pyro is already initialized at that point.

Environment variables override configuration file settings. Configuration file settings override the built-in default settings.

PYRO_STORAGE is used at initialization time, that is, as soon as a part of the Pyro package is imported in your program. You can only change PYRO_STORAGE beforehand by either setting the environment variable or making an entry in the configuration file. Changing Pyro.config.PYRO_STORAGE in your program leads to unexpected results, because the initilization has already been done using the old value. So don't do this, and use one of the two other ways.