{"library":"pycg","title":"PyCG - Practical Python Call Graphs","description":"PyCG is a tool for generating call graphs for Python code using static analysis. It produces call graphs in JSON format and supports Python >=3.4. The current version on PyPI is 0.0.8. Development is relatively low activity; last commits on GitHub appear to be from 2022. The primary use case is understanding static call relationships in Python programs.","language":"python","status":"maintenance","last_verified":"Fri May 01","install":{"commands":["pip install pycg"],"cli":{"name":"pycg","version":"sh: 1: pycg: not found"}},"imports":["from pycg import CallGraphGenerator","from pycg import formats"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from pycg import CallGraphGenerator\nfrom pycg import formats\n\n# Example: generate call graph for a single file\n# Note: pycg works best with a top-level script entry point\n# For this example, we'll assume you have a file 'myscript.py'\n# that defines functions and calls.\n# The generator returns a dictionary of call edges.\n\ngenerator = CallGraphGenerator(['myscript.py'], 'myscript')\n# The second argument is the package name (usually module name)\ngenerator.analyze()\n\n# Get call graph in JSON format\nformatter = formats.JSONFormatter(generator)\noutput = formatter.generate()\nprint(output)\n","lang":"python","description":"Basic usage to generate a JSON call graph for a Python file. Note that pycg expects a list of file paths and a package name.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}