gradio/scripts/check_pypi.py
D V 52f7831751
refactor: Use package.json for version management (#5514)
* refactor: Use package.json for version management

- uses package.json file for version management.
- updated the regex pattern.
- removed the logic that creates or updates the version.txt file

* load version through package.json

* fix code duplication

* add changeset

* add changeset

* fixes

* fix

* package version

* fix

* typing

* typing

* changes

* add changeset

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2023-09-15 16:23:52 -07:00

18 lines
485 B
Python

import json
import sys
import urllib.request
from pathlib import Path
version_file = Path(__file__).parent.parent / "gradio" / "package.json"
with version_file.open() as f:
version = json.load(f)["version"]
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")