Get latest stable version rather than absolute latest.

We don't want to import alpha versions, generally.

Test: get_rust_pkg.py -add3prf zerocopy
Change-Id: If51a5f9786ccbae8b8f858ae51153a0ffb5ffe7f
This commit is contained in:
Andrew Walbran
2022-11-18 13:42:37 +00:00
parent 99a9d7be5e
commit b5ef53e335

View File

@@ -111,15 +111,15 @@ def is_newer_version(args, prev_version, prev_id, check_version, check_id):
def get_max_version(pkg):
"""Ask crates.io for a pkg's latest version."""
"""Ask crates.io for a pkg's latest stable version."""
url = "https://crates.io/api/v1/crates/" + pkg
with urllib.request.urlopen(url) as request:
data = json.loads(request.read().decode())
return data["crate"]["max_version"]
return data["crate"]["max_stable_version"]
def find_dl_path(args, name):
"""Ask crates.io for the latest version download path."""
"""Ask crates.io for the latest stable version download path."""
base_name, version = pkg_base_name(name)
if not version:
version = get_max_version(name)