Tue Jul 18 18:10:00 CST 2023 inscode

上级 8fb22735
import subprocess
import re
# 你的依赖列表
dependencies = ["numpy", "pandas", "matplotlib", "scikit-learn"]
# 正则表达式来匹配下载进度和安装进度
download_pattern = re.compile(r'(?P<percent>\d+)%\s+\|(?P<done>\d+\.?\d*\w+)/(?P<total>\d+\.?\d*\w+)\s+')
install_pattern = re.compile(r'(?P<name>\w+).+Installing collected packages')
for dep in dependencies:
print(f"开始安装: {dep}")
process = subprocess.Popen(["pip", "install", dep], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(process.stdout.readline, b''):
line = line.decode('utf-8')
download_match = download_pattern.search(line)
if download_match:
print(f"下载进度: {download_match.group('percent')}% ({download_match.group('done')} / {download_match.group('total')})")
install_match = install_pattern.search(line)
if install_match:
print(f"开始安装: {install_match.group('name')}")
process.stdout.close()
process.wait()
from __future__ import print_function
import json
import sys
try:
from xmlrpc import client as xmlrpc
except ImportError:
import xmlrpclib as xmlrpc
query = sys.argv[1]
pypi = xmlrpc.ServerProxy("https://pypi.org/pypi")
results = pypi.search({"name": query})
json.dump(results, sys.stdout)
print()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册