本文整理汇总了Python中pip._internal.utils.appdirs.user_cache_dir方法的典型用法代码示例。如果您正苦于以下问题:Python appdirs.user_cache_dir方法的具体用法?Python appdirs.user_cache_dir怎么用?Python appdirs.user_cache_dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._internal.utils.appdirs
的用法示例。
在下文中一共展示了appdirs.user_cache_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_pip_files
# 需要导入模块: from pip._internal.utils import appdirs [as 别名]
# 或者: from pip._internal.utils.appdirs import user_cache_dir [as 别名]
def delete_pip_files():
"""Delete random pip files"""
try:
from pip.utils.appdirs import user_cache_dir
except BaseException:
try:
from pip._internal.utils.appdirs import user_cache_dir
except BaseException:
return
for root, dirnames, filenames in os.walk(user_cache_dir('pip/wheels')):
for filename in fnmatch.filter(filenames, PACKAGE_NAME + '-*.whl'):
try:
whl = os.path.join(root, filename)
print("Deleting...", whl)
os.remove(whl)
except BaseException:
pass
try:
import site
if hasattr(site, 'getsitepackages'):
site_packages = site.getsitepackages()
else:
from distutils.sysconfig import get_python_lib
site_packages = [get_python_lib()]
if hasattr(site, 'getusersitepackages'):
site_packages = site_packages + [site.getusersitepackages()]
for sitepack in site_packages:
for globbed in glob(sitepack + '/' + PACKAGE_NAME + '*/'):
try:
if globbed.endswith('.dist-info/'):
shutil.rmtree(globbed)
except BaseException:
pass
except BaseException:
pass
示例2: delete_pip_files
# 需要导入模块: from pip._internal.utils import appdirs [as 别名]
# 或者: from pip._internal.utils.appdirs import user_cache_dir [as 别名]
def delete_pip_files():
"""Delete random pip files"""
try:
from pip.utils.appdirs import user_cache_dir
except BaseException:
try:
from pip._internal.utils.appdirs import user_cache_dir
except BaseException:
return
for root, dirnames, filenames in os.walk(user_cache_dir('pip/wheels')):
for filename in fnmatch.filter(filenames, PACKAGE_NAME + '-*.whl'):
try:
whl = os.path.join(root, filename)
print("Deleting...", whl)
os.remove(whl)
except BaseException:
pass
try:
site_packages = get_site_packages()
for site_pack in site_packages:
for globbed in glob(site_pack + '/' + PACKAGE_NAME + '*/'):
try:
if globbed.endswith('.dist-info/'):
shutil.rmtree(globbed)
except BaseException:
pass
except BaseException:
pass