aboutsummaryrefslogtreecommitdiff
path: root/.ci/pypi-check.py
blob: 1b9c11c42b044eb4a9a28d6ba6ad101d48dbf03d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3


import argparse
import sys
import xmlrpc.client


def main():
    parser = argparse.ArgumentParser(description='PyPI package checker')
    parser.add_argument('package_name', metavar='PACKAGE-NAME')

    parser.add_argument(
        '--pypi-index-url',
        help=('PyPI index URL.'),
        default='https://pypi.python.org/pypi')

    args = parser.parse_args()

    pypi = xmlrpc.client.ServerProxy(args.pypi_index_url)
    releases = pypi.package_releases(args.package_name)

    if releases:
        print(next(iter(sorted(releases, reverse=True))))

    return 0


if __name__ == '__main__':
    sys.exit(main())