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.2.tar.gz (8.9 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.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pothenon-0.0.2.tar.gz
  • Upload date:
  • Size: 8.9 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.2.tar.gz
Algorithm Hash digest
SHA256 a58bda97cbefb00d42302e4f2640fe8d4eb5fb5eb889e412f84bd58426912117
MD5 319c4fd616353c838858f1e10b219662
BLAKE2b-256 71fb4e6dcaec81e5859b9dd4341ba8e0488781a2b2c5eaf64df6ecf50c31055e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pothenon-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7de3aa3fc4175f6f7e04791d1ab3257824d7bc9d3f24c10d51bd1344394d99a5
MD5 27324984fa1df680da650f7e6b27938b
BLAKE2b-256 e2001540474c30f02b95e12e8acea656ccd9bc568ff7e3478942212828f0292c

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