Rev 5067: (spiv) Hack py2exe so that we can have a library.zip built with optimize=2, in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jul 29 10:28:11 BST 2010


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5067 [merge]
revision-id: pqm at pqm.ubuntu.com-20100729092809-ppsnhr9bx1nnavti
parent: pqm at pqm.ubuntu.com-20100729081141-5sryhxyfat6g1ygo
parent: garyvdm at gmail.com-20100726101532-yrej0schgb4xfbwj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Thu 2010-07-29 10:28:09 +0100
message:
  (spiv) Hack py2exe so that we can have a library.zip built with optimize=2,
   but every thing else has optimize=1 (Gary van der Merwe)
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