On 26 May 2000, Gordon McMillan said:
Hmm. I see an application as a module distribution that happens to have a script. (Or maybe I see a module distribution as a scriptless app ;-)).
But end-users who just want to run a Python application see it as an application; the fact that it's (largely) written in Python and includes a Python library of its own is immaterial. However, all files from that application should most likely be installed in the same place -- /usr/local/myapp or "C:\Program Files\MyApp", pick your poison.
And the module developer should have the option of just dumping his stuff in /usr/local/lib/python1.x/site-packages and /usr/local/bin, or C:\Python, or whatever is the locally appropriate place to dump Python modules. Currently, of course, that's the *only* option that the Distutils easily supports. (Although I suspect that with the current code, one could craft a setup.cfg that forces the "install" command to put files wherever you damn well please. That's icky, though -- it won't deal with setting the right sys.path for your application.)
An idea AMK and I cooked up yesterday would be an addition to the Distutils "build_scripts" command: along with frobbing the #! line to point to the right Python interpreter, add a second line: import sys ; sys.append(path-to-this-app's-python-lib)
Or maybe "sys.insert(0, ...)".
Oops, meant "sys.path..." there of course.
The idea is to set sys.path for *just this application* rather than for all Python code installed on the system. This is kind of important if you have an application that defines a module "DateTime" and another, independent module called "DateTime". /usr/local/myapp/lib/python should come first in sys.path when you run myapp, and it should never be seen when you run anything else.
The possibilities are: * create shell script wrappers for every Python script: eg. script1 might be PYTHONPATH=/usr/local/myapp/lib/python \ exec /usr/local/bin/python1.6 /usr/local/myapp/_script1.py
* adjust the scripts at build time so set the right sys.path
Nasty as it is, I incline towards the latter: if nothing else, it's more portable!
But this is all speculative. The immediate aim of the Distutils is *not* full-blown Python applications, but I am starting to see how we could support such applications. A little idle speculation never hurt anyone.
That's an artifact of your code ;-). If you figured it out once, you stand at least a 50% chance of getting the same answer a second time <.5 wink>.
What!?! Are you accusing me of writing complex code? Well... ok... maybe a little bit... but only in install.py, really... the rest of it's quite straightforward!