From 3b5486948a3f126c6746ed8354201ba478d71675 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Mon, 10 Jan 2022 15:04:47 -0800 Subject: [PATCH] Add dependency on deephaven-plugin (#2) --- .github/workflows/build.yml | 9 ++++++++- README.md | 2 +- setup.cfg | 3 ++- src/deephaven/plugin/matplotlib/__init__.py | 13 +++++++------ src/deephaven/plugin/matplotlib/figure_type.py | 5 +++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b595e18..dbc9c7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: run: python -m pip install --upgrade setuptools wheel build - name: Build wheel - run: python -m build --wheel + run: python -m build - name: Upload dist uses: actions/upload-artifact@v2 @@ -30,3 +30,10 @@ jobs: name: dist path: dist/ if-no-files-found: error + + - name: Publish package + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} diff --git a/README.md b/README.md index a9ce4e9..ad0d6e6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To create your build / development environment: ```sh python3 -m venv .venv source .venv/bin/activate -pip install --upgrade pip setuptools build matplotlib +pip install --upgrade pip setuptools build deephaven-plugin matplotlib ``` To build: diff --git a/setup.cfg b/setup.cfg index 1640d22..d212da3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,6 +25,7 @@ package_dir= =src packages=find_namespace: install_requires = + deephaven-plugin matplotlib [options.packages.find] @@ -32,4 +33,4 @@ where=src [options.entry_points] deephaven.plugin = - register_into = deephaven.plugin.matplotlib:register_into + registration_cls = deephaven.plugin.matplotlib:MatplotlibRegistration diff --git a/src/deephaven/plugin/matplotlib/__init__.py b/src/deephaven/plugin/matplotlib/__init__.py index 2bcf764..c590514 100644 --- a/src/deephaven/plugin/matplotlib/__init__.py +++ b/src/deephaven/plugin/matplotlib/__init__.py @@ -1,8 +1,9 @@ -__version__ = "0.0.1.dev2" +from deephaven.plugin import Registration -def register_into(callback): - register_object_types_into(callback) +__version__ = "0.0.1.dev4" -def register_object_types_into(callback): - from . import figure_type - callback.register_object_type(figure_type.FigureType()) +class MatplotlibRegistration(Registration): + @classmethod + def register_into(cls, callback: Registration.Callback) -> None: + from . import figure_type + callback.register(figure_type.FigureType) diff --git a/src/deephaven/plugin/matplotlib/figure_type.py b/src/deephaven/plugin/matplotlib/figure_type.py index d800ca0..4a3a826 100644 --- a/src/deephaven/plugin/matplotlib/figure_type.py +++ b/src/deephaven/plugin/matplotlib/figure_type.py @@ -1,9 +1,10 @@ from io import BytesIO from matplotlib.figure import Figure +from deephaven.plugin.object import Exporter, ObjectType NAME = "matplotlib.figure.Figure" -class FigureType: +class FigureType(ObjectType): @property def name(self) -> str: return NAME @@ -11,7 +12,7 @@ def name(self) -> str: def is_type(self, object) -> bool: return isinstance(object, Figure) - def to_bytes(self, exporter, figure: Figure) -> bytes: + def to_bytes(self, exporter: Exporter, figure: Figure) -> bytes: buf = BytesIO() figure.savefig(buf, format='PNG') return buf.getvalue()