Path caching when running multiple commands
I've written a script to apply a command across a bunch of setup.py scripts in a subdirectory, and found a problem: distutils.dir_utils._path_cache stores a list of directories that have already been created. The directory name is just stored as 'dist', not a full path name, so if two subdirectories need to create a 'dist' directory, the second one thinks it's already been created, and dies.
Fix: storing full path names in the cache seems reasonable.
(The setup.py script is included below, since it may be instructive; feel free to use it as an example.)
# Top-level script for running a command-line over all the subpackages
import sys, os, glob from distutils.core import run_setup
files = os.listdir('.') dirs = filter(os.path.isdir, files) packages =  for dir in dirs: if os.path.exists( os.path.join( dir, 'setup.py') ): packages.append( dir )
top_dir = os.getcwd() for package_dir in packages: print 'Running', package_dir os.chdir( package_dir ) dist = run_setup('setup.py', script_args=sys.argv[1:], stop_after="run") os.chdir( top_dir )