[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Use Zooko"s zlibutil to do bounded uncompression with P...



Update of /home/minion/cvsroot/src/minion
In directory moria.mit.edu:/tmp/cvs-serv4240

Modified Files:
	MANIFEST.in Makefile TODO setup.py 
Log Message:
Use Zooko's zlibutil to do bounded uncompression with Python < 2.2.

Add a hack to setup.py to support multiple builds at once.


Index: MANIFEST.in
===================================================================
RCS file: /home/minion/cvsroot/src/minion/MANIFEST.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- MANIFEST.in	31 Dec 2002 04:41:03 -0000	1.3
+++ MANIFEST.in	31 Dec 2002 17:40:54 -0000	1.4
@@ -1,6 +1,6 @@
 include README HACKING LICENSE Makefile TODO pycheckrc
-include contrib/unittest.py
-include etc/mixminiond.conf
+include contrib/unittest.py contrib/zlibutil.py
+include etc/mixminiond.conf 
 # Old versions of distutils miss header files
 include src/_minionlib.h
 # Not used yet:

Index: Makefile
===================================================================
RCS file: /home/minion/cvsroot/src/minion/Makefile,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Makefile	31 Dec 2002 04:40:28 -0000	1.22
+++ Makefile	31 Dec 2002 17:40:54 -0000	1.23
@@ -57,6 +57,7 @@
 	rm -rf build dist
 	rm -f lib/mixminion/_unittest.py
 	rm -f lib/mixminion/_textwrap.py
+	rm -f lib/mixminion/_zlibutil.py
 	rm -f lib/mixminion/*.pyc
 	rm -f lib/mixminion/*.pyo
 	rm -f lib/mixminion/*/*.pyc
@@ -66,13 +67,13 @@
 
 test: do_build
 	@$(FINDPYTHON); \
-	echo $$PYTHON -tt build/lib*/mixminion/Main.py unittests; \
-	($$PYTHON -tt build/lib*/mixminion/Main.py unittests)
+	echo $$PYTHON setup.py run --subcommand=unittests; \
+	$$PYTHON setup.py run --subcommand=unittests
 
 time: do_build
 	@$(FINDPYTHON); \
-	echo $$PYTHON -tt build/lib*/mixminion/Main.py benchmarks; \
-	($$PYTHON -tt build/lib*/mixminion/Main.py benchmarks)
+	echo $$PYTHON setup.py run --subcommand=benchmarks; \
+	$$PYTHON setup.py run --subcommand=benchmarks
 
 #======================================================================
 # Install target (minimal.)

Index: TODO
===================================================================
RCS file: /home/minion/cvsroot/src/minion/TODO,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- TODO	31 Dec 2002 04:53:09 -0000	1.45
+++ TODO	31 Dec 2002 17:40:54 -0000	1.46
@@ -37,7 +37,7 @@
 			o Tests for BuildMessage functionality
 			o Tests for ModuleManager functionality
 			o Mention in the spec.
-			- Arg! Make space-bound zlib work under Python <2.2.
+			o Arg! Make space-bound zlib work under Python <2.2.
 		o Timeout connections.
 			o Implement timeout logic in MMTPServer
 			o Implement in ServerMain
@@ -160,7 +160,7 @@
 			- Hunt down leaks
 	- Build and install process
 	  	- The version string should be given in only one place
-		- Use sane arguments when testing with multiple python versions
+		o Use sane arguments when testing with multiple python versions
 		o Get SSL as needed
 		- Well-tested 'make install'
 		- RPMS, debs, and so on

Index: setup.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/setup.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- setup.py	31 Dec 2002 04:42:15 -0000	1.18
+++ setup.py	31 Dec 2002 17:40:54 -0000	1.19
@@ -45,12 +45,17 @@
 except:
     shutil.copy("contrib/unittest.py", "lib/mixminion/_unittest.py")
 
-# Install textwrap if python doesn't provide it. (This goes for all python<2.3)
+# Install textwrap if Python doesn't provide it. (This goes for all python<2.3)
 try:
     import textwrap
 except:
     shutil.copy("contrib/textwrap.py", "lib/mixminion/_textwrap.py")
 
+# If we have a version of Python older than 2.2, we can't do bounded-space
+# decompression without magic.  That magic is written by Zooko.
+if sys.version_info[:3] < (2,2,0):
+    shutil.copy("contrib/zlibutil.py", "lib/mixminion/_zlibutil.py")
+
 #======================================================================
 # Detect endian-ness
 
@@ -106,11 +111,42 @@
 f.close()
 
 #======================================================================
+# Define a helper to let us run commands from the compiled code.
+from distutils.core import Command
+
+class runMMCommand(Command):
+    # Based on setup.py from Zooko's pyutil package, which is in turn based on
+    # http://mail.python.org/pipermail/distutils-sig/2002-January/002714.html
+    description = "Run a subcommand from mixminion.Main"
+    user_options = [
+        ('subcommand=', None, 'Subcommand to run')]
+
+    def initialize_options(self):
+        self.subcommand = "unittests"
+        
+    def finalize_options(self):
+        build = self.get_finalized_command('build')
+        self.build_purelib = build.build_purelib
+        self.build_platlib = build.build_platlib
+        
+    def run(self):
+        self.run_command('build')
+        old_path = sys.path
+        sys.path[0:0] = [ self.build_purelib, self.build_platlib ]
+        try:
+            minion = __import__("mixminion.Main", globals(), "", [])
+            minion.Main.main(["mixminion.Main", self.subcommand])
+        finally:
+            sys.path = old_path
+        
+#======================================================================
 # Now, tell setup.py how to cope.
 import distutils.core
 from distutils.core import setup, Extension
 from distutils import sysconfig
 
+
+
 INCLUDE_DIRS.append("src")
 
 extmodule = Extension("mixminion._minionlib",
@@ -131,7 +167,8 @@
       package_dir={ '' : 'lib' },
       packages=['mixminion', 'mixminion.server', 'mixminion.directory'],
       scripts=[SCRIPT_PATH],
-      ext_modules=[extmodule])
+      ext_modules=[extmodule],
+      cmdclass={'run': runMMCommand})
 
 try:
     os.unlink(SCRIPT_PATH)