File: check_gpg.py

package info (click to toggle)
ubelt 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,180 kB
  • sloc: python: 15,487; sh: 807; makefile: 24
file content (36 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36


def main():
    """
    Checks that the latest wheels on pypi agree with the gpg key
    """
    import requests

    package_name = 'ubelt'
    url = "https://pypi.python.org/pypi/{}/json".format(package_name)
    package = requests.get(url).json()
    max_ver = max(package["releases"].keys())
    # ... check compatibility
    latest_wheel_info_list = package['releases'][max_ver]

    for wheel_info in latest_wheel_info_list:
        import ubelt as ub
        whl_fpath = ub.grabdata(
            wheel_info['url'],
            hash_prefix=wheel_info['digests']['sha256'],
            hasher='sha256'
        )

        if not wheel_info['has_sig']:
            raise ValueError('info says no sig')

        sig_fpath = ub.download(
            wheel_info['url'] + '.asc',
        )

        info = ub.cmd('gpg --verify {} {}'.format(sig_fpath, whl_fpath),
                      verbose=3)
        assert info['ret'] == 0

if __name__ == '__main__':
    pass