Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix version parsing #3016

Merged
merged 1 commit into from
Jul 25, 2024
Merged

fix version parsing #3016

merged 1 commit into from
Jul 25, 2024

Conversation

w-e-w
Copy link
Contributor

@w-e-w w-e-w commented Jul 25, 2024

recently on every launch install.py the message keep poping up on launch

Installing sd-webui-controlnet requirement: changing opencv-python version from 4.10.0.84 to 4.8.0

this is due to improper version comparison in install.py

comparable_version() in install.py retruns Tuple of strings

def comparable_version(version: str) -> Tuple:
return tuple(version.split("."))

until recently directly comparing Tuple of strings work good enough but opencv-python updated to vesrion 4.10.x.x

when checking for opencv-python>=4.8.0
the Tuple of strings ('4', '10', '0', '84') >= ('4', '8', '0') this retruns False
due to the string '10' is < string '8'


solution

as far as I'm aware the best way of passing version number is to use from packaging.version import parse
as this also handles more exotic version numbers such as the ones with suffixes

suffix like pytorch '2.1.2+cu121'

alternatively if you wish to not packaging then one could either write complex regex to handle special cases
or just assume that there's no special version numbers and simply convert str to int
which can be done by modifying comparable_version

def comparable_version(version: str) -> Tuple:
    return tuple(int(v) for v in version.split("."))

Copy link
Collaborator

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huchenlei huchenlei merged commit 56cec5b into Mikubill:main Jul 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants