Changeset 494

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

switched to optparse and a main() function

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/Build.py

    r493 r494  
    1   #! /usr/bin/env python  
      1 #!/usr/bin/env python  
    1 1 #  
    2 2 # Build packages using spec files  
     
    927 927 """  
    928 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."  
      929 def main(specfile):  
      930     global target_platform, target_iswin, config  
      931     global icon, versionInfo  
      932  
      933     try:  
      934         config = _load_data(os.path.join(HOMEPATH, 'config.dat'))  
      935     except IOError:  
      936         print "You must run Configure.py before building!"  
    943 937         sys.exit(1)  
    944 938  
    945   if config['hasRsrcUpdate']:  
    946       import icon, versionInfo  
      939     target_platform = config.get('target_platform', sys.platform)  
      940     target_iswin = target_platform[:3] == 'win'  
      941  
      942     if target_platform == sys.platform:  
      943         # _not_ cross compiling  
      944         if config['pythonVersion'] != sys.version:  
      945             print "The current version of Python is not the same with which PyInstaller was configured."  
      946             print "Please re-run Configure.py with this version."  
      947             sys.exit(1)  
      948  
      949     if config['hasRsrcUpdate']:  
      950         import icon, versionInfo  
    947 951  
    948   if config['hasUPX']:  
    949       setupUPXFlags()  
      952     if config['hasUPX']:  
      953         setupUPXFlags()  
    950 954  
    951   if not config['useELFEXE']:  
    952       EXE.append_pkg = 0  
      955     if not config['useELFEXE']:  
      956         EXE.append_pkg = 0  
      957  
      958     build(specfile)  
    953 959  
    954 960 if __name__ == '__main__':  
    955       if len(sys.argv) < 2:  
    956           print usage % sys.argv[0]  
    957       else:  
    958           build(sys.argv[1])  
      961     from optparse import OptionParser  
      962     parser = OptionParser('%program [options] specfile')  
      963     opts, args = parser.parse_args()  
      964     if len(args) != 1:  
      965         parser.error('Requires exactly one .spec-file')  
      966  
      967     main(args[0])