home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / distutils / core.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  4.4 KB  |  138 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. __revision__ = '$Id: core.py 65806 2008-08-18 11:13:45Z marc-andre.lemburg $'
  5. import sys
  6. import os
  7. from types import *
  8. from distutils.debug import DEBUG
  9. from distutils.errors import *
  10. from distutils.util import grok_environment_error
  11. from distutils.dist import Distribution
  12. from distutils.cmd import Command
  13. from distutils.config import PyPIRCCommand
  14. from distutils.extension import Extension
  15. USAGE = 'usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]\n   or: %(script)s --help [cmd1 cmd2 ...]\n   or: %(script)s --help-commands\n   or: %(script)s cmd --help\n'
  16.  
  17. def gen_usage(script_name):
  18.     script = os.path.basename(script_name)
  19.     return USAGE % vars()
  20.  
  21. _setup_stop_after = None
  22. _setup_distribution = None
  23. setup_keywords = ('distclass', 'script_name', 'script_args', 'options', 'name', 'version', 'author', 'author_email', 'maintainer', 'maintainer_email', 'url', 'license', 'description', 'long_description', 'keywords', 'platforms', 'classifiers', 'download_url', 'requires', 'provides', 'obsoletes')
  24. extension_keywords = ('name', 'sources', 'include_dirs', 'define_macros', 'undef_macros', 'library_dirs', 'libraries', 'runtime_library_dirs', 'extra_objects', 'extra_compile_args', 'extra_link_args', 'swig_opts', 'export_symbols', 'depends', 'language')
  25.  
  26. def setup(**attrs):
  27.     global _setup_distribution
  28.     klass = attrs.get('distclass')
  29.     if klass:
  30.         del attrs['distclass']
  31.     else:
  32.         klass = Distribution
  33.     if 'script_name' not in attrs:
  34.         attrs['script_name'] = os.path.basename(sys.argv[0])
  35.     
  36.     if 'script_args' not in attrs:
  37.         attrs['script_args'] = sys.argv[1:]
  38.     
  39.     
  40.     try:
  41.         _setup_distribution = dist = klass(attrs)
  42.     except DistutilsSetupError:
  43.         msg = None
  44.         if 'name' in attrs:
  45.             raise SystemExit, 'error in %s setup command: %s' % (attrs['name'], msg)
  46.         'name' in attrs
  47.         raise SystemExit, 'error in setup command: %s' % msg
  48.  
  49.     if _setup_stop_after == 'init':
  50.         return dist
  51.     dist.parse_config_files()
  52.     if _setup_stop_after == 'config':
  53.         return dist
  54.     
  55.     try:
  56.         ok = dist.parse_command_line()
  57.     except DistutilsArgError:
  58.         _setup_stop_after == 'config'
  59.         msg = _setup_stop_after == 'config'
  60.         None if DEBUG else _setup_stop_after == 'init'
  61.         raise SystemExit, gen_usage(dist.script_name) + '\nerror: %s' % msg
  62.     except:
  63.         _setup_stop_after == 'config'
  64.  
  65.     if DEBUG:
  66.         print 'options (after parsing command line):'
  67.         dist.dump_option_dicts()
  68.     
  69.     if _setup_stop_after == 'commandline':
  70.         return dist
  71.     if ok:
  72.         
  73.         try:
  74.             dist.run_commands()
  75.         except KeyboardInterrupt:
  76.             _setup_stop_after == 'commandline'
  77.             _setup_stop_after == 'commandline'
  78.             raise SystemExit, 'interrupted'
  79.         except (IOError, os.error):
  80.             _setup_stop_after == 'commandline'
  81.             exc = _setup_stop_after == 'commandline'
  82.             _setup_stop_after == 'commandline'
  83.             error = grok_environment_error(exc)
  84.             if DEBUG:
  85.                 sys.stderr.write(error + '\n')
  86.                 raise 
  87.             DEBUG
  88.             raise SystemExit, error
  89.         except (DistutilsError, CCompilerError):
  90.             _setup_stop_after == 'commandline'
  91.             msg = _setup_stop_after == 'commandline'
  92.             _setup_stop_after == 'commandline'
  93.             if DEBUG:
  94.                 raise 
  95.             DEBUG
  96.             raise SystemExit, 'error: ' + str(msg)
  97.         except:
  98.             _setup_stop_after == 'commandline'<EXCEPTION MATCH>KeyboardInterrupt
  99.         
  100.  
  101.     _setup_stop_after == 'commandline'
  102.     return dist
  103.  
  104.  
  105. def run_setup(script_name, script_args = None, stop_after = 'run'):
  106.     global _setup_stop_after, _setup_stop_after
  107.     if stop_after not in ('init', 'config', 'commandline', 'run'):
  108.         raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
  109.     stop_after not in ('init', 'config', 'commandline', 'run')
  110.     _setup_stop_after = stop_after
  111.     save_argv = sys.argv
  112.     g = {
  113.         '__file__': script_name }
  114.     l = { }
  115.     
  116.     try:
  117.         
  118.         try:
  119.             sys.argv[0] = script_name
  120.             if script_args is not None:
  121.                 sys.argv[1:] = script_args
  122.             
  123.             exec open(script_name, 'r').read() in g, l
  124.         finally:
  125.             sys.argv = save_argv
  126.             _setup_stop_after = None
  127.  
  128.     except SystemExit:
  129.         pass
  130.     except:
  131.         raise 
  132.  
  133.     if _setup_distribution is None:
  134.         raise RuntimeError, "'distutils.core.setup()' was never called -- perhaps '%s' is not a Distutils setup script?" % script_name
  135.     _setup_distribution is None
  136.     return _setup_distribution
  137.  
  138.