🖊 fix: requirements parsing error (#85)

This commit is contained in:
Florian Hönicke
2023-05-04 14:29:01 +02:00
committed by GitHub
parent 942629e637
commit e65f958ced
2 changed files with 7 additions and 5 deletions

View File

@@ -63,13 +63,12 @@ def clean_requirements_txt(previous_microservice_path):
continue
split = re.split(r'==|>=|<=|>|<|~=', line)
if len(split) == 1:
if len(split) == 1 or len(split) > 2:
version = None
package_name = split[0]
elif len(split) == 2:
package_name, version = split
else:
raise ValueError(f'Could not parse line {line} in requirements.txt')
package_name, version = split
# Keep lines with jina, docarray, openai, pytest unchanged
if package_name in {'jina', 'docarray', 'openai', 'pytest'}:
@@ -79,7 +78,7 @@ def clean_requirements_txt(previous_microservice_path):
if version is None or not is_package_on_pypi(package_name, version):
latest_version = get_latest_package_version(package_name)
if latest_version is None:
raise ValueError(f'Package {package_name} not found on PyPI')
continue
updated_requirements.append(f'{package_name}~={latest_version}')
else:
updated_requirements.append(line)

View File

@@ -47,6 +47,8 @@ gtts~=2.2.3
pydub~=123.123.123
# non-existing package with correct version
base64~=3.3.0
# not parsable version
pdfminer.six>=20201018,<20211018
# existing package without version
requests
# another existing package without version
@@ -57,6 +59,7 @@ jina==111.222.333
docarray==111.222.333
gtts~=2.2.3
pydub~=0.25.1
pdfminer.six~=20201018
requests~=2.26.0
streamlit~=0.89.0"""
requirements_txt_path = os.path.join(tmpdir, "requirements.txt")