From e475dffc95f5d95e11082734f967437fe1565b65 Mon Sep 17 00:00:00 2001 From: Benjamin Bohard Date: Wed, 25 Mar 2020 14:35:05 +0100 Subject: [PATCH] Load services as submodules --- debian/control | 1 + script/{server.py => risotto.py} | 1 + setup.py | 9 +++++++++ src/risotto/__init__.py | 15 ++++++++++++--- 4 files changed, 23 insertions(+), 3 deletions(-) rename script/{server.py => risotto.py} (92%) create mode 100644 setup.py diff --git a/debian/control b/debian/control index 5baa84b..b291644 100644 --- a/debian/control +++ b/debian/control @@ -11,3 +11,4 @@ Architecture: any Pre-Depends: dpkg, python3, ${misc:Pre-Depends} Depends: ${python:Depends}, ${misc:Depends} Description: configuration manager + diff --git a/script/server.py b/script/risotto.py similarity index 92% rename from script/server.py rename to script/risotto.py index d6b37b7..6273d8b 100644 --- a/script/server.py +++ b/script/risotto.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from asyncio import get_event_loop from risotto import get_app diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..29f1cbb --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +from setuptools import setup, find_packages + +setup( + name='risotto', + version='0.1', + packages=['risotto' ], + scripts=['script/risotto.py'], + package_dir={"": "src"}, + ) diff --git a/src/risotto/__init__.py b/src/risotto/__init__.py index 0c67d85..5756fda 100644 --- a/src/risotto/__init__.py +++ b/src/risotto/__init__.py @@ -1,4 +1,13 @@ +from pkg_resources import iter_entry_points + +class Service: + pass + +services = Service() +for ep in iter_entry_points(group='risotto_services'): + setattr(services, ep.name, ep.load()) + +def list_modules(): + return services from .http import get_app - -__ALL__ = ('get_app',) - +__ALL__ = ('get_app', 'services')