Debian Codegraph @

python/mach/docs/driver.rst

raw
1 .. _mach_driver:
2
3 =======
4 Drivers
5 =======
6
7 Entry Points
8 ============
9
10 It is possible to use setuptools' entry points to load commands
11 directly from python packages. A mach entry point is a function which
12 returns a list of files or directories containing mach command
13 providers. e.g.:
14
15 .. code-block:: python
16
17 def list_providers():
18 providers = []
19 here = os.path.abspath(os.path.dirname(__file__))
20 for p in os.listdir(here):
21 if p.endswith('.py'):
22 providers.append(os.path.join(here, p))
23 return providers
24
25 See http://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins
26 for more information on creating an entry point. To search for entry
27 point plugins, you can call
28 :py:meth:`mach.command_util.load_commands_from_entry_point`. e.g.:
29
30 .. code-block:: python
31
32 load_commands_from_entry_point("mach.external.providers")