Source

cutehg / setup.py

Full commit
#!/usr/bin/env python

#author tom

import os
import dircache
import distutils.core
import distutils.util
from distutils.command.build import build


class CuteHgBuild(build):
    def compile_ui(self, ui_file, py_file):
        # Search for pyuic4 in python bin dir, then in the $Path.
        try:
            from PyQt4 import uic
            fp = open(py_file, 'w')
            uic.compileUi(ui_file, fp)
            fp.close()
        except Exception, e:
            print 'Unable to compile user interface', e
            return

    def run(self):
        ui_files = dircache.listdir('cutehg/ui')
        for filename in ui_files:
            name = filename.split('.')[0]
            if not os.path.exists( ('cutehg/dialogs/ui_%s.py' % name) ):
                self.compile_ui( ('cutehg/ui/%s.ui' % name), ('cutehg/dialogs/ui_%s.py' % name) )
        build.run(self)


distutils.core.setup(
    name='cutehg',
    version='0.02',
    description='Qt4 Dialog extension to Mercurial',
    author="Tom Burdick",
    author_email='thomas.burdick@gmail.com',
    license='GNU GPL2',
    cmdclass = { 'build' : CuteHgBuild }, # define custom build class
    platforms='All',
    packages=['cutehg', 'cutehg.dialogs', 'cutehg.vcsmodel'],
    url='http://www.bitbucket.org/bfrog/cutehg',
    )