[Distutils] Creating an "app folder" with setuptools?
Leif Strand
leif at geodynamics.org
Wed Nov 8 04:53:26 CET 2006
I've been trying to use setuptools as a "Pythonic Autopackage".
Basically, I want users to be able install a Python package -- plus all
its needed dependencies -- with a single command, without any
preparatory steps, and with no questions asked.
To this end, the best strategy seems to be the "app folder" strategy
used on Windows. On Windows, the runtime linker/loader implicitly adds
the directory containing the main '.exe' to the DLL search path. This
means that regardless of any environment settings (such as PATH), DLLs
put alongside the main EXE will be found -- and, with few exceptions,
will override DLLs elsewhere on the system. This fact is routinely
exploited on Windows: you can dump your EXE and all its needed
dependencies in a single folder, and it will "just work".
The Python interpreter is similar to the Windows loader in that the
directory containing the main Python script is always first on
'sys.path'. This fact, combined with the awesome 'setuptools' package
and easy_install's --install-dir (-d) option would seem to give me
everything I need.
However, there are road blocks which I can't seem to get around (without
patching setuptools, that is). The chief problem seems to be that
setuptools complains too much!
*) It complains if the destination directory doesn't exist.
*) It complains if the destination directory doesn't support .pth files
or isn't on PYTHONPATH.
Actually, I find the errors about .pth/PYTHONPATH to be annoying in
general. On Unix, I'm accustomed to tools which simply do what they're
told, be it "rm -rf *" or anything else. For example, "./configure
--prefix=$HOME/foo/bar; make; make install" will create $HOME/foo/bar if
it doesn't already exist, and Autoconf certainly doesn't complain about
the subdirectories thus created not being on PATH or PYTHONPATH.
One could argue that this amounts to a philosophical difference. But to
me, the .pth/PYTHONPATH errors seem like a bug/limitation. If I tell
easy_install to create a directory containing my app's scripts, plus all
its (possibly "flat") egg dependencies, the resulting directory *will*
work once all the dust clears, regardless of what my PYTHONPATH may
contain at install time. Even in the case of .pth files, there is no way
to know at install time what might work at runtime -- for example, my
app's generated, top-level scripts might call site.addsitedir()
themselves on behalf of the application.
But perhaps I've just overlooked something. Is there a way to to tell
setuptools to simply do what it's told?
--Leif
More information about the Distutils-SIG
mailing list