organizing your scripts, with plenty of re-use
Buck
workitharder at gmail.com
Tue Oct 13 16:38:44 EDT 2009
On Oct 13, 9:37 am, Ethan Furman <et... at stoneleaf.us> wrote:
> Buck wrote:
> >I'd like to get to zero-installation if possible. It's easy with
> >simple python scripts, why not packages too? I know the technical
> >reasons, but I haven't heard any practical reasons.
>
> I don't think we mean the same thing by "zero-installation"... seems to
> me that if you have to copy it, check it out, or anything to get the
> code from point A to point 'usable on your computer', then you have done
> some sort of installation.
I think most people would agree that installation is whatever you need
to do between downloading the software and being able to use it. For
GNU packages, it's './configure && make && make install'. For Python
packages, it's usually './setup.py install'.
> > Steven had the nicest workaround (with the location = __import__
> > ('__main__').__file__ trick), but none of them solve the problem of
> > the OP: organization of runnable scripts. So far it's been required to
> > place all runnable scripts directly above any used packages. The
> > workaround that Gabriel has been touting requires this too.
>
> Wha? "Place all runnable scripts directly above any used packages?" I
> must have missed something major in this thread. The only thing
> necessary is to have the package being imported to be somewhere in
> PYTHONPATH.
The only way to get your packages on the PYTHONPATH currently is to:
* install the packages to site-packages (I don't have access)
* edit the PYTHONPATH all users' environment (again, no access)
* create some boilerplate that edits sys.path at runtime (various
problems in previous post)
* put your scripts directly above the package (this seems best so
far, but forces a flat hierarchy of scripts)
More information about the Python-list
mailing list