Use valid pypi versions for install in assistant (#14750)

Co-authored-by: Kushashwa Ravi Shrimali <kushashwaravishrimali@gmail.com>
This commit is contained in:
otaj 2022-09-16 15:26:04 +02:00 committed by lexierule
parent e72e5b981e
commit 4262cf83ac
1 changed files with 2 additions and 6 deletions

View File

@ -1,7 +1,6 @@
import datetime import datetime
import glob import glob
import json import json
import logging
import os import os
import re import re
import shutil import shutil
@ -17,7 +16,6 @@ from urllib.request import Request, urlopen
import fire import fire
import pkg_resources import pkg_resources
from packaging.version import parse as version_parse
REQUIREMENT_FILES = { REQUIREMENT_FILES = {
"pytorch": ( "pytorch": (
@ -124,10 +122,8 @@ class AssistantCLI:
url = f"https://pypi.org/pypi/{PACKAGE_MAPPING[package]}/json" url = f"https://pypi.org/pypi/{PACKAGE_MAPPING[package]}/json"
data = json.load(urlopen(Request(url))) data = json.load(urlopen(Request(url)))
if not version: if not version:
versions = list(data["releases"].keys()) pypi_vers = pypi_versions(PACKAGE_MAPPING[package])
versions = sorted(versions, key=lambda x: version_parse(x)) version = pypi_vers[-1]
logging.debug(f"Available versions: {versions}")
version = versions[-1]
releases = list(filter(lambda r: r["packagetype"] == "sdist", data["releases"][version])) releases = list(filter(lambda r: r["packagetype"] == "sdist", data["releases"][version]))
assert releases, f"Missing 'sdist' for this package/version aka {package}/{version}" assert releases, f"Missing 'sdist' for this package/version aka {package}/{version}"
release = releases[0] release = releases[0]