Changeset 493

Show
Ignore:
Timestamp:
Fri Jul 25 05:34:34 2008
Author:
htgoebel
Message:

Code cleanup: Moved functional lines at the end of file (this mean: all functions and definitions are now at the beginning).

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/Build.py

    r492 r493  
    28 28 import tempfile  
    29 29 import md5  
      30 import UserList  
    30 31  
    31 32 import mf  
     
    37 38 STRINGTYPE = type('')  
    38 39 TUPLETYPE = type((None,))  
      40 UNCOMPRESSED, COMPRESSED = range(2)  
    39 41  
    40 42 # todo: use pkg_resources here  
     
    56 58     return eval(open(filename, 'r').read())  
    57 59  
    58   try:  
    59       config = _load_data(os.path.join(HOMEPATH, 'config.dat'))  
    60   except IOError:  
    61       print "You must run Configure.py before building!"  
    62       sys.exit(1)  
    63    
    64   target_platform = config.get('target_platform', sys.platform)  
    65   target_iswin = target_platform[:3] == 'win'  
    66    
    67   if target_platform == sys.platform:  
    68       # _not_ cross compiling  
    69       if config['pythonVersion'] != sys.version:  
    70           print "The current version of Python is not the same with which PyInstaller was configured."  
    71           print "Please re-run Configure.py with this version."  
    72           sys.exit(1)  
    73    
    74   if config['hasRsrcUpdate']:  
    75       import icon, versionInfo  
    76    
    77 60 def setupUPXFlags():  
    78 61     f = os.environ.get("UPX", "")  
     
    86 69     os.environ["UPX"] = f  
    87 70  
    88   if config['hasUPX']:  
    89       setupUPXFlags()  
    90    
    91   def build(spec):  
    92       global SPECPATH, BUILDPATH, WARNFILE, rthooks  
    93       rthooks = _load_data(os.path.join(HOMEPATH, 'rthooks.dat'))  
    94       SPECPATH, specnm = os.path.split(spec)  
    95       specnm = os.path.splitext(specnm)[0]  
    96       if SPECPATH == '':  
    97           SPECPATH = os.getcwd()  
    98       WARNFILE = os.path.join(SPECPATH, 'warn%s.txt' % specnm)  
    99       BUILDPATH = os.path.join(SPECPATH, 'build%s' % specnm)  
    100       if '-o' in sys.argv:  
    101           bpath = sys.argv[sys.argv.index('-o')+1]  
    102           if os.path.isabs(bpath):  
    103               BUILDPATH = bpath  
    104           else:  
    105               BUILDPATH = os.path.join(SPECPATH, bpath)  
    106       if not os.path.exists(BUILDPATH):  
    107           os.mkdir(BUILDPATH)  
    108       execfile(spec)  
    109    
    110 71 def mtime(fnm):  
    111 72     try:  
     
    467 428     return cachedfile  
    468 429  
    469   UNCOMPRESSED, COMPRESSED = range(2)  
    470 430 class PKG(Target):  
    471 431     typ = 'PKG'  
     
    719 679  
    720 680  
    721   if not config['useELFEXE']:  
    722       EXE.append_pkg = 0  
    723    
    724 681 class COLLECT(Target):  
    725 682     def __init__(self, *args, **kws):  
     
    797 754         return 1  
    798 755  
    799   import UserList  
      756  
    799 756 class TOC(UserList.UserList):  
    800 757     def __init__(self, initlist=None):  
     
    942 899     return PKG(TkTree(), name='tk.pkg')  
    943 900  
      901 #---  
      902  
      903 def build(spec):  
      904     global SPECPATH, BUILDPATH, WARNFILE, rthooks  
      905     rthooks = _load_data(os.path.join(HOMEPATH, 'rthooks.dat'))  
      906     SPECPATH, specnm = os.path.split(spec)  
      907     specnm = os.path.splitext(specnm)[0]  
      908     if SPECPATH == '':  
      909         SPECPATH = os.getcwd()  
      910     WARNFILE = os.path.join(SPECPATH, 'warn%s.txt' % specnm)  
      911     BUILDPATH = os.path.join(SPECPATH, 'build%s' % specnm)  
      912     if '-o' in sys.argv:  
      913         bpath = sys.argv[sys.argv.index('-o')+1]  
      914         if os.path.isabs(bpath):  
      915             BUILDPATH = bpath  
      916         else:  
      917             BUILDPATH = os.path.join(SPECPATH, bpath)  
      918     if not os.path.exists(BUILDPATH):  
      919         os.mkdir(BUILDPATH)  
      920     execfile(spec)  
      921  
      922  
    944 923 usage = """\  
    945 924 Usage: python %s <specfile>  
     
    948 927 """  
    949 928  
      929 try:  
      930     config = _load_data(os.path.join(HOMEPATH, 'config.dat'))  
      931 except IOError:  
      932     print "You must run Configure.py before building!"  
      933     sys.exit(1)  
      934  
      935 target_platform = config.get('target_platform', sys.platform)  
      936 target_iswin = target_platform[:3] == 'win'  
      937  
      938 if target_platform == sys.platform:  
      939     # _not_ cross compiling  
      940     if config['pythonVersion'] != sys.version:  
      941         print "The current version of Python is not the same with which PyInstaller was configured."  
      942         print "Please re-run Configure.py with this version."  
      943         sys.exit(1)  
      944  
      945 if config['hasRsrcUpdate']:  
      946     import icon, versionInfo  
      947  
      948 if config['hasUPX']:  
      949     setupUPXFlags()  
      950  
      951 if not config['useELFEXE']:  
      952     EXE.append_pkg = 0  
      953  
    950 954 if __name__ == '__main__':  
    951 955     if len(sys.argv) < 2: