morepath.autosetup – Configuration Automation

This module defines functionality to automatically configure Morepath.

morepath.scan(), morepath.autoscan() are part of the public API.

morepath.autosetup.import_package(distribution)

Takes a pkg_resources distribution and loads the module contained in it, if it matches the rules layed out in morepath.autoscan().

morepath.autosetup.import_package(distribution)

Takes a pkg_resources distribution and loads the module contained in it, if it matches the rules layed out in morepath.autoscan().

class morepath.autosetup.DependencyMap

A registry that tracks dependencies between distributions.

Used by morepath_packages() to find installed Python distributions that depend on Morepath, directly or indirectly.

depends(project_name, on_project_name, visited=None)

Check whether project transitively depends on another.

A project depends on another project if it directly or indirectly requires the other project.

Parameters:
  • project_name – Python distribution name.
  • on_project_name – Python distribution name it depends on.
Returns:

True if project_name depends on on_project_name.

load()

Fill the registry with dependency information.

relevant_dists(on_project_name)

Iterable of distributions that depend on project.

Dependency is transitive.

Parameters:on_project_name – Python distribution name
Returns:iterable of Python distribution objects that depend on project
morepath.autosetup.get_module_name(distribution)

Determines the module name to import from the given distribution.

If an entry point named scan is found in the group morepath, it’s value is used. If not, the project_name is used.

See morepath.autoscan() for details and an example.

morepath.autosetup.caller_module(level=2)

Give module where calling function is defined.

Level:levels deep to look up the stack frame
Returns:a Python module
morepath.autosetup.caller_package(level=2)

Give package where calling function is defined.

Level:levels deep to look up the stack frame
Returns:a Python module (representing the __init__.py of a package)