Skip to content

Instantly share code, notes, and snippets.

@kristaps
Last active January 15, 2016 13:18
Show Gist options
  • Save kristaps/86406a1970eaab11d11f to your computer and use it in GitHub Desktop.
Save kristaps/86406a1970eaab11d11f to your computer and use it in GitHub Desktop.
Show python package PYPI upload times. Helpful when, for example, your tests start failing and you'd like to investigate what recent package updates might have caused the breakage.
#!/usr/bin/env python
from __future__ import print_function
import json
from pip.operations.freeze import freeze
import urllib
URL_TEMPLATE = "https://pypi.python.org/pypi/{pkg}/{version}/json"
for pkg_spec in freeze():
pkg, version = pkg_spec.split('==')
upload_time = None
response = urllib.urlopen(URL_TEMPLATE.format(pkg=pkg, version=version))
if response.getcode() == 200:
data = json.loads(response.read())
for url in data['urls']:
if url['python_version'] == 'source':
upload_time = url['upload_time']
break
print("{:25} {:10} {}".format(pkg, version, upload_time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment