organizing many python scripts, in a large corporate environment.

eryksun () eryksun at gmail.com
Mon Mar 14 15:56:15 EDT 2011


On Monday, March 14, 2011 9:45:51 AM UTC-4, eryksun () wrote:
> 
> If you're linking to a common file, couldn't you just add in 
> the base folder there? 
>
> ...
> 
> # script.py
> import _path   # _path.py is a symbolic link
> 
> # _path.py:
> base = '/absolute/path/to/base'
> import site
> site.addsitedir(base) 

To be clear on the file structure, I'm picturing that 'base' is a path on each user's shell path where all the accessible scripts are linked, and that this is also the package directory. So when a linked script runs "import _path" it will import the _path.py that's located in base, which adds the base path to Python's sys.path. On the other hand, any subsequently imported modules will be found by searching sys.path. Thus each subdirectory needs the additional symbolic link back to the base _path.py. It's a bit convoluted, but so are the constraints of this problem -- at least to me.



More information about the Python-list mailing list