parameters: (setup_script, args)
docstring: Run a distutils setup script, sandboxed in its directory
docstring_summary: Run a distutils setup script, sandboxed in its directory
docstring_tokens: Run a distutils setup script sandboxed in its directory
function: def run_setup(setup_script, args):
      """Run a distutils setup script, sandboxed in its directory"""
      setup_dir = os.path.abspath(os.path.dirname(setup_script))
      with setup_context(setup_dir):
          try:
              sys.argv[:] = [setup_script] + list(args)
              sys.path.insert(0, setup_dir)
              # reset to include setup dir, w/clean callback list
              working_set.__init__()
              working_set.callbacks.append(lambda dist: dist.activate())
  
              # __file__ should be a byte string on Python 2 (#712)
              dunder_file = (
                  setup_script
                  if isinstance(setup_script, str) else
                  setup_script.encode(sys.getfilesystemencoding())
              )
  
              with DirectorySandbox(setup_dir):
                  ns = dict(__file__=dunder_file, __name__='__main__')
                  _execfile(setup_script, ns)
          except SystemExit as v:
              if v.args and v.args[0]:
                  raise
function_tokens: def run_setup ( setup_script , args ) : setup_dir = os . path . abspath ( os . path . dirname ( setup_script ) ) with setup_context ( setup_dir ) : try : sys . argv [ : ] = [ setup_script ] + list ( args ) sys . path . insert ( 0 , setup_dir ) # reset to include setup dir, w/clean callback list working_set . __init__ ( ) working_set . callbacks . append ( lambda dist : dist . activate ( ) ) # __file__ should be a byte string on Python 2 (#712) dunder_file = ( setup_script if isinstance ( setup_script , str ) else setup_script . encode ( sys . getfilesystemencoding ( ) ) ) with DirectorySandbox ( setup_dir ) : ns = dict ( __file__ = dunder_file , __name__ = '__main__' ) _execfile ( setup_script , ns ) except SystemExit as v : if v . args and v . args [ 0 ] : raise