py2dx Installation Guide
For py2dx 2.0 released August 11, 2003
These are the installation notes for py2dx, a Python extension for the OpenDX visualization package. With it, a Python program can start OpenDX, load or define a network, and manipulate the modules. Please send questions or comments to PSC User Services.
1. Overview
Python can load extensions with a command like import DX. Once loaded, the new features defined by the extension can be used like any other Python command.
The py2dx extension makes most of the commands in the OpenDX library named DXLink look like Python commands. In addition, this extension arranges for messages from OpenDX to be handled in Python. If the OpenDX message concerns an error, a Python exception will be created. Other messages can be routed to a Python routine (typically termed a callback) for processing by the application.
Installing this extension requires making changes in the /usr/lib directory which, on most systems, requires root privileges.
2. Prepare the Files
You need to first find the library on your system that contains Python version 2.2 or later. You must avoid earlier versions of Python - they cannot be used for this extension. On Linux 9.0, for example, the library is /usr/lib/python2.2.
In the Python directory, go to the subdirectory named site-packages. If there is already a directory there named DX, you must rename it or (if brave) remove it.
Create a new directory named DX under site-packages and download the py2dx distribution to that directory. Please see the MFIX tools documentation to download the package.
Uncompress and untar the downloaded file. This should create a subdirectory named Install that contains a number of files.
3. Install
In the new directory Install, review the file named Makefile. It has been set to use the standard locations for Python and OpenDX. If you have stored things in other locations, you will probably need to change only a line or two at the top.
Run make and check that it creates the following 6 files. You may need to adjust the compiler settings in the file Makefile or change other items to be appropriate for your system.
-
In directory site-packages:
-
DX.pth
In directory DX:
-
__init__.py
__init__.pyc
DXServer.py
DXServer.pyc
_DX.so
4. Regeneration of Interface Files
The open-source utility called SWIG generates the files DX_wrap.c (about 3940 lines) and __init__.py (about 205 lines) using the OpenDX file dxl.h. Because SWIG can be tricky, the two files produced by SWIG are distributed with py2dx so you do not have to run SWIG on your system.
However, if your Python application seems to have trouble running OpenDX, check whether you are running versions of OpenDX or Linux that are new. The versions used in the current py2dx distribution are listed under "System Requirements" in the py2dx User Guide. If your versions are newer, running SWIG to regenerate the interface files may help.
To regenerate these files, first be sure that the version of SWIG on your system is equal to or greater than the version listed under "System Requirements". Then, move the old versions of DX_wrap.c and __init__.py to another location and run make again.
Note: SWIG creates a file named DX.py which is then renamed by Make to __init__.py.