Knowledge on Python script's dependencies - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: Knowledge on Python script's dependencies (/thread-37370.html) |
Knowledge on Python script's dependencies - almahdi - Jun-02-2022 How can we know a Python script's dependencies recursively, entirely ie. of any kind of subroutines including of Python itself? RE: Knowledge on Python script's dependencies - Larz60+ - Jun-02-2022 you can get this from https://pypi.org/pypi/package/json (replace module with actual package name) then use index ["info"]["requires_dist"] from your python script or simply open url and search for "requires_dist" you can also find required python version with ["info"]["requires_python"] or search "requires_python" Edit 10:46 PM EDT Here's a quick module that will get the info import requests import json from pathlib import Path import sys def get_dependencies(package_name): pkginfo = {} url = f"https://pypi.org/pypi/{package_name}/json" response = requests.get(url) if response.status_code == 200: pkginfo = json.loads(response.content) else: print(f"Unable to fetch url: {url}") sys.exit(-1) print(f"\nOther packages: {pkginfo['info']['requires_dist']}") print(f"python versions: {pkginfo['info']['requires_python']}") def main(): get_dependencies('pyflowchart') if __name__ == '__main__': main()results: To get the full list, follow the tree as each dependency may also have it's own dependencies.
|