From f614eeabf34a542b3c09a75d3023b7c76a292727 Mon Sep 17 00:00:00 2001 From: Paddy Mullen Date: Sat, 28 Dec 2024 10:34:02 -0500 Subject: [PATCH] working on the hatch build step --- pyproject.toml | 19 +++++++++++++++++-- scripts/hatch_build.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 scripts/hatch_build.py diff --git a/pyproject.toml b/pyproject.toml index 35a6e74..85e02a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ classifiers = [ ] dependencies = [ "anywidget >= 0.9.0", - "ipyreact", "graphlib_backport>=1.0.0", "packaging>=18" ] @@ -41,8 +40,19 @@ version = "0.8.0" [project.license] file = "LICENSE.txt" + + +[tool.uv] +dev-dependencies = [ + "anywidget[dev]>=0.9.0", + "jupyterlab>=4.2.5", + "ruff>=0.6.2", + "polars>=1.5.0", +] + + [project.optional-dependencies] -dev = ["watchfiles", "jupyterlab"] +dev = ["watchfiles", "jupyterlab", "anywidget[dev]>=0.9.0",] test = [ "nbval>=0.9", @@ -76,6 +86,11 @@ docs = [ [project.urls] Homepage = "https://github.com/paddymul/buckaroo" +[tool.hatch.build] +only-packages = true + +[tool.hatch.envs.default] +installer = "uv" [tool.hatch.build.targets.wheel] include = [ diff --git a/scripts/hatch_build.py b/scripts/hatch_build.py new file mode 100644 index 0000000..025f867 --- /dev/null +++ b/scripts/hatch_build.py @@ -0,0 +1,31 @@ +"""A Hatchling plugin to build the quak frontend.""" + +import os +import pathlib +import subprocess + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + +ROOT = pathlib.Path(__file__).parent / ".." + + +class BuckarooBuildHook(BuildHookInterface): + """Hatchling plugin to build the quak frontend.""" + + PLUGIN_NAME = "buckaroo_hatch" + + def initialize(self, version: str, build_data: dict) -> None: + """Initialize the plugin.""" + # if os.getenv("SKIP_DENO_BUILD", "0") == "1": + # # Skip the build if the environment variable is set + # # Useful in CI/CD pipelines + # return + + + bjs_core_root = ROOT / "packages/buckaroo-js-core" + if not (bjs_core_root / "dist/index.esm.js").exists(): + subprocess.check_call(["npm", "install"], cwd=bjs_core_root) + subprocess.check_call(["npm", "run", "build"], cwd=bjs_core_root) + subprocess.check_call(["npm", "install"], cwd=ROOT) + subprocess.check_call(["npm", "run", "build"], cwd=ROOT) +