[Zope-Checkins] CVS: Zope3 - stupid_build.py:1.1.2.4
Guido van Rossum
guido@python.org
Wed, 5 Dec 2001 16:32:06 -0500
Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv32363
Modified Files:
Tag: Zope-3x-branch
stupid_build.py
Log Message:
There were so many little violations of good taste here that I decided
to rewrite it. :-)
Move the mainline into a main() function. Let the visit() function
collect a list of directories that contain a setup.py script. Don't
put things in local variables for efficiency. Don't pass the absolute
pathname of the setup.py script -- we chdir() to each directory
anyway.
=== Zope3/stupid_build.py 1.1.2.3 => 1.1.2.4 ===
import sys, os
-executable = sys.executable
-setup_files = []
-def visit(setup_files, dirname, names):
+
+def visit(setup_dirs, dirname, names):
if 'setup.py' in names:
- setup_files.append(dirname + os.sep + 'setup.py')
+ setup_dirs.append(dirname)
+
+def main():
+ setup_dirs = []
+ os.path.walk(os.getcwd(), visit, setup_dirs)
+ for dir in setup_dirs:
+ print "Building extensions in %s" % dir
+ os.chdir(dir)
+ os.spawnl(os.P_WAIT, sys.executable,
+ sys.executable, "setup.py", 'build_ext', '-i', 'clean')
+ print
-cwd = os.getcwd()
-os.path.walk(cwd, visit, setup_files)
-for file in setup_files:
- print "Building extensions in %s" % file
- p = file.split('/')[:-1]
- os.chdir('/'.join(p))
- os.spawnl(os.P_WAIT, executable, executable, file,
- 'build_ext', '-i', 'clean')
- print
+if __name__ == "__main__":
+ main()