METADATA 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Metadata-Version: 2.1
  2. Name: pluggy
  3. Version: 1.0.0
  4. Summary: plugin and hook calling mechanisms for python
  5. Home-page: https://github.com/pytest-dev/pluggy
  6. Author: Holger Krekel
  7. Author-email: holger@merlinux.eu
  8. License: MIT
  9. Platform: unix
  10. Platform: linux
  11. Platform: osx
  12. Platform: win32
  13. Classifier: Development Status :: 6 - Mature
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: MIT License
  16. Classifier: Operating System :: POSIX
  17. Classifier: Operating System :: Microsoft :: Windows
  18. Classifier: Operating System :: MacOS :: MacOS X
  19. Classifier: Topic :: Software Development :: Testing
  20. Classifier: Topic :: Software Development :: Libraries
  21. Classifier: Topic :: Utilities
  22. Classifier: Programming Language :: Python :: Implementation :: CPython
  23. Classifier: Programming Language :: Python :: Implementation :: PyPy
  24. Classifier: Programming Language :: Python :: 3
  25. Classifier: Programming Language :: Python :: 3 :: Only
  26. Classifier: Programming Language :: Python :: 3.6
  27. Classifier: Programming Language :: Python :: 3.7
  28. Classifier: Programming Language :: Python :: 3.8
  29. Classifier: Programming Language :: Python :: 3.9
  30. Requires-Python: >=3.6
  31. Description-Content-Type: text/x-rst
  32. License-File: LICENSE
  33. Requires-Dist: importlib-metadata (>=0.12) ; python_version < "3.8"
  34. Provides-Extra: dev
  35. Requires-Dist: pre-commit ; extra == 'dev'
  36. Requires-Dist: tox ; extra == 'dev'
  37. Provides-Extra: testing
  38. Requires-Dist: pytest ; extra == 'testing'
  39. Requires-Dist: pytest-benchmark ; extra == 'testing'
  40. ====================================================
  41. pluggy - A minimalist production ready plugin system
  42. ====================================================
  43. |pypi| |conda-forge| |versions| |github-actions| |gitter| |black| |codecov|
  44. This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.
  45. Please `read the docs`_ to learn more!
  46. A definitive example
  47. ====================
  48. .. code-block:: python
  49. import pluggy
  50. hookspec = pluggy.HookspecMarker("myproject")
  51. hookimpl = pluggy.HookimplMarker("myproject")
  52. class MySpec:
  53. """A hook specification namespace."""
  54. @hookspec
  55. def myhook(self, arg1, arg2):
  56. """My special little hook that you can customize."""
  57. class Plugin_1:
  58. """A hook implementation namespace."""
  59. @hookimpl
  60. def myhook(self, arg1, arg2):
  61. print("inside Plugin_1.myhook()")
  62. return arg1 + arg2
  63. class Plugin_2:
  64. """A 2nd hook implementation namespace."""
  65. @hookimpl
  66. def myhook(self, arg1, arg2):
  67. print("inside Plugin_2.myhook()")
  68. return arg1 - arg2
  69. # create a manager and add the spec
  70. pm = pluggy.PluginManager("myproject")
  71. pm.add_hookspecs(MySpec)
  72. # register plugins
  73. pm.register(Plugin_1())
  74. pm.register(Plugin_2())
  75. # call our ``myhook`` hook
  76. results = pm.hook.myhook(arg1=1, arg2=2)
  77. print(results)
  78. Running this directly gets us::
  79. $ python docs/examples/toy-example.py
  80. inside Plugin_2.myhook()
  81. inside Plugin_1.myhook()
  82. [-1, 3]
  83. .. badges
  84. .. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
  85. :target: https://pypi.org/pypi/pluggy
  86. .. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
  87. :target: https://pypi.org/pypi/pluggy
  88. .. |github-actions| image:: https://github.com/pytest-dev/pluggy/workflows/main/badge.svg
  89. :target: https://github.com/pytest-dev/pluggy/actions
  90. .. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pluggy.svg
  91. :target: https://anaconda.org/conda-forge/pytest
  92. .. |gitter| image:: https://badges.gitter.im/pytest-dev/pluggy.svg
  93. :alt: Join the chat at https://gitter.im/pytest-dev/pluggy
  94. :target: https://gitter.im/pytest-dev/pluggy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  95. .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
  96. :target: https://github.com/ambv/black
  97. .. |codecov| image:: https://codecov.io/gh/pytest-dev/pluggy/branch/master/graph/badge.svg
  98. :target: https://codecov.io/gh/pytest-dev/pluggy
  99. :alt: Code coverage Status
  100. .. links
  101. .. _pytest:
  102. http://pytest.org
  103. .. _tox:
  104. https://tox.readthedocs.org
  105. .. _devpi:
  106. http://doc.devpi.net
  107. .. _read the docs:
  108. https://pluggy.readthedocs.io/en/latest/