~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-04 17:52:34 UTC
  • mfrom: (4584.1.3 bzr.exe-qtimages)
  • Revision ID: pqm@pqm.ubuntu.com-20090804175234-3e4oyzlwy1rb3mnj
(bialix) Include the image format plugins in the win32 all-in-one
        installer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
BZRLIB['packages'] = get_bzrlib_packages()
94
94
 
95
95
 
 
96
from distutils import log
96
97
from distutils.core import setup
97
98
from distutils.command.install_scripts import install_scripts
98
99
from distutils.command.install_data import install_data
400
401
    data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x64.dll')]))
401
402
 
402
403
 
403
 
def get_qbzr_py2exe_info(includes, excludes, packages):
 
404
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
404
405
    # PyQt4 itself still escapes the plugin detection code for some reason...
405
406
    packages.append('PyQt4')
406
407
    excludes.append('PyQt4.elementtree.ElementTree')
414
415
        QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
415
416
        qscintilla2.dll""".split())
416
417
    # the qt binaries might not be on PATH...
417
 
    qt_dir = os.path.join(sys.prefix, "PyQt4", "bin")
418
 
    path = os.environ.get("PATH","")
419
 
    if qt_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
420
 
        os.environ["PATH"] = path + os.pathsep + qt_dir
 
418
    # They seem to install to a place like C:\Python25\PyQt4\*
 
419
    # Which is not the same as C:\Python25\Lib\site-packages\PyQt4
 
420
    pyqt_dir = os.path.join(sys.prefix, "PyQt4")
 
421
    pyqt_bin_dir = os.path.join(pyqt_dir, "bin")
 
422
    if os.path.isdir(pyqt_bin_dir):
 
423
        path = os.environ.get("PATH", "")
 
424
        if pyqt_bin_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
 
425
            os.environ["PATH"] = path + os.pathsep + pyqt_bin_dir
 
426
    # also add all imageformat plugins to distribution
 
427
    # We will look in 2 places, dirname(PyQt4.__file__) and pyqt_dir
 
428
    base_dirs_to_check = []
 
429
    if os.path.isdir(pyqt_dir):
 
430
        base_dirs_to_check.append(pyqt_dir)
 
431
    try:
 
432
        import PyQt4
 
433
    except ImportError:
 
434
        pass
 
435
    else:
 
436
        pyqt4_base_dir = os.path.dirname(PyQt4.__file__)
 
437
        if pyqt4_base_dir != pyqt_dir:
 
438
            base_dirs_to_check.append(pyqt4_base_dir)
 
439
    if not base_dirs_to_check:
 
440
        log.warn("Can't find PyQt4 installation -> not including imageformat"
 
441
                 " plugins")
 
442
    else:
 
443
        files = []
 
444
        for base_dir in base_dirs_to_check:
 
445
            plug_dir = os.path.join(base_dir, 'plugins', 'imageformats')
 
446
            if os.path.isdir(plug_dir):
 
447
                for fname in os.listdir(plug_dir):
 
448
                    # Include plugin dlls, but not debugging dlls
 
449
                    fullpath = os.path.join(plug_dir, fname)
 
450
                    if fname.endswith('.dll') and not fname.endswith('d4.dll'):
 
451
                        files.append(fullpath)
 
452
        if files:
 
453
            data_files.append(('imageformats', files))
 
454
        else:
 
455
            log.warn('PyQt4 was found, but we could not find any imageformat'
 
456
                     ' plugins. Are you sure your configuration is correct?')
421
457
 
422
458
 
423
459
def get_svn_py2exe_info(includes, excludes, packages):
600
636
    data_files = topics_files + plugins_files
601
637
 
602
638
    if 'qbzr' in plugins:
603
 
        get_qbzr_py2exe_info(includes, excludes, packages)
 
639
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
604
640
 
605
641
    if 'svn' in plugins:
606
642
        get_svn_py2exe_info(includes, excludes, packages)