[Distutils] distutils and the development process
Thu, 24 Feb 2000 06:42:06 -0800 (PST)
Greg Ward discourseth:
> The idea of the build directory is that you just do this:
> export PYTHONPATH=build/lib:build/platlib
> while you're in the develop-test-debug cycle for extension modules.
Sounds good. :)
> > I'm also curious how people like to run test scripts. One special
> > case is post-install hello-world-type example programs for the
> > installer to play with. To keep mine from being confused by the
> > package source directory, I end up adding the following to them:
> That sounds like a "demo script" to me, but that's just quibbling over
> semantics. I simply don't understand what you mean by "confused by the
> package source directory". Please explain.
OK. A recipient of my MIDI stream parser package (called `MIDI')
installs via distutils. They're still in the distribution directory
and want to run a demo script to see that things are working. The
script does `import MIDI'..
Traceback (innermost last):
File "./test.py", line 9, in ?
File "./MIDI/__init__.py", line 1, in ?
In = __import__('MIDI.In').In.MidiIn
File "./MIDI/In.py", line 27, in ?
_midi = __import__('MIDI._In')
ImportError: No module named _In
The script went to the source directory (MIDI) and, of course, didn't
find the extension module.
> > # Ugh..make sure we look only in system directories for the package.
> > # This is only important when executing a script in the package
> > # distribution directory.
> > import sys
> > sys.path = sys.path[1:]
> Ugh, barf, blechh indeed. Why *ever* do you need to do this?
Well, it makes the script work. As I said, I'm sure there must be a
better way. :)