Simon Wittber
simonwittber at gmail.com
Thu Jan 6 10:31:46 EST 2005
> > /home/simon/public_html/package/module.py > > No surprise, this doesn't work in Python, either. The example I provided was contrived, designed to illustrate my problem. I had created the package correctly, as you describe below. The package is designed to be installed using a distutils setup.py script. I need the package in each developer's public_html directory so that each individual developer can modifiy parts of the package and only effect their development environment, (we are all working on a single linux box) and not the entire server. Changes to the package are merged using SVN. The package will eventually be deployed to production using distutils. > Just make the subdirectory a package: > > cd /home/simon/public_html/package/ > touch __init__.py > > Now, anything running from /home/simon/public_html/ can do this: > > import package.module It seems, with the standard PSP handler, that this statement is incorrect. This is because psp.py loads and exec's the .psp file, and psp.py has a different current working directory to the .psp file. Therefore, the directory which contains the .psp file, is not in sys.path. > The same rules (generally) apply to mod_python as to running a single > interpreter from the command line. Except, it seems, files which are processed by the PSP handler. PSP files will not import modules or packages which exist in the same directory as the PSP file, unless of course, the .psp filepath exists in sys.path. Whether this is a bug or not, depends on one's point of view. Personally, I believe .psp files should be able to import python modules and packages from .psp file's directory, hence the psp.py hack. Sw.
|