def read_package_name_from_setup_py(path):
    try:
        setup_py = os.path.join (path, "setup.py")
        if os.path.exists (setup_py):
            cmd = [sys.executable, "-S", "-s", setup_py, "--name", "--version"]

            env = { "PYTHONPATH" : ":".join (sys.path) }

            proc = subprocess.Popen(cmd, env = env, stdout=subprocess.PIPE)
            result = proc.communicate()
            vv = result[0]
            if proc.returncode != 0:
                raise Exception("'%s' failed with return code '%d'" % (" ".join(cmd), proc.returncode))

            # check_output was added in python 2.7. Use it when available
            #vv = subprocess.check_output([sys.executable, setup_py, "--name", "--version"])
            return parse_setup_py_version_output(vv)
    except (Exception, __HOLE__):
        LOG.exception("Unable to run '%s'", setup_py)
dataset/ETHPy150Open zillow/buildout-platform-versions/buildout_platform_versions/__init__.py/read_package_name_from_setup_py