paulb@330 | 1 | <?xml version="1.0" encoding="iso-8859-1"?> |
paulb@330 | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
paulb@330 | 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
paulb@330 | 4 | <html xmlns="http://www.w3.org/1999/xhtml"> |
paulb@330 | 5 | <head> |
paulb@330 | 6 | <title>Getting PYTHONPATH Right</title> |
paulb@330 | 7 | <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" /> |
paulb@330 | 8 | <link href="styles.css" rel="stylesheet" type="text/css" /> |
paulb@330 | 9 | </head> |
paulb@330 | 10 | |
paulb@330 | 11 | <body> |
paulb@330 | 12 | <h1>Getting PYTHONPATH Right</h1> |
paulb@330 | 13 | |
paulb@330 | 14 | <p>When deploying your application, it is essential that it has access to all |
paulb@330 | 15 | the necessary libraries and packages that it uses. If such libraries and |
paulb@330 | 16 | packages were installed using the standard <code>setup.py</code> program, |
paulb@330 | 17 | then you may only need to worry about the application itself being found by |
paulb@330 | 18 | Python.</p> |
paulb@330 | 19 | |
paulb@330 | 20 | <h2>Running Adapters Directly</h2> |
paulb@330 | 21 | |
paulb@330 | 22 | <p>For those server environments where you can just run the adapter code |
paulb@330 | 23 | (BaseHTTPRequestHandler, Twisted), you can choose to specify the |
paulb@330 | 24 | <code>PYTHONPATH</code> on the command line when you run the code. Here is an |
paulb@330 | 25 | example of this (using <code>bash</code> on GNU/Linux or UNIX |
paulb@330 | 26 | distributions):</p> |
paulb@330 | 27 | <pre>PYTHONPATH=.:examples/Common python examples/BaseHTTPRequestHandler/SimpleApp.py</pre> |
paulb@330 | 28 | |
paulb@330 | 29 | <h2>Adapters Run by the Web Server</h2> |
paulb@330 | 30 | |
paulb@330 | 31 | <p>For those server environments where the Web server itself runs the adapter |
paulb@330 | 32 | code (CGI, mod_python, WSGI), you may need to either configure the Web server |
paulb@330 | 33 | to alter the <code>PYTHONPATH</code>, if possible, or to add some extra lines |
paulb@330 | 34 | in the adapter code to change Python's <code>sys.path</code> variable. Here |
paulb@330 | 35 | is an example of this:</p> |
paulb@330 | 36 | <pre>sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")</pre> |
paulb@330 | 37 | |
paulb@330 | 38 | <h2>Configuring PYTHONPATH in Java Servlet Containers</h2> |
paulb@330 | 39 | |
paulb@330 | 40 | <p>In servlet container deployments, all required libraries and packages are |
paulb@330 | 41 | typically bundled with the application itself. Since this bundling process is |
paulb@330 | 42 | usually very inconvenient, a script has been included in the |
paulb@330 | 43 | <code>tools/JavaServlet</code> directory to make it slightly easier.</p> |
paulb@330 | 44 | |
paulb@330 | 45 | <h2>Configuring PYTHONPATH in Webware</h2> |
paulb@330 | 46 | |
paulb@330 | 47 | <p>Since Webware's WebKit runs as a separate process, it is possible to |
paulb@330 | 48 | specify <code>PYTHONPATH</code> on the command line when you start that |
paulb@330 | 49 | process. Here is an example of this (using <code>bash</code> on GNU/Linux or |
paulb@330 | 50 | UNIX distributions):</p> |
paulb@330 | 51 | <pre>cd WebKit |
paulb@330 | 52 | PYTHONPATH=/home/paulb/Software/Python/WebStack/examples/Common ./AppServer</pre> |
paulb@330 | 53 | |
paulb@330 | 54 | <h2>Configuring PYTHONPATH in Zope</h2> |
paulb@330 | 55 | |
paulb@330 | 56 | <p>In Zope's <code>etc/zope.conf</code> file, <code>path</code> directives |
paulb@330 | 57 | can be used to indicate the location of various resources. Here is an example |
paulb@330 | 58 | of this:</p> |
paulb@330 | 59 | <pre>path /home/paulb/Software/Python/WebStack/examples/Common</pre> |
paulb@330 | 60 | </body> |
paulb@330 | 61 | </html> |