summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-03-25 13:18:35 +0100
committerMartin Fischer <martin@push-f.com>2021-03-25 13:24:09 +0100
commit40ab2310a30d7347cb5e50dc81c3be0a77088e88 (patch)
treef9ffee0359691b8c58544f301602cfcc51fa7bf0
parent91ba2400d6eca7bd6124702be50076a2470786bd (diff)
add cargo_check.py
-rwxr-xr-xcargo_check.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/cargo_check.py b/cargo_check.py
new file mode 100755
index 0000000..3350c56
--- /dev/null
+++ b/cargo_check.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# Written by Martin Fischer <martin@push-f.com> and licensed under MIT.
+from multiprocessing.dummy import Pool
+import toml
+import requests
+
+sess = requests.session()
+sess.headers['user-agent'] = 'cargo_check.py'
+
+tasks = []
+
+with open('Cargo.toml') as f:
+ data = toml.load(f)
+ for name, info in data['dependencies'].items():
+ version = info if isinstance(info, str) else info.get('version')
+ tasks.append((name, version))
+
+def check_package(info):
+ name, version = info
+ res = sess.get('https://crates.io/api/v1/crates/{}'.format(name))
+ latest_version = res.json()['versions'][0]
+ if latest_version['yanked']:
+ print(name, 'was yanked')
+ elif not latest_version['num'].startswith(version):
+ print('{} is outdated ({}), {} is available'.format(name, version, latest_version['num']))
+
+pool = Pool()
+pool.map(check_package, tasks)