diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 7c86ab154..1f678b773 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -23,6 +23,11 @@ jobs: python -m pip install --upgrade pip pip install -U -r requirements.txt + - name: Ensure dist build is valid + run: | + mkdir -p dist + python -m build --sdist --wheel --outdir dist/ . + - name: Print version run: python -m redel --version diff --git a/.gitignore b/.gitignore index 9ad3e3e97..014547ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -151,6 +151,19 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ +# Viz gitignore (for sdist) +logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* +node_modules +dist +dist-ssr +coverage +*.local + .kanpai/ .redel/ .temp/ diff --git a/pyproject.toml b/pyproject.toml index 577e6e5ec..ac70ea05e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,20 @@ web = [ [tool.hatch] version.path = "redel/_version.py" +[tool.hatch.build.hooks.custom] +path = "scripts/hatch_build.py" + +[tool.hatch.build.targets.sdist] +exclude = [ + "sandbox", + "viz", +] + +[tool.hatch.build.targets.wheel] +artifacts = [ + "redel/server/viz_dist", +] + [tool.black] line-length = 120 preview = true diff --git a/scripts/hatch_build.py b/scripts/hatch_build.py new file mode 100644 index 000000000..2539120d3 --- /dev/null +++ b/scripts/hatch_build.py @@ -0,0 +1,18 @@ +import subprocess +from pathlib import Path + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + + +class BuildFrontend(BuildHookInterface): + PLUGIN_NAME = "build_frontend" + FRONTEND_DIR_PATH = Path(__file__).parents[1] / "viz" + + def initialize(self, version, build_data): + subprocess.run( + args=["npm", "run", "build"], + cwd=self.FRONTEND_DIR_PATH, + check=True, + ) + + return super().initialize(version, build_data)