[Zope-Checkins] CVS: Zope2 - compile_all.py:1.1.2.2 compilezpy.py:1.5.158.1
evan@serenade.digicool.com
evan@serenade.digicool.com
Thu, 19 Apr 2001 16:46:17 -0400
Update of /cvs-repository/Zope2/inst
In directory serenade.digicool.com:/home/evan/Zope/trunk/inst
Modified Files:
Tag: evan-makefile-branch
compile_all.py compilezpy.py
Log Message:
Allow directories to opt out of module compilation with a .no_pycompile file.
--- Updated File compile_all.py in package Zope2 --
--- compile_all.py 2001/04/19 19:46:19 1.1.2.1
+++ compile_all.py 2001/04/19 20:45:47 1.1.2.2
@@ -97,9 +97,7 @@
import compilezpy
import build_extensions
- user=group=''
- import default_content; default_content.main(home, user, group)
-
+
print '-'*78
print
print 'Done! Use "make install" to set up your instance home.'
--- Updated File compilezpy.py in package Zope2 --
--- compilezpy.py 1999/07/23 19:37:27 1.5
+++ compilezpy.py 2001/04/19 20:45:47 1.5.158.1
@@ -83,17 +83,55 @@
#
##############################################################################
-import compileall, os, sys
+import compileall, os, sys, stat, py_compile
-class Shutup:
- def write(*args): pass # :)
-
print
print '-'*78
print 'Compiling python modules'
-stdout=sys.stdout
-try:
- sys.stdout=Shutup()
- compileall.compile_dir(os.getcwd())
-finally:
- sys.stdout=stdout
+
+# Copied from compileall.py, without 'print' statements.
+# Added check for '.no_pycompile'.
+def compile_dir(dir, maxlevels=10, ddir=None):
+ """Byte-compile all modules in the given directory tree."""
+ try:
+ names = os.listdir(dir)
+ except os.error:
+ return
+ names.sort()
+ if '.no_pycompile' in names:
+ return 1
+ success = 1
+ for name in names:
+ fullname = os.path.join(dir, name)
+ if ddir:
+ dfile = os.path.join(ddir, name)
+ else:
+ dfile = None
+ if os.path.isfile(fullname):
+ head, tail = name[:-3], name[-3:]
+ if tail == '.py':
+ cfile = fullname + (__debug__ and 'c' or 'o')
+ ftime = os.stat(fullname)[stat.ST_MTIME]
+ try: ctime = os.stat(cfile)[stat.ST_MTIME]
+ except os.error: ctime = 0
+ if (ctime > ftime): continue
+ try:
+ py_compile.compile(fullname, None, dfile)
+ except KeyboardInterrupt:
+ raise KeyboardInterrupt
+ except:
+ print 'Compilation of "%s" failed.' % dfile
+ success = 0
+ elif (maxlevels > 0 and
+ name != os.curdir and name != os.pardir and
+ os.path.isdir(fullname) and
+ not os.path.islink(fullname)):
+ compile_dir(fullname, maxlevels - 1, dfile)
+ return success
+
+if not compile_dir(os.getcwd()):
+ print
+ print '!' * 78
+ print 'There were errors during module compilation.'
+ print '!' * 78
+ print