bots: Find external packaged bots via 'zulip_bots.registry' entry_point.

Now we will be able to execute `zulip-run-bot` with the `-r` argument
to search for and run bots from the `zulip_bots.registry` entry_point.

Each entry point should have the name correspond to the bot name,
and have the value be the bot module. E.g, an Python package for a
bot called "packaged_bot" should have an `entry_points` setup like
the following:

setup(
    ...
    entry_points={
        "zulip_bot.registry":[
            "packaged_bot=packaged_bot.packaged_bot"
        ]
    }
    ...
)

whose file structure may look like this:

packaged_bot/
├───packaged_bot/
|   ├───packaged_bot.py  # The bot module
|   ├───test_packaged_bot.py
|   ├───packaged_bot.conf
|   └───doc.md
└───setup.py  # Register the entry points here

Add test case.
This commit is contained in:
PIG208 2021-07-22 12:13:40 +08:00 committed by Tim Abbott
parent 4fd29baf2b
commit 4bc0c607c1
4 changed files with 94 additions and 24 deletions

View file

@ -66,6 +66,7 @@ setuptools_info = dict(
"lxml",
"BeautifulSoup4",
"typing_extensions",
'importlib-metadata >= 3.6; python_version < "3.10"',
],
)