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
评论列表
文章目录