Refactor get_version_from_pypi to use default python lib for GET request
This commit is contained in:
parent
e081b985c4
commit
cf1456ba8a
1 changed files with 16 additions and 5 deletions
|
|
@ -11,12 +11,23 @@ def read_version_from_pyproject(file_path):
|
|||
return None
|
||||
|
||||
|
||||
def get_version_from_pypi(package_name):
|
||||
import requests
|
||||
# def get_version_from_pypi(package_name):
|
||||
# import requests
|
||||
|
||||
response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
|
||||
if response.ok:
|
||||
return response.json()["info"]["version"]
|
||||
# response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
|
||||
# if response.ok:
|
||||
# return response.json()["info"]["version"]
|
||||
# return None
|
||||
|
||||
|
||||
def get_version_from_pypi(package_name):
|
||||
# Use default python lib to make the GET for this because it runs in github actions
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
response = urllib.request.urlopen(f"https://pypi.org/pypi/{package_name}/json")
|
||||
if response.getcode() == 200:
|
||||
return json.loads(response.read())["info"]["version"]
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue