是否可以搜索何时将特定程序包推送到Pypi?即
pip search foo==0.17
foo (0.17) {SOME DATE}
pip search foo==0.18
foo (0.18) {SOME OTHER DATE}
我可以在Pypi的页面上看到发布历史,但是可以通过pip获得吗?我不想看到版本号,我想要发布的日期。
答案 0 :(得分:2)
是的,有可能。 PyPI有一个API,其中所有包信息均为JSON格式。
示例:https://pypi.org/pypi/{YOUR_PACKAGE}/json
import json
import requests
def search(package_name, version):
url = 'https://pypi.org/pypi/%s/json' % package_name
response = requests.request('GET', url)
if response.ok:
json_response = json.loads(response.content)
uploads = json_response['releases'][version]
for upload in uploads:
print('upload date %s | filename = %s' % (upload['upload_time'], upload['filename']))
search('pandas', '0.24.2')
输出:
upload date 2019-03-14T10:10:10 | filename = pandas-0.24.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
upload date 2019-03-14T10:10:34 | filename = pandas-0.24.2-cp27-cp27mu-manylinux1_i686.whl
upload date 2019-03-14T10:10:39 | filename = pandas-0.24.2-cp27-cp27mu-manylinux1_x86_64.whl
upload date 2019-03-14T10:10:44 | filename = pandas-0.24.2-cp27-cp27m-win32.whl
upload date 2019-03-14T10:10:49 | filename = pandas-0.24.2-cp27-cp27m-win_amd64.whl
upload date 2019-03-14T10:10:55 | filename = pandas-0.24.2-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
upload date 2019-03-14T10:11:00 | filename = pandas-0.24.2-cp35-cp35m-manylinux1_i686.whl
upload date 2019-03-14T10:11:05 | filename = pandas-0.24.2-cp35-cp35m-manylinux1_x86_64.whl
upload date 2019-03-14T10:11:11 | filename = pandas-0.24.2-cp35-cp35m-win32.whl
upload date 2019-03-14T10:11:15 | filename = pandas-0.24.2-cp35-cp35m-win_amd64.whl
upload date 2019-03-14T10:11:21 | filename = pandas-0.24.2-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
upload date 2019-03-14T10:12:12 | filename = pandas-0.24.2-cp36-cp36m-manylinux1_i686.whl
upload date 2019-03-14T10:12:18 | filename = pandas-0.24.2-cp36-cp36m-manylinux1_x86_64.whl
upload date 2019-03-14T10:12:23 | filename = pandas-0.24.2-cp36-cp36m-win32.whl
upload date 2019-03-14T10:12:27 | filename = pandas-0.24.2-cp36-cp36m-win_amd64.whl
upload date 2019-03-14T10:12:33 | filename = pandas-0.24.2-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
upload date 2019-03-14T10:12:38 | filename = pandas-0.24.2-cp37-cp37m-manylinux1_x86_64.whl
upload date 2019-03-14T10:12:43 | filename = pandas-0.24.2-cp37-cp37m-win32.whl
upload date 2019-03-14T10:12:47 | filename = pandas-0.24.2-cp37-cp37m-win_amd64.whl
upload date 2019-03-14T10:12:53 | filename = pandas-0.24.2.tar.gz
希望有帮助!