[PATCH] Force pygments package to be loaded in py2exe

Pascal Quantin pascal.quantin at gmail.com
Tue Jan 27 15:42:43 CST 2009


# HG changeset patch
# User Pascal Quantin <pascal.quantin at gmail.com>
# Date 1233089606 -3600
# Node ID 87d4115806b006f9080eb5c36958274feb023ac9
# Parent  97b55cce3100d3b408cda75b96dabdd5be92dd6a
Force pygments package to be loaded in py2exe

Like with email package, the pygments package is not fully loaded by py2exe due to Python2.5 dynamic imports which are not found by modulefinder. This breaks the highlight extension.
-> Force the pygments package to be included if installed so that the dynamic imports work as expected.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -188,6 +188,13 @@
         datafiles.append((os.path.join('mercurial', dir),
                           [os.path.join(dir, file_) for file_ in files]))
 
+packaging = ['hgext', 'email']
+try:
+    import pygments
+    packaging.append('pygments')
+except ImportError:
+    pass
+
 setup(name='mercurial',
       version=version,
       author='Matt Mackall',
@@ -200,7 +207,7 @@
       ext_modules=ext_modules,
       data_files=datafiles,
       cmdclass=cmdclass,
-      options=dict(py2exe=dict(packages=['hgext', 'email']),
+      options=dict(py2exe=dict(packages=packaging),
                    bdist_mpkg=dict(zipdist=True,
                                    license='COPYING',
                                    readme='contrib/macosx/Readme.html',


More information about the Mercurial-devel mailing list