Skip to content

Commit

Permalink
Merge pull request #5686 from patrys/automatic-plugin-discovery
Browse files Browse the repository at this point in the history
Automatic plugin discovery
  • Loading branch information
maarcingebala committed May 28, 2020
2 parents 753e293 + 9e244ac commit 8b4c790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .isort.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions saleor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import django_cache_url
import jaeger_client
import jaeger_client.config
import pkg_resources
import sentry_sdk
from django.core.exceptions import ImproperlyConfigured
from django.core.management.utils import get_random_secret_key
Expand Down Expand Up @@ -518,6 +519,15 @@ def get_host():
"saleor.payment.gateways.razorpay.plugin.RazorpayGatewayPlugin",
]

# Plugin discovery
installed_plugins = pkg_resources.iter_entry_points("saleor.plugins")
for entry_point in installed_plugins:
plugin_path = "{}.{}".format(entry_point.module_name, entry_point.attrs[0])
if plugin_path not in PLUGINS:
if entry_point.name not in INSTALLED_APPS:
INSTALLED_APPS.append(entry_point.name)
PLUGINS.append(plugin_path)

if (
not DEBUG
and ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL
Expand Down

0 comments on commit 8b4c790

Please sign in to comment.