2023-03-04 01:19:37 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2023-02-05 19:45:31 +00:00
|
|
|
import requests
|
2023-02-04 21:58:21 +00:00
|
|
|
|
2023-07-21 16:36:09 +00:00
|
|
|
from invokeai.version import __version__
|
2023-02-04 21:58:21 +00:00
|
|
|
|
2023-02-05 19:45:31 +00:00
|
|
|
local_version = str(__version__).replace("-", "")
|
2023-07-27 14:54:01 +00:00
|
|
|
package_name = "InvokeAI"
|
|
|
|
|
2023-02-04 21:58:21 +00:00
|
|
|
|
2023-02-05 19:45:31 +00:00
|
|
|
def get_pypi_versions(package_name=package_name) -> list[str]:
|
2023-02-04 21:58:21 +00:00
|
|
|
"""Get the versions of the package from PyPI"""
|
|
|
|
url = f"https://pypi.org/pypi/{package_name}/json"
|
2023-02-05 19:45:31 +00:00
|
|
|
response = requests.get(url).json()
|
2023-02-04 21:58:21 +00:00
|
|
|
versions: list[str] = list(response["releases"].keys())
|
|
|
|
return versions
|
|
|
|
|
|
|
|
|
2023-02-05 19:45:31 +00:00
|
|
|
def local_on_pypi(package_name=package_name, local_version=local_version) -> bool:
|
2023-02-04 21:58:21 +00:00
|
|
|
"""Compare the versions of the package from PyPI and the local package"""
|
|
|
|
pypi_versions = get_pypi_versions(package_name)
|
|
|
|
return local_version in pypi_versions
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if local_on_pypi():
|
|
|
|
print(f"Package {package_name} is up to date")
|
|
|
|
else:
|
|
|
|
print(f"Package {package_name} is not up to date")
|