是否可以搜索特定版本的软件包何时发布?
Is it possible to search for when a specific version of a package has been published?
是否可以在特定包被推送到 Pypi 时进行搜索?即
pip search foo==0.17
foo (0.17) {SOME DATE}
pip search foo==0.18
foo (0.18) {SOME OTHER DATE}
我可以在 Pypi 的页面上看到发布历史,但是它可以通过 pip 获得吗?我不想看到版本号,我想要它的发布日期。
是的,这是可能的。 PyPI 有一个 API 格式的所有包信息。
示例: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
希望对您有所帮助!
是否可以在特定包被推送到 Pypi 时进行搜索?即
pip search foo==0.17
foo (0.17) {SOME DATE}
pip search foo==0.18
foo (0.18) {SOME OTHER DATE}
我可以在 Pypi 的页面上看到发布历史,但是它可以通过 pip 获得吗?我不想看到版本号,我想要它的发布日期。
是的,这是可能的。 PyPI 有一个 API 格式的所有包信息。
示例: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
希望对您有所帮助!