~ubuntu-branches/ubuntu/trusty/python-distutils-extra/trusty-proposed

« back to all changes in this revision

Viewing changes to DistUtilsExtra/command/build_kdeui.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-02-11 10:39:50 UTC
  • mfrom: (18.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110211103950-kseoijf2ilwdr3rr
Tags: 2.24-1
* auto.py: Fix the string comparison to not install *.notifyrc.in files
  twice. Thanks Éric Araujo for spotting this!
* DistUtilsExtra/auto.py, __provides(): Do not accidentally clobber
  "py_modules" with "packages", by using a proper copy of the list. Remove
  error filter workaround from test/auto.py.
* Rename "check" command to "pylint", to avoid clobbering distutils' own
  check command in 2.7/3.x. (LP: #714655)
* DistUtilsExtra/auto.py, DistUtilsExtra/command/__init__.py: Actually
  expose the pylint command as a setup.py command.
* Remove pykdeuic4 integration, it's been a continuous source of build
  failures and bugs. Using uic.loadUi() is much more robust.
  Instead, install Qt *.ui files into /usr/share/projectname/ just like the
  GtkBuilder *.ui files.
* debian/compat, debian/control: Bump to dh 7 compatibility, as we are using
  dh_auto_* magic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""distutils_extra.command.build_kdeui
2
 
 
3
 
Implement DistutilsExtra's 'build_kdeui' command.
4
 
"""
5
 
 
6
 
# Created by Martin Pitt
7
 
 
8
 
import subprocess
9
 
import os.path
10
 
import distutils.dir_util
11
 
 
12
 
class build_kdeui(distutils.cmd.Command):
13
 
 
14
 
    description = "compile KDE .ui files to .py with pykdeuic4"
15
 
 
16
 
    user_options= [('ui-files=', 'u', '.ui files that should be built'),
17
 
            ('ui-package=', 'p', 'Python package name for the generated .py files'),
18
 
            ]
19
 
 
20
 
    def initialize_options(self):
21
 
        self.ui_files = None
22
 
        self.ui_package = None
23
 
 
24
 
    def finalize_options(self):
25
 
        if not self.ui_files:
26
 
            return
27
 
        if self.ui_package is None:
28
 
            self.ui_package = '%s.kdeui' % self.distribution.get_name()
29
 
 
30
 
        self.destdir = os.path.join('build', 'kdeui', *self.ui_package.split('.'))
31
 
        if self.distribution.package_dir is None:
32
 
            self.distribution.package_dir = {}
33
 
        self.distribution.package_dir[self.ui_package] = self.destdir
34
 
        self.distribution.packages.append(self.ui_package)
35
 
 
36
 
    def run(self):
37
 
        if not self.ui_files:
38
 
            return
39
 
 
40
 
        distutils.dir_util.mkpath(self.destdir)
41
 
        init = os.path.join(self.destdir, '__init__.py')
42
 
        if not os.path.exists(init):
43
 
            open(init, 'w').close()
44
 
 
45
 
        for f in eval(self.ui_files):
46
 
            dest = os.path.join(self.destdir,
47
 
                    os.path.splitext(os.path.basename(f))[0] + '.py')
48
 
            print 'kdeui: %s -> %s' % (f, dest)
49
 
            result = subprocess.call(['python', '/usr/bin/pykdeuic4', '-o', dest, f])
50
 
            if result != 0:
51
 
                raise SystemError('The KDE .ui file %s can not be converted' % f)
52