[PATCH 1 of 2 RFC] setup: add command to generate index of extensions

Yuya Nishihara yuya at tcha.org
Sun Jun 5 02:36:27 CDT 2011


Martin Geisler wrote:
> Yuya Nishihara <yuya at tcha.org> writes:
> 
> > +class buildhgextindex(Command):
> > +    description = 'generate prebuilt index of hgext (for frozen package)'
> > +    user_options = []
> > +    _indexfilename = 'hgext/__index__.py'
> > +
> > +    def initialize_options(self):
> > +        pass
> > +
> > +    def finalize_options(self):
> > +        pass
> > +
> > +    def run(self):
> > +        if os.path.exists(self._indexfilename):
> > +            os.unlink(self._indexfilename)
> > +
> > +        # here no extension enabled, disabled() lists up everything
> > +        code = ('import pprint; from mercurial import extensions; '
> > +                'pprint.pprint(extensions.disabled())')
> > +        out, err = runcmd([sys.executable, '-c', code], env)
> 
> Is there a reason that you don't just run the Python code in the Python
> process that runs setup.py?

Yes, it needs to disable gettext. Though it can be achieved by the following
code, but I don't think good idea to depend on import order:

    os.environ['LANGUAGE'] = 'C'
    from mercurial import extensions  # here gettext is instantiated
    docs = extensions.disabled()
    ...
    # restore os.environ['LANGUAGE'] ?

Regards,
Yuya


More information about the Mercurial-devel mailing list