From 05705ded65258d4f8be73306d96e5362116c71f1 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Wed, 3 Feb 2021 11:50:26 +0100 Subject: [PATCH] Use package directory to namespace modules --- __init__.py | 0 epicyon/README.md | 5 +++++ epicyon/__init__.py | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 __init__.py create mode 100644 epicyon/README.md create mode 100644 epicyon/__init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/epicyon/README.md b/epicyon/README.md new file mode 100644 index 000000000..8cb99765d --- /dev/null +++ b/epicyon/README.md @@ -0,0 +1,5 @@ +# Epicyon Pypi package + +This is a wrapper package for the purpose of gathering all modules under the +`epicyon` namespace when doing Python module imports. With this wrapper +package, you can get `from epicyon import httpsig` instead of `import httpsig`. diff --git a/epicyon/__init__.py b/epicyon/__init__.py new file mode 100644 index 000000000..a437682e1 --- /dev/null +++ b/epicyon/__init__.py @@ -0,0 +1,23 @@ +"""Pypi package module namespce wrapper. + +We do this automation based importing to take all Epicyon modules in under this +package namespace in one go. This way we do not have to maintain a module list +here just for the Pypi packaging effort and package builds will automatically +pick up new modules as we go forward. +""" + +from pathlib import Path +from pkgutil import walk_packages + +__all__ = [] + +package_root = str(Path(".").parent.absolute()) + +for loader, module_name, is_pkg in walk_packages([package_root]): + __all__.append(module_name) + + if module_name == "epicyon": + continue + + _module = loader.find_module(module_name).load_module(module_name) + globals()[module_name] = _module