Changeset 3492

Show
Ignore:
Timestamp:
08/16/08 17:11:25 (5 years ago)
Author:
nopper
Message:

version indipendent

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/PacketManipulator/setup.py

    r3491 r3492  
    2424 
    2525from distutils.core import setup, Extension 
     26from PM.Core.Const import PM_VERSION 
    2627 
    2728def getoutput(cmd): 
    2829    """Return output (stdout or stderr) of executing cmd in a shell.""" 
    29     return getstatusoutput(cmd)[1]                                      
     30    return getstatusoutput(cmd)[1] 
    3031 
    3132def getstatusoutput(cmd): 
    3233    """Return (status, output) of executing cmd in a shell.""" 
    33     if sys.platform == 'win32':                                
    34         pipe = os.popen(cmd, 'r')                              
    35         text = pipe.read()                                     
    36         sts = pipe.close() or 0                                
    37         if text[-1:] == '\n':                                  
    38             text = text[:-1]                                   
    39         return sts, text                                       
    40     else:                                                      
    41         from commands import getstatusoutput                   
    42         return getstatusoutput(cmd)                            
     34    if sys.platform == 'win32': 
     35        pipe = os.popen(cmd, 'r') 
     36        text = pipe.read() 
     37        sts = pipe.close() or 0 
     38        if text[-1:] == '\n': 
     39            text = text[:-1] 
     40        return sts, text 
     41    else: 
     42        from commands import getstatusoutput 
     43        return getstatusoutput(cmd) 
    4344 
    4445def pkgc_version_check(name, longname, req_version): 
    4546    is_installed = not os.system('pkg-config --exists %s' % name) 
    46     if not is_installed:                                          
    47         print "Could not find %s" % longname                      
    48         return 0                                                  
     47    if not is_installed: 
     48        print "Could not find %s" % longname 
     49        return 0 
    4950 
    5051    orig_version = getoutput('pkg-config --modversion %s' % name) 
    51     version = map(int, orig_version.split('.'))                   
    52     pkc_version = map(int, req_version.split('.'))                
     52    version = map(int, orig_version.split('.')) 
     53    pkc_version = map(int, req_version.split('.')) 
    5354 
    5455    if version >= pkc_version: 
    55         return 1               
    56     else:                      
     56        return 1 
     57    else: 
    5758        print "Warning: Too old version of %s" % longname 
    5859        print "         Need %s, but %s is installed" % \ 
    59               (pkc_version, orig_version)                 
    60         self.can_build_ok = 0                             
    61         return 0                                          
     60              (pkc_version, orig_version) 
     61        self.can_build_ok = 0 
     62        return 0 
    6263 
    6364def pkc_get_include_dirs(names): 
    64     if type(names) != tuple:     
    65         names = (names,)         
    66     retval = []                  
    67     for name in names:           
     65    if type(names) != tuple: 
     66        names = (names,) 
     67    retval = [] 
     68    for name in names: 
    6869        output = getoutput('pkg-config --cflags-only-I %s' % name) 
    69         retval.extend(output.replace('-I', '').split())            
    70     return retval                                                  
     70        retval.extend(output.replace('-I', '').split()) 
     71    return retval 
    7172 
    7273def pkc_get_libraries(names): 
    73     if type(names) != tuple:  
    74         names = (names,)      
    75     retval = []               
    76     for name in names:        
     74    if type(names) != tuple: 
     75        names = (names,) 
     76    retval = [] 
     77    for name in names: 
    7778        output = getoutput('pkg-config --libs-only-l %s' % name) 
    78         retval.extend(output.replace('-l', '').split())          
    79     return retval                                                
     79        retval.extend(output.replace('-l', '').split()) 
     80    return retval 
    8081 
    8182def pkc_get_library_dirs(names): 
    82     if type(names) != tuple:     
    83         names = (names,)         
    84     retval = []                  
    85     for name in names:           
     83    if type(names) != tuple: 
     84        names = (names,) 
     85    retval = [] 
     86    for name in names: 
    8687        output = getoutput('pkg-config --libs-only-L %s' % name) 
    87         retval.extend(output.replace('-L', '').split())          
     88        retval.extend(output.replace('-L', '').split()) 
    8889    return retval 
    8990 
     
    9192 
    9293if os.getenv('PM_DOCKING', False): 
     94    print "OMG you're brave enough to give a try :O" 
     95 
    9396    os.chdir("PM/moo") 
    9497    os.system("make") 
     
    99102        moo = Extension( 
    100103            'PM.Gui.moo_stub', 
    101             [                  
     104            [ 
    102105                'PM/moo/moopane.c', 
    103106                'PM/moo/moopaned.c', 
    104107                'PM/moo/moobigpaned.c', 
    105108                'PM/moo/moomarshals.c', 
    106                 'PM/moo/moo-pygtk.c',   
    107                 'PM/moo/moo-stub.c',    
    108             ],                       
     109                'PM/moo/moo-pygtk.c', 
     110                'PM/moo/moo-stub.c', 
     111            ], 
    109112            include_dirs=pkc_get_include_dirs('gtk+-2.0 pygtk-2.0'), 
    110             libraries=pkc_get_libraries('gtk+-2.0 pygtk-2.0'),       
     113            libraries=pkc_get_libraries('gtk+-2.0 pygtk-2.0'), 
    111114            library_dirs=pkc_get_library_dirs('gtk+-2.0 pygtk-2.0'), 
    112         )                                                            
    113     else:                                                            
    114         moo = Extension(                                          
    115             'PM.Gui.moo_stub',                                       
    116             [                                                        
     115        ) 
     116    else: 
     117        moo = Extension( 
     118            'PM.Gui.moo_stub', 
     119            [ 
    117120                'PM/moo/moopane.c', 
    118121                'PM/moo/moopaned.c', 
     
    136139 
    137140mo_files = [] 
     141 
    138142for filepath in glob.glob("PM/share/locale/*/LC_MESSAGES/*.mo"): 
    139143    lang = filepath[len("PM/share/locale/"):] 
     
    142146 
    143147setup(name         = 'PacketManipulator', 
    144       version      = '0.1', 
     148      version      = PM_VERSION, 
    145149      description  = 'Packet manipulation made easy', 
    146150      author       = 'Francesco Piccinno',