Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pytest-dev/pluggy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.9.0
Choose a base ref
...
head repository: pytest-dev/pluggy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.10.0
Choose a head ref

Commits on Feb 24, 2019

  1. Skip tests when deploying

    nicoddemus committed Feb 24, 2019
    Copy the full SHA
    f32dee0 View commit details
  2. Merge pull request #192 from nicoddemus/release-0.9.0

    Preparing release 0.9.0
    nicoddemus authored Feb 24, 2019
    Copy the full SHA
    61f67e0 View commit details
  3. Merge pull request #193 from nicoddemus/skip-tests-on-deploy

    Skip tests when deploying
    nicoddemus authored Feb 24, 2019
    Copy the full SHA
    758c00d View commit details

Commits on Feb 28, 2019

  1. Fix typo

    ingwinlu authored Feb 28, 2019
    Copy the full SHA
    1874468 View commit details
  2. Add eggsample setup.py

    ingwinlu authored Feb 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0867847 View commit details
  3. Merge pull request #194 from ingwinlu/patch-1

    Minor documentation improvements
    nicoddemus authored Feb 28, 2019
    Copy the full SHA
    3ef4ff8 View commit details

Commits on Mar 1, 2019

  1. Fix method name add_hookspecs in docstring

    Jakob Kogler authored and Jakob Kogler committed Mar 1, 2019
    Copy the full SHA
    52c98ab View commit details
  2. Merge pull request #195 from jakobkogler/docstring_typo

    Fix method name `add_hookspecs` in docstring
    nicoddemus authored Mar 1, 2019
    Copy the full SHA
    4f98685 View commit details

Commits on Mar 6, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ee26b8d View commit details
  2. Merge pull request #196 from jakobkogler/doc_classname_example_fix

    Fix class name of plugin in example
    nicoddemus authored Mar 6, 2019
    Copy the full SHA
    4ea9711 View commit details

Commits on Mar 23, 2019

  1. Copy the full SHA
    70cb026 View commit details
  2. Copy the full SHA
    e0ad955 View commit details
  3. ci: Travis: dist=xenial

    blueyed committed Mar 23, 2019
    Copy the full SHA
    e654da4 View commit details
  4. tox.ini: pytest: addopts, testpaths

    norecursedirs is not necessary anymore with testpaths.
    blueyed committed Mar 23, 2019
    Copy the full SHA
    4223913 View commit details
  5. doc fix: is_blocked

    blueyed committed Mar 23, 2019
    Copy the full SHA
    29c1a96 View commit details

Commits on Mar 25, 2019

  1. Merge pull request #198 from blueyed/cfg

    Revisit config
    nicoddemus authored Mar 25, 2019
    Copy the full SHA
    cbd4e3a View commit details
  2. Copy the full SHA
    1af4173 View commit details

Commits on Mar 26, 2019

  1. Merge pull request #197 from blueyed/cov

    Setup coverage reporting
    nicoddemus authored Mar 26, 2019
    Copy the full SHA
    59b3cf2 View commit details

Commits on Apr 7, 2019

  1. Copy the full SHA
    9550fc3 View commit details
  2. Copy the full SHA
    491cefe View commit details

Commits on Apr 20, 2019

  1. Fix test for DistFacade

    asottile committed Apr 20, 2019
    Copy the full SHA
    e387587 View commit details
  2. Copy the full SHA
    66b2a13 View commit details

Commits on Apr 21, 2019

  1. Copy the full SHA
    f282a42 View commit details
  2. Invoke tox directly (?)

    asottile committed Apr 21, 2019
    Copy the full SHA
    0706fba View commit details
  3. Merge pull request #200 from asottile/fix_pre_commit_config

    pre-commit autoupdate + fix config
    nicoddemus authored Apr 21, 2019
    Copy the full SHA
    4de9e44 View commit details

