Show
Ignore:
Timestamp:
04/01/03 10:33:35 (6 years ago)
Author:
arjanmol
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gaphor/setup.py

    r191 r193  
    3737 
    3838    user_options = [ 
    39         ('pkg-config=', None, 'Path to pkg-config'), 
     39        #('pkg-config=', None, 'Path to pkg-config'), 
    4040    ] 
    4141 
    42     pkg_config_checked=False 
    43     config_failed=False 
     42    #pkg_config_checked=False 
     43    config_failed=[] 
    4444 
    4545    def initialize_options(self): 
    46         self.pkg_config = 'pkg-config' 
     46        #self.pkg_config = 'pkg-config' 
     47        pass 
    4748 
    4849    def finalize_options(self): 
    4950        # Check for existence of pkg-config 
    50         status, output = getstatusoutput('%s --version' % self.pkg_config) 
    51         if status != 0: 
    52             print 'pkg-config not found.' 
    53             raise SystemExit 
    54         print 'Found pkg-config version %s' % output 
     51        #status, output = getstatusoutput('%s --version' % self.pkg_config) 
     52        #if status != 0: 
     53        #    print 'pkg-config not found.' 
     54        #    raise SystemExit 
     55        #print 'Found pkg-config version %s' % output 
     56        pass 
    5557 
    5658    def run(self): 
     
    6466 
    6567        self.module_check('xml.parsers.expat') 
    66         self.module_check('gobject') 
     68        #self.module_check('gobject', 'glib_version', (2, 0)) 
     69        self.module_check('gtk', 'gtk_version', (2, 0), 
     70                                 'pygtk_version', (1, 99, 16)) 
    6771        self.module_check('gnome') 
    6872        self.module_check('gnome.ui') 
     
    7175        self.module_check('bonobo.ui') 
    7276        self.module_check('gconf') 
    73         self.module_check('diacanvas') 
    74  
     77        self.module_check('diacanvas', 'diacanvas_version', (0, 9, 2)) 
     78 
     79        print '' 
    7580        if self.config_failed: 
    7681            print 'Config failed.' 
     82            print 'The following modules can not be found or are to old:' 
     83            print ' ', str(self.config_failed)[1:-1] 
     84            print '' 
    7785            raise SystemExit 
     86        else: 
     87            print 'Config succeeded.' 
     88            print 'You can run Gaphor by typing: python setup.py run' 
    7889 
    7990    def pkg_config_check(self, package, version): 
     
    8293        if retval: 
    8394            print '!!! Required package %s not found.' % package 
    84             self.config_failed = True 
     95            self.config_failed.append(package) 
    8596            return 
    8697        pkg_version_str = getoutput('%s --modversion %s' % (self.pkg_config, package)) 
     
    91102        else: 
    92103            print "!!! Package '%s' has version %s, should have at least version %s." % ( package, pkg_version_str, version ) 
    93             self.config_failed = True 
    94  
    95     def module_check(self, module): 
     104            self.config_failed.append(package) 
     105 
     106    def module_check(self, module, *version_checks): 
     107        """Check for the availability of a module. 
     108 
     109        version_checks is a set of ket/version pairs that should be true. 
     110        """ 
    96111        try: 
    97             __import__(module) 
     112            mod = __import__(module) 
    98113        except ImportError: 
    99114            print "!!! Required module '%s' not found." % module 
    100             self.config_failed = True 
     115            self.config_failed.append(module) 
    101116        else: 
    102117            print "Module '%s' found." % module 
    103  
     118            while version_checks: 
     119                self.version_check(mod, version_checks[0], version_checks[1]) 
     120                version_checks = version_checks[2:] 
     121 
     122    def version_check(self, module, key, ver): 
     123        import string 
     124        s_ver = string.join(map(str, ver), '.') 
     125        print "  Checking key '%s.%s' >= %s..." % (module.__name__, key, s_ver), 
     126        try: 
     127            modver = getattr(module, key) 
     128        except: 
     129            print "Not found." % key 
     130            self.config_failed.append(module.__name__) 
     131        else: 
     132            s_modver = string.join(map(str, modver), '.') 
     133            if modver >= ver: 
     134                print "Okay (%s)." % s_modver 
     135            else: 
     136                print "Failed (%s)" % s_modver 
     137                self.config_failed.append(module.__name__) 
    104138 
    105139class build_py_Gaphor(build_py):