Skip to main content

pothenon

pothenon is a dependency parser for Python functions and classes. Given a callable or class, it inspects the object's source code and resolves each external symbol it references to its originating Python package, including the package's version where available.

Installation

pip install pothenon

Usage

from pothenon import dependency_parser

Resolving dependencies of a user-defined function

When a function calls another function that is defined in the same (local) scope, pothenon reports that function together with its own dependencies:

import json
from math import sqrt

def add_one(x):
    return x + 1

def get_sqrt(x):
    return sqrt(x)

def my_operation(x):
    y = add_one(x)
    z = get_sqrt(y)
    return z

def dump_operation(x):
    y = my_operation(x)
    return json.dumps(y)

print(dependency_parser.get_full_source(dump_operation))
"""
import json

from math import sqrt

def get_sqrt(x):
    return sqrt(x)

def add_one(x):
    return x + 1

def my_operation(x):
    y = add_one(x)
    z = get_sqrt(y)
    return z

def dump_operation(x):
    y = my_operation(x)
    return json.dumps(y)
"""

API

dependency_parser.get_call_dependencies(func)

Analyses func and returns a CallDependencies dict mapping each external symbol name to a PackageInfo named tuple with the following fields:

Field Description
localname The name by which the symbol is referenced inside func
info A VersionInfo with module, qualname, and version
source_code Source code of the dependency (local callables only)
dependency Recursively resolved dependencies of the dependency

dependency_parser.split_by_version_availability(call_dependencies)

Partitions a CallDependencies dict into two dicts: one for dependencies that have a version string and one for those that do not.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pothenon-0.0.3.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pothenon-0.0.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file pothenon-0.0.3.tar.gz.

File metadata

  • Download URL: pothenon-0.0.3.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pothenon-0.0.3.tar.gz
Algorithm Hash digest
SHA256 10ba0b7d4396451ad09740bc84dd8d5e54d13679da2d3e3c241f5c92258b1e33
MD5 0015efaadbb1e79ddd7c2d9dc7350b6a
BLAKE2b-256 c200894154f2ad20bd7ad38c03e78dd3fe39812aae93328c980f501aad367bf5

See more details on using hashes here.

File details

Details for the file pothenon-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pothenon-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pothenon-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f053cabf1623d2e6244815306d8232f8bf60c591ff11f88fcaffbd7487aefb3f
MD5 926a536869c0733d60f8d56941182c5f
BLAKE2b-256 3794ad61810d48fcf7cd3f35bd366b0f153984b7129690fd0c33d5abf4fc3437

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page