Rev 5361: (garyvdm, gz) Hack py2exe so that we can have a library.zip built with in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Jul 26 12:51:32 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5361 [merge]
revision-id: pqm at pqm.ubuntu.com-20100726115129-2uy7vwm0v2ergzk3
parent: pqm at pqm.ubuntu.com-20100724001123-fexv81gfn5j94yif
parent: garyvdm at gmail.com-20100726101532-yrej0schgb4xfbwj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-07-26 12:51:29 +0100
message:
  (garyvdm, gz) Hack py2exe so that we can have a library.zip built with
  	optimize=2, but every thing else has optimize=1.
modified:
  setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
=== modified file 'setup.py'
--- a/setup.py	2010-07-05 14:16:45 +0000
+++ b/setup.py	2010-07-26 10:15:32 +0000
@@ -694,13 +694,24 @@
                                "optimize": 2,
                               },
                    }
+
+    # We want the libaray.zip to have optimize = 2, but the exe to have
+    # optimize = 1, so that .py files that get compilied at run time
+    # (e.g. user installed plugins) dont have their doc strings removed.
+    class py2exe_no_oo_exe(py2exe.build_exe.py2exe):
+        def build_executable(self, *args, **kwargs):
+            self.optimize = 1
+            py2exe.build_exe.py2exe.build_executable(self, *args, **kwargs)
+            self.optimize = 2
+
     if __name__ == '__main__':
         setup(options=options_list,
               console=console_targets,
               windows=gui_targets,
               zipfile='lib/library.zip',
               data_files=data_files,
-              cmdclass={'install_data': install_data_with_bytecompile},
+              cmdclass={'install_data': install_data_with_bytecompile,
+                        'py2exe': py2exe_no_oo_exe},
               )
 
 else:




More information about the bazaar-commits mailing list