Changeset 490
- Timestamp:
- Wed Jul 23 16:51:26 2008
- Files:
-
- trunk/suffixes.py (added)
- trunk/Build.py (modified) (diff)
- trunk/mf.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/Build.py
r485 r490 62 62 63 63 target_platform = config.get('target_platform', sys.platform) 64 mf.target_platform = target_platform65 64 target_iswin = target_platform[:3] == 'win' 66 65 … … 216 215 ################################################### 217 216 # Initialize analyzer and analyze scripts 218 analyzer = mf.ImportTracker(dirs.keys()+paths, self.hookspath, self.excludes) 217 analyzer = mf.ImportTracker(dirs.keys()+paths, self.hookspath, 218 self.excludes, 219 target_platform=target_platform) 219 220 #print analyzer.path 220 221 scripts = [] # will contain scripts to bundle -
trunk/mf.py
r485 r490 59 59 60 60 class Owner: 61 def __init__(self, path): 61 def __init__(self, path, target_platform=None): 61 61 self.path = path 62 self.target_platform = target_platform 62 63 def __str__(self): 63 64 return self.path … … 67 68 68 69 class DirOwner(Owner): 69 def __init__(self, path): 70 def __init__(self, path, target_platform=None): 69 70 if path == '': 70 71 path = os.getcwd() 71 72 if not os.path.isdir(path): 72 73 raise ValueError, "%s is not a directory" % path 73 Owner.__init__(self, path) 74 def getmod(self, nm, getsuffixes=suffixes.get_suffixes, loadco=marshal.loads): 74 Owner.__init__(self, path, target_platform) 75 76 def _getsuffixes(self): 77 return suffixes.get_suffixes(self.target_platform) 78 79 def getmod(self, nm, getsuffixes=None, loadco=marshal.loads): 80 if getsuffixes is None: 81 getsuffixes = self._getsuffixes 75 82 pth = os.path.join(self.path, nm) 76 83 possibles = [(pth, 0, None)] … … 137 144 138 145 class PYZOwner(Owner): 139 def __init__(self, path): 146 def __init__(self, path, target_platform=None): 139 146 import archive 140 147 self.pyz = archive.ZlibArchive(path) 141 Owner.__init__(self, path) 148 Owner.__init__(self, path, target_platform) 141 148 def getmod(self, nm): 142 149 rslt = self.pyz.extract(nm) … … 152 159 if zipimport: 153 160 class ZipOwner(Owner): 154 def __init__(self, path): 161 def __init__(self, path, target_platform=None): 154 161 self.__zip = zipimport.zipimporter(path) 155 Owner.__init__(self, path) 162 Owner.__init__(self, path, target_platform) 155 162 156 163 def getmod(self, nm): … … 247 254 248 255 class PathImportDirector(ImportDirector): 249 def __init__(self, pathlist=None, importers=None, ownertypes=None): 256 def __init__(self, pathlist=None, importers=None, ownertypes=None, 257 target_platform=None): 250 258 if pathlist is None: 251 259 self.path = sys.path … … 262 270 self.inMakeOwner = 0 263 271 self.building = {} 272 self.target_platform = target_platform 273 264 274 def __str__(self): 265 275 return str(self.path) 276 266 277 def getmod(self, nm): 267 278 mod = None … … 278 289 break 279 290 return mod 291 280 292 def makeOwner(self, path): 281 293 if self.building.get(path): … … 287 299 # this may cause an import, which may cause recursion 288 300 # hence the protection 289 owner = klass(path) 301 owner = klass(path, self.target_platform) 289 301 except Exception, e: 290 302 #print "PathImportDirector", e … … 331 343 LogDict = dict 332 344 345 333 346 class ImportTracker: 334 347 # really the equivalent of builtin import 335 def __init__(self, xpath=None, hookspath=None, excludes=None): 348 def __init__(self, xpath=None, hookspath=None, excludes=None, 349 target_platform=None): 336 350 self.path = [] 337 351 self.warnings = {} … … 344 358 FrozenImportDirector(), 345 359 RegistryImportDirector(), 346 PathImportDirector(self.path) 360 PathImportDirector(self.path, target_platform=target_platform) 346 360 ] 347 361 if hookspath: … … 351 365 if excludes is None: 352 366 self.excludes = [] 367 self.target_platform = target_platform 368 353 369 def analyze_r(self, nm, importernm=None): 354 370 importer = importernm … … 380 396 j = j + len(newnms) 381 397 return map(lambda a: a[0], nms) 398 382 399 def analyze_one(self, nm, importernm=None, imptyp=0): 383 400 # first see if we could be importing a relative name
