David Collantes <[EMAIL PROTECTED]> writes: > I have a question about tmda-tofmipd. On the file itself, this shows: > > except ImportError: > # Prepend /usr/lib/python2.x/site-packages/TMDA/pythonlib > sitedir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3], > 'site-packages', 'TMDA', 'pythonlib') > sys.path.insert(0, sitedir) > > That is very OS centric, right?
Not really. PREFIX/python2.x/site-packages is a standard search location for packages installed by third parties. You can run TMDA in one of two ways. First, you can simply unpack the tarball and either put tmda-X.xx/bin in your path or symlink tmda-X.xx/bin/tmda-* into /usr/local/bin, for instance. In this scenario, the two or three lines above what you quoted kick in and the programs successfully import paths.py (also in bin). That file adds '../TMDA' and ../TMDA/pythonlib' to the search path. Actually, it specifies an absolute path to those locations, but you get the idea. When TMDA is installed by an RPM or a BSD port, the tmda-X.xx/TMDA directory (package) is placed in site-packages and the bin/tmda* files are copied to PREFIX (usually /usr/local/bin). The paths.py file is not copied! So the import for that fails and we fix up the module search path with the code above. The Python variable sys.prefix will contain whatever you used for $PREFIX at the time you copiled Python. If you set PREFIX to /usr, then Python is at /usr/lib/python2.x. If you set it to /usr/local, then Python is at /usr/local/lib/python2.x. In either case, the above code does the right thing and finds the site-packages directory within the Python tree. The site-packages directory is a standard part of a Python install, though it's usually empty to begin with. > I have my tmda installed for global use at /usr/local/tmda, should I > change the line about accordingly, so tmda-tofmipd find the > libraries where it should? If you installed from tarball, you shouldn't need to change anything. TMDA will successfully import paths.py and will find the TMDA and TMDA/pythonlib directories in /usr/local/tmda/. > The tofmipd.pid is not being created, will that cause that? As far as I am aware, tmda-ofmipd doesn't create a .pid file. Is there something else that does in your configuration? In any case, the search path specified above should have nothing to do with it. It is only used internally by Python to find modules. If tmda-ofmipd actually loads and doesn't bomb out right at the beginning with an ImportError exception (when importing Util, right after the code you quoted), then the search path update is working correctly. Tim _____________________________________________ tmda-users mailing list ([EMAIL PROTECTED]) http://tmda.net/lists/listinfo/tmda-users
