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

compat: Bokeh upper pin policy #776

Merged
merged 3 commits into from
Dec 16, 2024
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
32 changes: 27 additions & 5 deletions geoviews/models/custom_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
from functools import cache

from bokeh import __version__ as bokeh_version
from bokeh.core.properties import Any, Dict, Instance, List, String
from bokeh.models import ColumnDataSource, PolyDrawTool, PolyEditTool, Tool
from packaging.requirements import Requirement

from .._warnings import warn


class _BokehCheck(Tool):
_bokeh_require_version = "bokeh ==3.6.*"
def __init__(self, *args, **kwargs):
self._check_bokeh_version()
super().__init__(*args, **kwargs)

@classmethod
@cache
def _check_bokeh_version(cls) -> None:
bokeh_req = Requirement(cls._bokeh_require_version)
if bokeh_req.specifier.contains(bokeh_version):
return
msg = f"{cls.__name__} only official supported with {cls._bokeh_require_version}, you have {bokeh_version} installed."
warn(msg, RuntimeWarning)


class CheckpointTool(Tool):
class CheckpointTool(_BokehCheck, Tool):
"""
Checkpoints the data on the supplied ColumnDataSources, allowing
the RestoreTool to restore the data to a previous state.
Expand All @@ -11,7 +33,7 @@ class CheckpointTool(Tool):
sources = List(Instance(ColumnDataSource))


class RestoreTool(Tool):
class RestoreTool(_BokehCheck, Tool):
"""
Restores the data on the supplied ColumnDataSources to a previous
checkpoint created by the CheckpointTool
Expand All @@ -20,15 +42,15 @@ class RestoreTool(Tool):
sources = List(Instance(ColumnDataSource))


class ClearTool(Tool):
class ClearTool(_BokehCheck, Tool):
"""
Clears the data on the supplied ColumnDataSources.
"""

sources = List(Instance(ColumnDataSource))


class PolyVertexEditTool(PolyEditTool):
class PolyVertexEditTool(_BokehCheck, PolyEditTool):

node_style = Dict(String, Any, help="""
Custom styling to apply to the intermediate nodes of a patch or line glyph.""")
Expand All @@ -37,7 +59,7 @@ class PolyVertexEditTool(PolyEditTool):
Custom styling to apply to the start and nodes of a patch or line glyph.""")


class PolyVertexDrawTool(PolyDrawTool):
class PolyVertexDrawTool(_BokehCheck, PolyDrawTool):

node_style = Dict(String, Any, help="""
Custom styling to apply to the intermediate nodes of a patch or line glyph.""")
Expand Down
22 changes: 22 additions & 0 deletions geoviews/tests/plotting/bokeh/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pathlib import Path

import pytest

from geoviews.models.custom_tools import _BokehCheck


def test_bokeh_version():
# Can be removed when minimum Python version is 3.11
tomllib = pytest.importorskip("tomllib")

pyproject = Path(__file__).parents[4] / "pyproject.toml"
pyproject.resolve(strict=True)
requires = tomllib.loads(pyproject.read_text())["build-system"]["requires"]

for req in requires:
if req.startswith("bokeh"):
break
else:
raise ValueError("Bokeh not found in build-system requires")

assert req == _BokehCheck._bokeh_require_version
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling", "hatch-vcs", 'bokeh ==3.6']
requires = ["hatchling", "hatch-vcs", 'bokeh ==3.6.*']
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -27,7 +27,7 @@ classifiers = [
]

dependencies = [
'bokeh >=3.6.0,<3.7.0',
'bokeh >=3.6.0',
'cartopy >=0.18.0',
'holoviews >=1.16.0',
'numpy',
Expand Down
Loading