[Distutils] distutils and the development process

Greg Ward gward@python.net
Wed, 23 Feb 2000 22:24:44 -0500

On 23 February 2000, est@hyperreal.org said:
> I'd like to be able to use distutil's build process while I'm
> developing and debugging code.  This has proven difficult so far
> because of the use of the build directory.  I've ended up just using
> Makefile-driven in-place builds during the development cycle.  Does
> anyone have any tips or tricks in this area?

As they say in the trade, "That's not a bug -- that's a feature!"

But seriously: what *about* the build directory is causing you problems?
My current thinking is to put *everything* somewhere in the build
directory, leaving the source tree pristine.  I.e., .o or .obj files
would go in build/tmp.<plat>, along with the surprise compiler turds
that Visual C++ leaves behind.  (When you think about it, .o and .obj
files are really just compiler turds too -- but we all expect them from
years of experience.)

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.
Just make sure you stay in the root of the source tree.

You can work this way too for pure Python modules if you *want*, but
there's no good reason to.  If your source tree is laid out in a
sensible way (like Distutils, of course, or PyXML), then you don't have
to do anything special -- eg. when I'm hacking on Distutils, I just let
Python find distutils.core as distutils/core.py under the Distutils
source root.  No problem.

> 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.

> # 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?

Greg Ward - Linux weenie                                gward@python.net
The NSA.  We care: we listen to our customers.