From 37c00b9de6c5ad2472aa0e0d41ef0b8c8d3cc6d3 Mon Sep 17 00:00:00 2001 From: 622f1ac984054d073dc85e67 <622f1ac984054d073dc85e67@devide> Date: Tue, 18 Jul 2023 18:10:00 +0800 Subject: [PATCH] Tue Jul 18 18:10:00 CST 2023 inscode --- install_pip.py | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/install_pip.py b/install_pip.py index 25058e0..8f8c030 100644 --- a/install_pip.py +++ b/install_pip.py @@ -1,26 +1,14 @@ -import subprocess -import re - -# 你的依赖列表 -dependencies = ["numpy", "pandas", "matplotlib", "scikit-learn"] - -# 正则表达式来匹配下载进度和安装进度 -download_pattern = re.compile(r'(?P\d+)%\s+\|(?P\d+\.?\d*\w+)/(?P\d+\.?\d*\w+)\s+') -install_pattern = re.compile(r'(?P\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 -- GitLab