{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/31218","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/31218/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/31218/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/31218/events","html_url":"https://github.com/saltstack/salt/pull/31218","id":133706226,"number":31218,"title":"Allow loading external modules using setuptools entry points","user":{"login":"s0undt3ch","id":300048,"avatar_url":"https://avatars.githubusercontent.com/u/300048?v=3","gravatar_id":"","url":"https://api.github.com/users/s0undt3ch","html_url":"https://github.com/s0undt3ch","followers_url":"https://api.github.com/users/s0undt3ch/followers","following_url":"https://api.github.com/users/s0undt3ch/following{/other_user}","gists_url":"https://api.github.com/users/s0undt3ch/gists{/gist_id}","starred_url":"https://api.github.com/users/s0undt3ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s0undt3ch/subscriptions","organizations_url":"https://api.github.com/users/s0undt3ch/orgs","repos_url":"https://api.github.com/users/s0undt3ch/repos","events_url":"https://api.github.com/users/s0undt3ch/events{/privacy}","received_events_url":"https://api.github.com/users/s0undt3ch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-15T12:59:09Z","updated_at":"2016-02-16T18:59:05Z","closed_at":"2016-02-16T17:41:52Z","pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/31218","html_url":"https://github.com/saltstack/salt/pull/31218","diff_url":"https://github.com/saltstack/salt/pull/31218.diff","patch_url":"https://github.com/saltstack/salt/pull/31218.patch"},"body":"Since I was unable to find the right document to properly document this addition, here's what should be added to said document.\r\n\r\n# External Modules Setuptools Entry-Points Support\r\n\r\nThe salt loader was enhanced to look for external modules by looking at the `salt.loader` [entry-point](https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins).\r\nIf [`pkg_resources`](https://pythonhosted.org/setuptools/pkg_resources.html) is available(which it should if setuptools is installed).\r\n\r\nThe package which has custom engines, minion modules, outputters, etc, should require setuptools and should define the following entry points in it's setup function:\r\n\r\n```python\r\nfrom setuptools import setup, find_packages\r\n\r\nsetup(name=<NAME>,\r\n      version=<VERSION>,\r\n      description=<DESC>,\r\n      author=<AUTHOR>,\r\n      author_email=<AUTHOR-EMAIL>,\r\n      url=' ... ',\r\n      packages=find_packages(),\r\n      entry_points='''\r\n        [salt.loader]\r\n        engines_dirs = <package>.<loader-module>:engines_dirs\r\n        fileserver_dirs = <package>.<loader-module>:fileserver_dirs\r\n        pillar_dirs = <package>.<loader-module>:pillar_dirs\r\n        returner_dirs = <package>.<loader-module>:returner_dirs\r\n        roster_dirs = <package>.<loader-module>:roster_dirs\r\n      ''')\r\n```\r\n\r\nThe above setup script example mentions a loader module, here's an example of how `<package>/<loader-module>.py` should look like:\r\n```python\r\n# -*- coding: utf-8 -*-\r\n\r\n# Import python libs\r\nimport os\r\n\r\nPKG_DIR = os.path.abspath(os.path.dirname(__file__))\r\n\r\n\r\ndef engines_dirs():\r\n    '''\r\n    yield one path per parent directory of where engines can be found\r\n    '''\r\n    yield os.path.join(PKG_DIR, 'engines_1')\r\n    yield os.path.join(PKG_DIR, 'engines_2')\r\n\r\n\r\ndef fileserver_dirs():\r\n    '''\r\n    yield one path per parent directory of where fileserver modules can be found\r\n    '''\r\n    yield os.path.join(PKG_DIR, 'fileserver')\r\n\r\n\r\ndef pillar_dirs():\r\n    '''\r\n    yield one path per parent directory of where external pillar modules can be found\r\n    '''\r\n    yield os.path.join(PKG_DIR, 'pillar')\r\n\r\n\r\ndef returner_dirs():\r\n    '''\r\n    yield one path per parent directory of where returner modules can be found\r\n    '''\r\n    yield os.path.join(PKG_DIR, 'returners')\r\n\r\n\r\ndef roster_dirs():\r\n    '''\r\n    yield one path per parent directory of where roster modules can be found\r\n    '''\r\n    yield os.path.join(PKG_DIR, 'roster')\r\n```\r\n\r\n----\r\nRefs https://github.com/saltstack/salt/issues/31206"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/184830905","html_url":"https://github.com/saltstack/salt/pull/31218#issuecomment-184830905","issue_url":"https://api.github.com/repos/saltstack/salt/issues/31218","id":184830905,"user":{"login":"s0undt3ch","id":300048,"avatar_url":"https://avatars.githubusercontent.com/u/300048?v=3","gravatar_id":"","url":"https://api.github.com/users/s0undt3ch","html_url":"https://github.com/s0undt3ch","followers_url":"https://api.github.com/users/s0undt3ch/followers","following_url":"https://api.github.com/users/s0undt3ch/following{/other_user}","gists_url":"https://api.github.com/users/s0undt3ch/gists{/gist_id}","starred_url":"https://api.github.com/users/s0undt3ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s0undt3ch/subscriptions","organizations_url":"https://api.github.com/users/s0undt3ch/orgs","repos_url":"https://api.github.com/users/s0undt3ch/repos","events_url":"https://api.github.com/users/s0undt3ch/events{/privacy}","received_events_url":"https://api.github.com/users/s0undt3ch/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T18:59:05Z","updated_at":"2016-02-16T18:59:05Z","body":"Thanks!"}}