setup.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:cmany 作者: biojppm 项目源码 文件源码
def get_binaries_directory():
    """Return the installation directory, or None
    http://stackoverflow.com/questions/36187264"""
    if '--user' in sys.argv:
        paths = (site.getusersitepackages(),)
    else:
        if hasattr(site, 'getsitepackages'):
            print("cmany setup: site-packages", site.getsitepackages())
            print("cmany setup: site-user-packages", site.getusersitepackages())
            print("cmany setup: site-prefix", os.path.dirname(sys.executable))
            paths = site.getsitepackages()
        else:
            print("cmany setup: no site.getsitepackages()...")
            py_prefix = os.path.dirname(sys.executable)
            paths = [
                py_prefix + '/lib/site-packages',
                py_prefix + '/lib/site-packages',
                py_prefix + '/lib',
            ]
        py_version = '{}.{}'.format(sys.version_info[0], sys.version_info[1])
        paths += (s.format(py_version) for s in (
            sys.prefix + '/lib/python{}/site-packages/',
            sys.prefix + '/lib/python{}/dist-packages/',
            sys.prefix + '/local/lib/python{}/site-packages/',
            sys.prefix + '/local/lib/python{}/dist-packages/',
            '/Library/Python/{}/site-packages/',
        ))
    for path in paths:
        if os.path.exists(path):
            print('cmany setup: installation path:', path)
            return path
    raise Exception('cmany setup: no installation path found', file=sys.stderr)
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号