METADATA 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. Metadata-Version: 2.1
  2. Name: pluggy
  3. Version: 1.2.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.7
  27. Classifier: Programming Language :: Python :: 3.8
  28. Classifier: Programming Language :: Python :: 3.9
  29. Classifier: Programming Language :: Python :: 3.10
  30. Classifier: Programming Language :: Python :: 3.11
  31. Requires-Python: >=3.7
  32. Description-Content-Type: text/x-rst
  33. License-File: LICENSE
  34. Requires-Dist: importlib-metadata (>=0.12) ; python_version < "3.8"
  35. Provides-Extra: dev
  36. Requires-Dist: pre-commit ; extra == 'dev'
  37. Requires-Dist: tox ; extra == 'dev'
  38. Provides-Extra: testing
  39. Requires-Dist: pytest ; extra == 'testing'
  40. Requires-Dist: pytest-benchmark ; extra == 'testing'
  41. ====================================================
  42. pluggy - A minimalist production ready plugin system
  43. ====================================================
  44. |pypi| |conda-forge| |versions| |github-actions| |gitter| |black| |codecov|
  45. This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.
  46. Please `read the docs`_ to learn more!
  47. A definitive example
  48. ====================
  49. .. code-block:: python
  50. import pluggy
  51. hookspec = pluggy.HookspecMarker("myproject")
  52. hookimpl = pluggy.HookimplMarker("myproject")
  53. class MySpec:
  54. """A hook specification namespace."""
  55. @hookspec
  56. def myhook(self, arg1, arg2):
  57. """My special little hook that you can customize."""
  58. class Plugin_1:
  59. """A hook implementation namespace."""
  60. @hookimpl
  61. def myhook(self, arg1, arg2):
  62. print("inside Plugin_1.myhook()")
  63. return arg1 + arg2
  64. class Plugin_2:
  65. """A 2nd hook implementation namespace."""
  66. @hookimpl
  67. def myhook(self, arg1, arg2):
  68. print("inside Plugin_2.myhook()")
  69. return arg1 - arg2
  70. # create a manager and add the spec
  71. pm = pluggy.PluginManager("myproject")
  72. pm.add_hookspecs(MySpec)
  73. # register plugins
  74. pm.register(Plugin_1())
  75. pm.register(Plugin_2())
  76. # call our ``myhook`` hook
  77. results = pm.hook.myhook(arg1=1, arg2=2)
  78. print(results)
  79. Running this directly gets us::
  80. $ python docs/examples/toy-example.py
  81. inside Plugin_2.myhook()
  82. inside Plugin_1.myhook()
  83. [-1, 3]
  84. .. badges
  85. .. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
  86. :target: https://pypi.org/pypi/pluggy
  87. .. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
  88. :target: https://pypi.org/pypi/pluggy
  89. .. |github-actions| image:: https://github.com/pytest-dev/pluggy/workflows/main/badge.svg
  90. :target: https://github.com/pytest-dev/pluggy/actions
  91. .. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pluggy.svg
  92. :target: https://anaconda.org/conda-forge/pytest
  93. .. |gitter| image:: https://badges.gitter.im/pytest-dev/pluggy.svg
  94. :alt: Join the chat at https://gitter.im/pytest-dev/pluggy
  95. :target: https://gitter.im/pytest-dev/pluggy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  96. .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
  97. :target: https://github.com/ambv/black
  98. .. |codecov| image:: https://codecov.io/gh/pytest-dev/pluggy/branch/master/graph/badge.svg
  99. :target: https://codecov.io/gh/pytest-dev/pluggy
  100. :alt: Code coverage Status
  101. .. links
  102. .. _pytest:
  103. http://pytest.org
  104. .. _tox:
  105. https://tox.readthedocs.org
  106. .. _devpi:
  107. http://doc.devpi.net
  108. .. _read the docs:
  109. https://pluggy.readthedocs.io/en/latest/