code: def _setup_py_run_from_dir(root_dir, py_interpreter):
      
      data = {}
      with _enter_single_subdir(root_dir) as single_subdir:
          if not os.path.exists("setup.py"):
              raise Exception("'setup.py' does not exist in '%s'" % (
                  single_subdir))
          # generate a temporary json file which contains the metadata
          output_json = tempfile.NamedTemporaryFile()
          cmd = "%s setup.py -q --command-packages metaextract " \
                "metaextract -o %s " % (py_interpreter, output_json.name)
          try:
              subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
          except subprocess.CalledProcessError:
              # try again with a encoding in setup.py
              _set_file_encoding_utf8("setup.py")
              subprocess.check_output(cmd, shell=True)
  
          # read json file and return data
          with open(output_json.name, "r") as f:
              data = json.loads(f.read())
  
          # sort some of the keys if the dict values are lists
          for key in ['data_files', 'entry_points', 'extras_require',
                      'install_requires', 'setup_requires', 'scripts',
                      'tests_require', 'tests_suite']:
              if key in data['data'] and isinstance(data['data'][key], list):
                  data['data'][key] = sorted(data['data'][key])
      return data
docs: run the extractmeta command via the setup.py in the given root_dir.
      the output of extractmeta is json and is stored in a tempfile
      which is then read in and returned as data