organizing many python scripts, in a large corporate environment.

eryksun () eryksun at gmail.com
Sat Mar 12 14:01:20 EST 2011


bukzor wrote:
> This only works if you can edit the PYTHONPATH. With thousands of
> users and dozens of groups each with their own custom environments,
> this is a herculean effort.

It works for me without setting PYTHONPATH. Again, I run the module from the root folder with the -m option as a package module (no .py extension), which is easy enough to do with a Windows shortcut. 

No doubt there's a way to hack things to make direct execution work, but I don't think it's recommended to directly run a script that's part of a package namespace. Experts on the subject can feel free to chime in. 

If you need a site-wide solution that works with Unix shebang, you could symlink the names of all the scripts to a dispatcher. Extract the name from argv[0] based on the symlink filename, and then find the script in the package (or periodically update a stored hash of all scripts). Have the dispatcher run it as a package module with `python -m path.to.module [args]`. 

I hope someone else has a better idea...

--
EOF



More information about the Python-list mailing list