ocebuild.third_party#

Vendored third-party dependencies

Subpackages#

Package Contents#

Functions#

inject_module(→ None)

Injects a module into the current Python runtime.

inject_module_namespace() → Set[str])

Injects all exported names from a module into the current namespace.

ocebuild.third_party.inject_module(name: str, module: str) None[source]#

Injects a module into the current Python runtime.

This will override all consumers of the module, which may cause unexpected behavior if the new module is not compatible with the current runtime.

Note that if a module is imported before this function is called, it will not be updated with the new module. This is useful for overriding modules that are imported by other dependencies or library consumers.

Use this function with extreme caution!

Parameters:
  • name – The name of the module to inject.

  • module – The module path to inject.

ocebuild.third_party.inject_module_namespace(module, exclude: set | None = None, namespace=globals()) Set[str][source]#

Injects all exported names from a module into the current namespace.

This excludes built-ins and duplicate names to ensure no existing names are overwritten. This is useful for extending existing modules that may have internal names that are not exported.

Parameters:
  • module – The module to inject.

  • exclude – A set of names to exclude from the module. (Optional)

  • namespace – The namespace to inject the module into. (Default: globals())

Returns:

A set of all injected names.