gradio/scripts/check_pypi.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
485 B
Python
Raw Normal View History

import json
import sys
import urllib.request
from pathlib import Path
root_directory = Path(__file__).parent.parent
version = (root_directory / "gradio" / "version.txt").read_text(
encoding='utf8').strip()
with urllib.request.urlopen("https://pypi.org/pypi/gradio/json") as url:
releases = json.load(url)["releases"]
if version in releases:
print(f"Version {version} already exists on PyPI")
sys.exit(1)
else:
print(f"Version {version} does not exist on PyPI")