Changeset 3492
- Timestamp:
- 08/16/08 17:11:25 (5 years ago)
- Files:
-
- 1 modified
-
branch/PacketManipulator/setup.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/PacketManipulator/setup.py
r3491 r3492 24 24 25 25 from distutils.core import setup, Extension 26 from PM.Core.Const import PM_VERSION 26 27 27 28 def getoutput(cmd): 28 29 """Return output (stdout or stderr) of executing cmd in a shell.""" 29 return getstatusoutput(cmd)[1] 30 return getstatusoutput(cmd)[1] 30 31 31 32 def getstatusoutput(cmd): 32 33 """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) 43 44 44 45 def pkgc_version_check(name, longname, req_version): 45 46 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 49 50 50 51 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('.')) 53 54 54 55 if version >= pkc_version: 55 return 1 56 else: 56 return 1 57 else: 57 58 print "Warning: Too old version of %s" % longname 58 59 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 62 63 63 64 def 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: 68 69 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 71 72 72 73 def 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: 77 78 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 80 81 81 82 def 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: 86 87 output = getoutput('pkg-config --libs-only-L %s' % name) 87 retval.extend(output.replace('-L', '').split()) 88 retval.extend(output.replace('-L', '').split()) 88 89 return retval 89 90 … … 91 92 92 93 if os.getenv('PM_DOCKING', False): 94 print "OMG you're brave enough to give a try :O" 95 93 96 os.chdir("PM/moo") 94 97 os.system("make") … … 99 102 moo = Extension( 100 103 'PM.Gui.moo_stub', 101 [ 104 [ 102 105 'PM/moo/moopane.c', 103 106 'PM/moo/moopaned.c', 104 107 'PM/moo/moobigpaned.c', 105 108 '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 ], 109 112 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'), 111 114 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 [ 117 120 'PM/moo/moopane.c', 118 121 'PM/moo/moopaned.c', … … 136 139 137 140 mo_files = [] 141 138 142 for filepath in glob.glob("PM/share/locale/*/LC_MESSAGES/*.mo"): 139 143 lang = filepath[len("PM/share/locale/"):] … … 142 146 143 147 setup(name = 'PacketManipulator', 144 version = '0.1',148 version = PM_VERSION, 145 149 description = 'Packet manipulation made easy', 146 150 author = 'Francesco Piccinno',
