From 72011446e137fc9b84b9d3e6c505afdbc87aba53 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 27 Mar 2025 15:16:09 +0100 Subject: [PATCH 1/5] Use pyproject.toml --- .github/workflows/docs-deploy.yml | 6 +-- .github/workflows/screenshots.yml | 2 +- MANIFEST.in | 4 -- fastplotlib/VERSION | 1 - fastplotlib/__init__.py | 4 +- fastplotlib/_version.py | 5 ++ pyproject.toml | 77 ++++++++++++++++++++++++++++++- setup.py | 76 ------------------------------ 8 files changed, 86 insertions(+), 89 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 fastplotlib/VERSION create mode 100644 fastplotlib/_version.py delete mode 100644 setup.py diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index a0cb54357..470e2e5a5 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -40,7 +40,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools # remove pygfx from install_requires, we install using pygfx@main - sed -i "/pygfx/d" ./setup.py + sed -i "/pygfx/d" ./pyproject.toml pip install git+https://github.com/pygfx/pygfx.git@main pip install -e ".[docs,notebook,imgui]" - name: Show wgpu backend @@ -68,7 +68,7 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} # any push to main goes to fastplotlib.org/ver/dev run: echo "DOCS_VERSION_DIR=dev" >> "$GITHUB_ENV" - + # upload docs via SCP - name: Deploy docs uses: appleboy/scp-action@v0.1.7 @@ -90,7 +90,7 @@ jobs: with: message: | 📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/${{ env.DOCS_VERSION_DIR }} - + # upload docs via SCP - name: Deploy docs release if: ${{ github.ref_type == 'tag' }} diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 0985fc179..cfaf419b8 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -36,7 +36,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools # remove pygfx from install_requires, we install using pygfx@main - sed -i "/pygfx/d" ./setup.py + sed -i "/pygfx/d" ./pyproject.toml pip install git+https://github.com/pygfx/pygfx.git@main - name: Install fastplotlib run: | diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index b8debd28d..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -recursive-include fastplotlib/utils/colormaps/ * -include fastplotlib/VERSION -recursive-include fastplotlib/assets/ * - diff --git a/fastplotlib/VERSION b/fastplotlib/VERSION deleted file mode 100644 index 1d0ba9ea1..000000000 --- a/fastplotlib/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.4.0 diff --git a/fastplotlib/__init__.py b/fastplotlib/__init__.py index 7eb9554e8..8ee461da9 100644 --- a/fastplotlib/__init__.py +++ b/fastplotlib/__init__.py @@ -1,5 +1,6 @@ from pathlib import Path +from ._version import __version__, version_info # this must be the first import for auto-canvas detection from .utils import loop # noqa from .graphics import * @@ -20,9 +21,6 @@ from .utils import config, enumerate_adapters, select_adapter, print_wgpu_report -with open(Path(__file__).parent.joinpath("VERSION"), "r") as f: - __version__ = f.read().split("\n")[0] - if len(enumerate_adapters()) < 1: from warnings import warn diff --git a/fastplotlib/_version.py b/fastplotlib/_version.py new file mode 100644 index 000000000..4fa907364 --- /dev/null +++ b/fastplotlib/_version.py @@ -0,0 +1,5 @@ +__version__ = "0.4.0" + +version_info = tuple( + int(i) if i.isnumeric() else i for i in __version__.split("+")[0].split(".") +) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4d957aee3..567edccdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,78 @@ +# ===== Project info + +[project] +dynamic = ["version"] +name = "fastplotlib" +description = "Next-gen fast plotting library running on WGPU using the pygfx rendering engine " +readme = "README.md" +license = { file = "LICENSE" } +authors = [{ name = "Kushal Kolar" }, { name = "Caitlin Lewis" }] +keywords = [ + "visualization", + "science", + "interactive", + "pygfx", + "webgpu", + "wgpu", + "vulkan", + "gpu", +] +requires-python = ">= 3.10" +dependencies = ["numpy>=1.23.0", "pygfx~=0.9.0", "wgpu>=0.20.0", "cmap>=0.1.3"] + +[project.optional-dependencies] +docs = [ + "sphinx", + "sphinx-gallery", + "pydata-sphinx-theme", + "glfw", + "ipywidgets>=8.0.0,<9", + "sphinx-copybutton", + "sphinx-design", + "pandoc", + "imageio[ffmpeg]", + "matplotlib", + "scikit-learn", +] +notebook = [ + "jupyterlab", + "jupyter-rfb>=0.5.1", + "ipywidgets>=8.0.0,<9", + "sidecar", +] +tests = [ + "pytest", + "nbmake", + "black", + "scipy", + "imageio[ffmpeg]", + "scikit-learn", + "tqdm", +] +imgui = ["imgui-bundle"] +dev = ["fastplotlib[docs,notebook,tests,imgui]"] + +[project.urls] +Homepage = "https://www.fastplotlib.org/" +Documentation = "https://www.fastplotlib.org/" +Repository = "https://github.com/fastplotlib/fastplotlib" + +# ===== Building + [build-system] -requires = ["setuptools", "wheel"] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +# ===== Tooling + +# [tool.ruff] +# line-length = 88 +# [tool.ruff.lint] +# select = ["F", "E", "W", "N", "B", "RUF", "TC"] +# ignore = [ +# "E501", # Line too long +# "E731", # Do not assign a `lambda` expression, use a `def` +# "B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +# "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`" +# ] diff --git a/setup.py b/setup.py deleted file mode 100644 index 3ca95de0f..000000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -from setuptools import setup, find_packages -from pathlib import Path - - -install_requires = [ - "numpy>=1.23.0", - "pygfx~=0.9.0", - "wgpu>=0.20.0", - "cmap>=0.1.3", -] - - -extras_require = { - "docs": [ - "sphinx", - "sphinx-gallery", - "pydata-sphinx-theme", - "glfw", - "ipywidgets>=8.0.0,<9", - "sphinx-copybutton", - "sphinx-design", - "pandoc", - "imageio[ffmpeg]", - "matplotlib", - "scikit-learn", - ], - "notebook": [ - "jupyterlab", - "jupyter-rfb>=0.5.1", - "ipywidgets>=8.0.0,<9", - "sidecar", - ], - "tests": [ - "pytest", - "nbmake", - "black", - "scipy", - "imageio[ffmpeg]", - "scikit-learn", - "tqdm", - ], - "imgui": ["imgui-bundle"], -} - - -with open(Path(__file__).parent.joinpath("README.md")) as f: - readme = f.read() - -with open(Path(__file__).parent.joinpath("fastplotlib", "VERSION"), "r") as f: - ver = f.read().split("\n")[0] - - -classifiers = [ - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering :: Visualization", - "License :: OSI Approved :: Apache Software License", - "Intended Audience :: Science/Research", -] - - -setup( - name="fastplotlib", - version=ver, - long_description=readme, - long_description_content_type="text/markdown", - packages=find_packages(), - url="https://github.com/fastplotlib/fastplotlib", - license="Apache 2.0", - author="Kushal Kolar, Caitlin Lewis", - author_email="", - python_requires=">=3.10", - install_requires=install_requires, - extras_require=extras_require, - include_package_data=True, - description="A fast plotting library built using the pygfx render engine", -) From 968296b1ebba6720bf98f5dfbb057477b28990a6 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 27 Mar 2025 15:22:56 +0100 Subject: [PATCH 2/5] forgot to safe --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0274add7d..528b62772 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools # remove pygfx from install_requires, we install using pygfx@main - sed -i "/pygfx/d" ./setup.py + sed -i "/pygfx/d" ./pyproject.toml pip install git+https://github.com/pygfx/pygfx.git@main - name: Install fastplotlib run: | From a89107e5424a87594ee41101f0523fbae81deebb Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 27 Mar 2025 15:24:18 +0100 Subject: [PATCH 3/5] black --- fastplotlib/__init__.py | 1 + fastplotlib/_version.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fastplotlib/__init__.py b/fastplotlib/__init__.py index 8ee461da9..6d92efffa 100644 --- a/fastplotlib/__init__.py +++ b/fastplotlib/__init__.py @@ -1,6 +1,7 @@ from pathlib import Path from ._version import __version__, version_info + # this must be the first import for auto-canvas detection from .utils import loop # noqa from .graphics import * diff --git a/fastplotlib/_version.py b/fastplotlib/_version.py index 4fa907364..11b3e538b 100644 --- a/fastplotlib/_version.py +++ b/fastplotlib/_version.py @@ -2,4 +2,4 @@ version_info = tuple( int(i) if i.isnumeric() else i for i in __version__.split("+")[0].split(".") -) \ No newline at end of file +) From 872d9cff3be83f8064df439372049d60c5a55fd8 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Fri, 28 Mar 2025 10:02:31 +0100 Subject: [PATCH 4/5] tweak to allow sed to do its thing --- pyproject.toml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 567edccdf..846c9070b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] dynamic = ["version"] name = "fastplotlib" -description = "Next-gen fast plotting library running on WGPU using the pygfx rendering engine " +description = "Next-gen fast plotting library running on WGPU using the Pygfx rendering engine " readme = "README.md" license = { file = "LICENSE" } authors = [{ name = "Kushal Kolar" }, { name = "Caitlin Lewis" }] @@ -18,7 +18,13 @@ keywords = [ "gpu", ] requires-python = ">= 3.10" -dependencies = ["numpy>=1.23.0", "pygfx~=0.9.0", "wgpu>=0.20.0", "cmap>=0.1.3"] +dependencies = [ + "numpy>=1.23.0", + "pygfx>=0.9.0", + "wgpu>=0.20.0", + "cmap>=0.1.3", + # (this comment keeps this list multiline in VSCode) +] [project.optional-dependencies] docs = [ From be61a444f5919baf541837561d309874ef418ea6 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Fri, 28 Mar 2025 10:11:55 +0100 Subject: [PATCH 5/5] black that one file that ci complains about --- fastplotlib/layouts/_graphic_methods_mixin.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fastplotlib/layouts/_graphic_methods_mixin.py b/fastplotlib/layouts/_graphic_methods_mixin.py index a04b681f5..a753eec73 100644 --- a/fastplotlib/layouts/_graphic_methods_mixin.py +++ b/fastplotlib/layouts/_graphic_methods_mixin.py @@ -32,7 +32,7 @@ def add_image( interpolation: str = "nearest", cmap_interpolation: str = "linear", isolated_buffer: bool = True, - **kwargs + **kwargs, ) -> ImageGraphic: """ @@ -78,7 +78,7 @@ def add_image( interpolation, cmap_interpolation, isolated_buffer, - **kwargs + **kwargs, ) def add_line_collection( @@ -96,7 +96,7 @@ def add_line_collection( metadatas: Union[Sequence[Any], numpy.ndarray] = None, isolated_buffer: bool = True, kwargs_lines: list[dict] = None, - **kwargs + **kwargs, ) -> LineCollection: """ @@ -169,7 +169,7 @@ def add_line_collection( metadatas, isolated_buffer, kwargs_lines, - **kwargs + **kwargs, ) def add_line( @@ -183,7 +183,7 @@ def add_line( cmap_transform: Union[numpy.ndarray, Iterable] = None, isolated_buffer: bool = True, size_space: str = "screen", - **kwargs + **kwargs, ) -> LineGraphic: """ @@ -234,7 +234,7 @@ def add_line( cmap_transform, isolated_buffer, size_space, - **kwargs + **kwargs, ) def add_line_stack( @@ -253,7 +253,7 @@ def add_line_stack( separation: float = 10.0, separation_axis: str = "y", kwargs_lines: list[dict] = None, - **kwargs + **kwargs, ) -> LineStack: """ @@ -334,7 +334,7 @@ def add_line_stack( separation, separation_axis, kwargs_lines, - **kwargs + **kwargs, ) def add_scatter( @@ -349,7 +349,7 @@ def add_scatter( sizes: Union[float, numpy.ndarray, Iterable[float]] = 1, uniform_size: bool = False, size_space: str = "screen", - **kwargs + **kwargs, ) -> ScatterGraphic: """ @@ -409,7 +409,7 @@ def add_scatter( sizes, uniform_size, size_space, - **kwargs + **kwargs, ) def add_text( @@ -422,7 +422,7 @@ def add_text( screen_space: bool = True, offset: tuple[float] = (0, 0, 0), anchor: str = "middle-center", - **kwargs + **kwargs, ) -> TextGraphic: """ @@ -473,5 +473,5 @@ def add_text( screen_space, offset, anchor, - **kwargs + **kwargs, )