Commits on May 5, 2019

  1. Switch to importlib-metadata (#199)

    Switch to importlib-metadata
    nicoddemus authored May 5, 2019
    Copy the full SHA
    8749791 View commit details

Commits on May 6, 2019

  1. Add changelog for #199

    asottile committed May 6, 2019
    Copy the full SHA
    b1d68ba View commit details
  2. Copy the full SHA
    f1f2e3c View commit details
  3. Add changelog for #199 (#201)

    Add changelog for #199
    nicoddemus authored May 6, 2019
    Copy the full SHA
    f4eb6b4 View commit details

Commits on May 7, 2019

  1. Preparing release 0.10.0

    nicoddemus committed May 7, 2019
    Copy the full SHA
    97262e8 View commit details
Showing with 132 additions and 104 deletions.
  1. +14 −0 .coveragerc
  2. +6 −6 .pre-commit-config.yaml
  3. +26 −16 .travis.yml
  4. +8 −0 CHANGELOG.rst
  5. +5 −1 README.rst
  6. +1 −1 appveyor.yml
  7. +4 −5 docs/conf.py
  8. +6 −2 docs/index.rst
  9. +31 −23 pluggy/manager.py
  10. +1 −0 setup.py
  11. +21 −45 testing/test_pluginmanager.py
  12. +9 −5 tox.ini
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[run]
include =
pluggy/*
testing/*
*/lib/python*/site-packages/pluggy/*
*/pypy*/site-packages/pluggy/*
*\Lib\site-packages\pluggy\*
branch = 1

[paths]
source = pluggy/
*/lib/python*/site-packages/pluggy/
*/pypy*/site-packages/pluggy/
*\Lib\site-packages\pluggy\
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.6b4
rev: 19.3b0
hooks:
- id: black
args: [--safe, --quiet]
language_version: python3.6
- repo: https://github.com/asottile/blacken-docs
rev: v0.2.0
rev: v0.5.0
hooks:
- id: blacken-docs
additional_dependencies: [black==18.6b4]
additional_dependencies: [black==19.3b0]
language_version: python3.6
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
rev: v2.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -25,8 +25,8 @@ repos:
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
python_version: python3.6
language_version: python3.6
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.0.0
rev: v1.3.0
hooks:
- id: rst-backticks
42 changes: 26 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
sudo: false
dist: xenial
language: python

stages:
- test
- name: test
if: tag IS NOT present
- name: deploy
if: repo = pytest-dev/pluggy AND tag IS present

jobs:
include:
- python: '3.6'
env: TOXENV=linting
cache:
directories:
- $HOME/.cache/pre-commit
- python: '3.6'
env: TOXENV=docs
- python: '2.7'
env: TOXENV=py27-pytestrelease
env: TOXENV=py27-pytestrelease-coverage
- python: '3.4'
env: TOXENV=py34-pytestrelease
env: TOXENV=py34-pytestrelease-coverage
- python: '3.5'
env: TOXENV=py35-pytestrelease
env: TOXENV=py35-pytestrelease-coverage
- python: '3.6'
env: TOXENV=py36-pytestrelease
- python: 'pypy'
env: TOXENV=pypy-pytestrelease
- python: 'pypy3.5'
env: TOXENV=pypy3-pytestrelease
- python: 'nightly'
env: TOXENV=py37-pytestrelease
env: TOXENV=py36-pytestrelease-coverage
- python: 'pypy2.7-6.0'
env: TOXENV=pypy-pytestrelease-coverage
- python: 'pypy3.5-6.0'
env: TOXENV=pypy3-pytestrelease-coverage
- python: '3.7'
env: TOXENV=py37-pytestrelease-coverage
- python: '2.7'
env: TOXENV=py27-pytestmaster
env: TOXENV=py27-pytestmaster-coverage
- python: '2.7'
env: TOXENV=py27-pytestfeatures
env: TOXENV=py27-pytestfeatures-coverage
- python: '3.6'
env: TOXENV=py36-pytestmaster
env: TOXENV=py36-pytestmaster-coverage
- python: '3.6'
env: TOXENV=py36-pytestfeatures
env: TOXENV=py36-pytestfeatures-coverage
- python: '3.6'
env: TOXENV=benchmark

@@ -60,6 +64,12 @@ install:
script:
- tox

after_script:
- |
if [[ "${TOXENV%-coverage}" != "$TOXENV" ]]; then
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV
fi
notifications:
irc:
channels:
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -55,6 +55,14 @@ Changelog

.. towncrier release notes start
pluggy 0.10.0 (2019-05-07)
==========================

Features
--------

- `#199 <https://github.com/pytest-dev/pluggy/issues/199>`_: Switch from ``pkg_resources`` to ``importlib-metadata`` for entrypoint detection for improved performance and import time.


pluggy 0.7.1 (2018-07-28)
=========================
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
pluggy - A minimalist production ready plugin system
====================================================

|pypi| |conda-forge| |versions| |travis| |appveyor| |gitter| |black|
|pypi| |conda-forge| |versions| |travis| |appveyor| |gitter| |black| |codecov|

This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.

@@ -85,6 +85,10 @@ A definitive example
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black

.. |codecov| image:: https://codecov.io/gh/pytest-dev/pluggy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/pytest-dev/pluggy
:alt: Code coverage Status

.. links
.. _pytest:
http://pytest.org
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ install:
build: false # Not a C# project, build stuff at the test step instead.

test_script:
- C:\Python35\python -m tox
- C:\Python35\Scripts\tox

# We don't deploy anything on tags with AppVeyor, we use Travis instead, so we
# might as well save resources
9 changes: 4 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import pkg_resources
import importlib_metadata


extensions = [
@@ -20,14 +20,13 @@

# General information about the project.

dist = pkg_resources.get_distribution("pluggy")
project = dist.project_name
project = "pluggy"
copyright = u"2016, Holger Krekel"
author = "Holger Krekel"

release = dist.version
release = importlib_metadata.version(project)
# The short X.Y version.
version = u".".join(dist.version.split(".")[:2])
version = u".".join(release.split(".")[:2])


language = None
8 changes: 6 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -122,6 +122,10 @@ The host

.. literalinclude:: examples/eggsample/eggsample/host.py

``eggsample/setup.py``

.. literalinclude:: examples/eggsample/setup.py

Let's get cooking - we install the host and see what a program run looks like::

$ pip install --editable pluggy/docs/examples/eggsample
@@ -308,7 +312,7 @@ will be executed *first* or *last* respectively in the hook call loop:
# load from the local module's namespace
pm.register(sys.modules[__name__])
# load a plugin defined on a class
pm.register(SomePlugin())
pm.register(SomeOtherPlugin())
For another example see the `hook function ordering`_ section of the
``pytest`` docs.
@@ -558,7 +562,7 @@ definitions to populate the registry is described in detail in the section on

In summary, you pass a plugin namespace object to the
:py:meth:`~pluggy.PluginManager.register()` and
:py:meth:`~pluggy.PluginManager.add_hookspec()` methods to collect
:py:meth:`~pluggy.PluginManager.add_hookspecs()` methods to collect
hook *implementations* and *specifications* from *plugin* namespaces respectively.

You can unregister any *plugin*'s hooks using
54 changes: 31 additions & 23 deletions pluggy/manager.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
from .hooks import HookImpl, _HookRelay, _HookCaller, normalize_hookimpl_opts
import warnings

import importlib_metadata


def _warn_for_function(warning, function):
warnings.warn_explicit(
@@ -25,11 +27,28 @@ def __init__(self, plugin, message):
super(Exception, self).__init__(message)


class DistFacade(object):
"""Emulate a pkg_resources Distribution"""

def __init__(self, dist):
self._dist = dist

@property
def project_name(self):
return self.metadata["name"]

def __getattr__(self, attr, default=None):
return getattr(self._dist, attr, default)

def __dir__(self):
return sorted(dir(self._dist) + ["_dist", "project_name"])


class PluginManager(object):
""" Core Pluginmanager class which manages registration
of plugin objects and 1:N hook calling.
You can register new hooks by calling ``add_hookspec(module_or_class)``.
You can register new hooks by calling ``add_hookspecs(module_or_class)``.
You can register plugin objects (which contain hooks) by calling
``register(plugin)``. The Pluginmanager is initialized with a
prefix that is searched for in the names of the dict of registered
@@ -152,7 +171,7 @@ def set_blocked(self, name):
self._name2plugin[name] = None

def is_blocked(self, name):
""" return True if the name blogs registering plugins of that name. """
""" return True if the given plugin name is blocked. """
return name in self._name2plugin and self._name2plugin[name] is None

def add_hookspecs(self, module_or_class):
@@ -259,29 +278,18 @@ def load_setuptools_entrypoints(self, group, name=None):
:rtype: int
:return: return the number of loaded plugins by this call.
"""
from pkg_resources import (
iter_entry_points,
DistributionNotFound,
VersionConflict,
)

count = 0
for ep in iter_entry_points(group, name=name):
# is the plugin registered or blocked?
if self.get_plugin(ep.name) or self.is_blocked(ep.name):
continue
try:
for dist in importlib_metadata.distributions():
for ep in dist.entry_points:
if ep.group != group or (name is not None and ep.name != name):
continue
# is the plugin registered or blocked?
if self.get_plugin(ep.name) or self.is_blocked(ep.name):
continue
plugin = ep.load()
except DistributionNotFound:
continue
except VersionConflict as e:
raise PluginValidationError(
plugin=None,
message="Plugin %r could not be loaded: %s!" % (ep.name, e),
)
self.register(plugin, name=ep.name)
self._plugin_distinfo.append((plugin, ep.dist))
count += 1
self.register(plugin, name=ep.name)
self._plugin_distinfo.append((plugin, DistFacade(dist)))
count += 1
return count

def list_plugin_distinfo(self):
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ def main():
author_email="holger@merlinux.eu",
url="https://github.com/pytest-dev/pluggy",
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=["importlib-metadata>=0.9"],
extras_require={"dev": ["pre-commit", "tox"]},
classifiers=classifiers,
packages=["pluggy"],
Loading