Changeset View
Standalone View
setup.py
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | setup( | ||||
setup_requires=['vcversioner'], | setup_requires=['vcversioner'], | ||||
extras_require={'testing': parse_requirements('test')}, | extras_require={'testing': parse_requirements('test')}, | ||||
vcversioner={'version_module_paths': ['swh/lister/_version.py']}, | vcversioner={'version_module_paths': ['swh/lister/_version.py']}, | ||||
include_package_data=True, | include_package_data=True, | ||||
entry_points=''' | entry_points=''' | ||||
[console_scripts] | [console_scripts] | ||||
swh-lister=swh.lister.cli:cli | swh-lister=swh.lister.cli:cli | ||||
[swh.cli.subcommands] | [swh.cli.subcommands] | ||||
lister=swh.lister.cli:lister | lister=swh.lister.cli:lister | ||||
[swh.workers] | |||||
lister.bitbucket=swh.lister.bitbucket:register | |||||
lister.cgit=swh.lister.cgit:register | |||||
lister.cran=swh.lister.cran:register | |||||
lister.debian=swh.lister.debian:register | |||||
lister.github=swh.lister.github:register | |||||
lister.gitlab=swh.lister.gitlab:register | |||||
anlambert: We should build that list dynamically instead of hardcoding it. This will ease the adding of… | |||||
Done Inline ActionsNo you cannot, that's the whole point of this idea: being able to declare plugins without having to load every possible python package or (recursively?) look for them in "some well known places". I did not want to force listers to be 'installed' in a 'swh.lister' namespace (in the sense of PEP420 ). Using this method based on entry points, a lister can be anywhere and does not need to lies within our swh namespace, and it is effectively loaded only if needed. I did implement the main swh.lister as plugins here mainly to show how it can be done. These default/basic listers could come with the main swh.lister package (preloaded) without using the plugin mechanism. This is debatable. TBH, I'm far from convinced this 'register' function is fine as it is in this diff (neither the data structure returned by the function nor the function name, however this later can be anything, since it's fully in the entrypoint declaration). douardda: No you cannot, that's the whole point of this idea: being able to **declare** plugins without… | |||||
lister.gnu=swh.lister.gnu:register | |||||
lister.npm=swh.lister.npm:register | |||||
lister.packagist=swh.lister.packagist:register | |||||
lister.phabricator=swh.lister.phabricator:register | |||||
lister.pypi=swh.lister.pypi:register | |||||
''', | ''', | ||||
classifiers=[ | classifiers=[ | ||||
"Programming Language :: Python :: 3", | "Programming Language :: Python :: 3", | ||||
"Intended Audience :: Developers", | "Intended Audience :: Developers", | ||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||||
"Operating System :: OS Independent", | "Operating System :: OS Independent", | ||||
"Development Status :: 5 - Production/Stable", | "Development Status :: 5 - Production/Stable", | ||||
], | ], | ||||
project_urls={ | project_urls={ | ||||
'Bug Reports': 'https://forge.softwareheritage.org/maniphest', | 'Bug Reports': 'https://forge.softwareheritage.org/maniphest', | ||||
'Funding': 'https://www.softwareheritage.org/donate', | 'Funding': 'https://www.softwareheritage.org/donate', | ||||
'Source': 'https://forge.softwareheritage.org/source/swh-lister', | 'Source': 'https://forge.softwareheritage.org/source/swh-lister', | ||||
}, | }, | ||||
) | ) |
We should build that list dynamically instead of hardcoding it. This will ease the adding of new listers.
Iterating on the sub-directories of the swh/lister folder could do the trick (core and tests must be
excluded though).
Other solution, import every submodules from swh.lister and check the presence of the register
function to determine if it is a plugin or not.