Skip to content

Commit

Permalink
build: build viz on pypi release
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Jul 29, 2024
1 parent 96e314b commit 95cbd77
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions scripts/hatch_build.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 95cbd77

Please sign in to comment.