def get_version(package, url_pattern=URL_PATTERN):
req = requests.get(url_pattern.format(package=package))<EOL>version = parse('<STR_LIT:0>')<EOL>if req.status_code == requests.codes.ok:<EOL><INDENT>j = req.json()<EOL>releases = j.get('<STR_LIT>', [])<EOL>for release in releases:<EOL><INDENT>ver = parse(release)<EOL>if not ver.is_prerelease:<EOL><INDENT>version = max(version, ver)<EOL><DEDENT><DEDENT><DEDENT>return version<EOL>
Return version of package on pypi.python.org using json. Adapted from https://stackoverflow.com/a/34366589