Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

setup.py: add PyQt support.

Changeset 04b0a5411e88

Parent 8fcd84b6ed1a

by Toshi MARUYAMA

Changes to one file · Browse files at 04b0a5411e88 Showing diff from parent 8fcd84b6ed1a Diff from another changeset...

Change 1 of 3 Show Entire File setup.py Stacked
 
14
15
16
 
17
18
19
 
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
53
 
 
 
54
55
56
 
149
150
151
 
152
153
154
 
14
15
16
17
18
19
20
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
86
87
88
89
90
91
 
184
185
186
187
188
189
190
@@ -14,6 +14,7 @@
 from distutils.core import setup  from distutils.command.build import build  from distutils.spawn import spawn, find_executable +from os.path import isdir, exists, join, walk, splitext    thgcopyright = 'Copyright (C) 2010 Steve Borho and others'  hgcopyright = 'Copyright (C) 2005-2010 Matt Mackall and others' @@ -47,10 +48,44 @@
  self.mkpath(modir)   self.make_file([pofile], mofile, spawn, (cmd,))   +class build_qt(build): + def compile_ui(self, ui_file, py_file=None): + # Search for pyuic4 in python bin dir, then in the $Path. + if py_file is None: + py_file = splitext(ui_file)[0] + "_ui.py" + try: + from PyQt4 import uic + fp = open(py_file, 'w') + uic.compileUi(ui_file, fp) + fp.close() + print "compiled", ui_file, "into", py_file + except Exception, e: + print 'Unable to compile user interface', e + return + + def compile_rc(self, qrc_file, py_file=None): + # Search for pyuic4 in python bin dir, then in the $Path. + if py_file is None: + py_file = splitext(qrc_file)[0] + "_rc.py" + if os.system('pyrcc4 "%s" -o "%s"' % (qrc_file, py_file)) > 0: + print "Unable to generate python module for resource file", qrc_file + + def run(self): + for dirpath, _, filenames in os.walk(join('tortoisehg', 'hgqt')): + for filename in filenames: + if filename.endswith('.ui'): + self.compile_ui(join(dirpath, filename)) + elif filename.endswith('.qrc'): + self.compile_rc(join(dirpath, filename)) + build.run(self) + +  build.sub_commands.append(('build_mo', None))    cmdclass = { - 'build_mo': build_mo} + 'build': build_qt , + 'build_mo': build_mo , + }    def setup_windows(version):   # Specific definitios for Windows NT-alike installations @@ -149,6 +184,7 @@
  _extra = {}   _scripts = ['thg', 'hgtk']   _packages = ['tortoisehg', 'tortoisehg.hgtk', + 'tortoisehg.hgqt',   'tortoisehg.hgtk.logview', 'tortoisehg.util']   _data_files = [(os.path.join('share/pixmaps/tortoisehg', root),   [os.path.join(root, file_) for file_ in files])