Skip to content

Commit a2007b5

Browse files
authored
Merge pull request #42 from dwhswenson/namespace-plugins
Fix up namespace plugins
2 parents 9d20fb0 + 48eef51 commit a2007b5

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.github/workflows/test-suite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: "Tests"
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- main
77
- stable
88
push:
99
branches:
10-
- master
10+
- main
1111
tags:
1212
- "v*"
1313
schedule:

docs/plugins.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ If the plugin is part of a larger Python package, or if it is important to
8989
track version numbers or to be able to change which plugins are installed
9090
in particular Python environments, the namespace distribution mechanism is a
9191
better choice. We use `native namespace packages`_, which is a standard way
92-
of making plugins in Python. Plugins should be in the ``paths_cli.plugins``
92+
of making plugins in Python. Plugins should be in the ``paths_cli_plugins``
9393
namespace.
9494

9595
.. _native namespace packages:

paths_cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def app_dir_plugins(posix):
3434
FilePluginLoader(commands),
3535
FilePluginLoader(app_dir_plugins(posix=False)),
3636
FilePluginLoader(app_dir_plugins(posix=True)),
37-
NamespacePluginLoader('paths_cli.plugins')
37+
NamespacePluginLoader('paths_cli_plugins')
3838
]
3939

4040
plugins = sum([loader() for loader in self.plugin_loaders], [])

paths_cli/plugin_management.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ def iter_namespace(ns_pkg):
120120
return pkgutil.iter_modules(ns_pkg.__path__,
121121
ns_pkg.__name__ + ".")
122122

123-
ns = importlib.import_module(self.search_path)
124-
candidates = [
125-
importlib.import_module(name)
126-
for _, name, _ in iter_namespace(ns)
127-
]
123+
try:
124+
ns = importlib.import_module(self.search_path)
125+
except ModuleNotFoundError:
126+
candidates = []
127+
else:
128+
candidates = [
129+
importlib.import_module(name)
130+
for _, name, _ in iter_namespace(ns)
131+
]
128132
return candidates
129133

130134
@staticmethod

0 commit comments

Comments
 (0)