cutehg / setup.py

#!/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 compile_qrc(self, qrc_file, py_file):
     # Search for pyuic4 in python bin dir, then in the $Path.
        try:
            import subprocess
            rccprocess = subprocess.Popen(['pyrcc4', qrc_file, '-o', py_file])
            rccprocess.wait()
        except Exception, e:
            print 'Unable to compile resouce file', 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) )

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

        self.compile_qrc( 'cutehg/icons/icons.qrc', 'cutehg/icons_rc.py' )
        import shutil
        shutil.copyfile( 'cutehg/icons_rc.py', 'cutehg/dialogs/icons_rc.py' )
        shutil.copyfile( 'cutehg/icons_rc.py', 'cutehg/views/icons_rc.py' )
        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.views', 'cutehg.views.models'],
    url='http://www.bitbucket.org/bfrog/cutehg',
    )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.