Created
June 13, 2024 06:05
-
-
Save sbz/e740f0aba62b9eab3fba968751ab9951 to your computer and use it in GitHub Desktop.
pypi-requires.py: List packages dependencies using pypi API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
import requests | |
from pprint import pprint | |
def main() -> int: | |
if sys.argv[0] == 1: | |
print(f"Usage: {sys.argv[0]} <package==version>|<package>|<package> <version>") | |
return 1 | |
if "==" in sys.argv[1]: | |
name, version = sys.argv[1].split("==") | |
else: | |
name = sys.argv[1] | |
version = sys.argv[2] or None | |
# name = 'prefect' | |
# version = '2.5.0' | |
if version is None: | |
url = f'https://pypi.python.org/pypi/{name}/json' | |
else: | |
url = f'https://pypi.python.org/pypi/{name}/{version}/json' | |
response = requests.get(url) | |
response.raise_for_status() | |
data = response.json() | |
for req in data['info']['requires_dist']: | |
if "extra == 'dev'" in req: | |
continue | |
print(req) | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check dependencies of paramiko