[PATCH] Force pygments package to be loaded in py2exe

Benoit Boissinot benoit.boissinot at ens-lyon.org
Tue Jan 27 15:51:13 CST 2009


On Tue, Jan 27, 2009 at 10:42:43PM +0100, Pascal Quantin wrote:
> # 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

Seems good. Can you add a comment in setup.py ?

And please do not use lines with more than 78/80 chars in your commit
message.

Thanks,

Benoit
> 
> 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',

-- 
:wq


More information about the Mercurial-devel mailing list