Changeset 10793:35713869d753 in orange for setup.py


Ignore:
Timestamp:
04/14/12 14:15:47 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Don't fail if orangeqt's setup.py can't be imported (due to a missing PyQt4).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r10792 r10793  
    118118 
    119119# Get the command for building orangeqt extension from 
    120 # source/orangeqt/setup.py file 
     120# source/orangeqt/setup.py file. 
     121# Fails  without PyQt4. 
    121122import imp 
    122 orangeqt_setup = imp.load_source("orangeqt_setup", "source/orangeqt/setup.py") 
    123  
    124 build_pyqt_ext = orangeqt_setup.build_pyqt_ext 
     123try: 
     124    orangeqt_setup = imp.load_source("orangeqt_setup", "source/orangeqt/setup.py") 
     125    build_pyqt_ext = orangeqt_setup.build_pyqt_ext 
     126except ImportError: 
     127    orangeqt_setup = None 
     128    build_pyqt_ext = None 
    125129 
    126130class LibStatic(Extension): 
     
    181185            # Build pyextract extension 
    182186            self.build_pyxtract(ext) 
    183         elif isinstance(ext, orangeqt_setup.PyQt4Extension): 
     187        elif orangeqt_setup and isinstance(ext, orangeqt_setup.PyQt4Extension): 
    184188            # Skip the build (will be handled by build_pyqt_ext command) 
    185189            return 
     
    459463#                   ) 
    460464 
    461     sub_commands = build.sub_commands + \ 
    462                    [("build_pyqt_ext", has_pyqt_extensions)] 
     465    sub_commands = build.sub_commands 
     466    if orangeqt_setup: 
     467        sub_commands += [("build_pyqt_ext", has_pyqt_extensions)] 
    463468 
    464469 
     
    620625 
    621626 
    622 orangeqt_ext = orangeqt_setup.orangeqt_ext 
    623 # Fix relative paths, name etc. 
    624 orangeqt_ext.name = "Orange.orangeqt" 
    625 orangeqt_ext.sources = ["source/orangeqt/orangeqt.sip"] + \ 
    626                        get_source_files("source/orangeqt", "cpp", 
    627                             exclude=["canvas3d.cpp", "plot3d.cpp",  
    628                                      "glextensions.cpp"] 
    629                                         ) 
    630 orangeqt_ext.include_dirs += ["source/orangeqt"] 
     627ext_modules = [include_ext, orange_ext, orangeom_ext, 
     628               orangene_ext, corn_ext, statc_ext] 
     629 
     630cmdclass = {"build": orange_build, 
     631            "build_ext": pyxtract_build_ext, 
     632            "install_lib": orange_install_lib, 
     633            "install": orange_install} 
     634                     
     635if orangeqt_setup: 
     636    orangeqt_ext = orangeqt_setup.orangeqt_ext 
     637    # Fix relative paths, name etc. 
     638    orangeqt_ext.name = "Orange.orangeqt" 
     639    orangeqt_ext.sources = ["source/orangeqt/orangeqt.sip"] + \ 
     640                           get_source_files("source/orangeqt", "cpp", 
     641                                exclude=["canvas3d.cpp", "plot3d.cpp",  
     642                                         "glextensions.cpp"] 
     643                                            ) 
     644 
     645    orangeqt_ext.include_dirs += ["source/orangeqt"] 
     646 
     647    ext_modules += [orangeqt_ext] 
     648 
     649    cmdclass["build_pyqt_ext"] = build_pyqt_ext 
     650 
    631651 
    632652def get_packages(): 
     
    728748        a.close() 
    729749 
    730 ext_modules = [include_ext, orange_ext, orangeom_ext, 
    731                orangene_ext, corn_ext, statc_ext, 
    732                orangeqt_ext 
    733                ] 
    734750 
    735751def setup_package(): 
     
    746762          license = LICENSE, 
    747763          keywords = KEYWORDS, 
    748  
    749           cmdclass={"build": orange_build, 
    750                     "build_ext": pyxtract_build_ext, 
    751                     "build_pyqt_ext": build_pyqt_ext, 
    752                     "install_lib": orange_install_lib, 
    753                     "install": orange_install}, 
     764          cmdclass=cmdclass, 
    754765          packages = get_packages(), 
    755766          package_data = get_package_data(), 
Note: See TracChangeset for help on using the changeset viewer.