Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdk-core: adopt pluggy 1.3 #2614

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions projects/vdk-core/src/vdk/api/plugin/plugin_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ class PluginException(Exception):
"""
Alias for the type of plugin hook call result returned in hookWrapper=True types of plugin hooks
"""
HookCallResult = (
pluggy.callers._Result if pluggy.__version__ < "1.0" else pluggy._callers._Result
)


def parse_version(version_str):
return tuple(map(int, version_str.split(".")))


if parse_version(pluggy.__version__) < parse_version("1.0"):
HookCallResult = pluggy.callers._Result
elif parse_version(pluggy.__version__) < parse_version("1.3"):
HookCallResult = pluggy._callers._Result
else: # since 1.3
HookCallResult = pluggy.Result


class IPluginRegistry(metaclass=ABCMeta):
Expand Down
5 changes: 4 additions & 1 deletion projects/vdk-plugins/build-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pip install -U pip setuptools
pip install --upgrade --extra-index-url $PIP_EXTRA_INDEX_URL -r requirements.txt
pip install --upgrade -e . --extra-index-url $PIP_EXTRA_INDEX_URL

if [ -n "${USE_VDKCORE_DEV_VERSION}" ] ; then pip install -e ../../vdk-core; fi

# List exceptions to below check here.
# Those are not technically plugins so they would not have entry point defined.
if [ "$PLUGIN_NAME" != 'quickstart-vdk' ] && \
Expand All @@ -25,6 +27,8 @@ then
if ! vdk version 2>&1 | grep -q "$PLUGIN_NAME"; then
echo "Plugin entry point seems to be mis-configured."
echo "Make sure to set setup.py entry_points for the plugin or update an exception case in above if statement."
echo "Running vdk version:"
vdk version
exit 1
else
echo "Check passed."
Expand All @@ -33,6 +37,5 @@ fi

pip install pytest-cov

if [ -n "${USE_VDKCORE_DEV_VERSION}" ] ; then pip install -e ../../vdk-core; fi

pytest --junitxml=tests.xml --cov vdk --cov-report term-missing --cov-report xml:coverage.xml