Можно ли искать, когда была опубликована конкретная версия пакета? - PullRequest
1 голос
/ 06 мая 2019

Можно ли искать, когда определенный пакет был отправлен в Pypi? т.е.

pip search foo==0.17 
foo (0.17) {SOME DATE}     
pip search foo==0.18 
foo (0.18) {SOME OTHER DATE}     

Я могу посмотреть историю релизов на странице Pypi, но доступна ли она через pip? Я не хочу видеть номера версий, я хочу дату, когда она была выпущена.

1 Ответ

2 голосов
/ 06 мая 2019

Да, это возможно.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

Надеюсь, это поможет!

...