Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/apache_release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,34 @@ def create_release_artifacts(package_config: dict, version) -> list[str]:
if os.path.exists("dist"):
shutil.rmtree("dist")

# For the UI package, build the frontend before packaging.
if package_name == "apache-hamilton-ui":
print("Building UI frontend (npm install + npm run build)...")
frontend_dir = os.path.join(original_dir, "ui", "frontend")
build_target = os.path.join("hamilton_ui", "build")
try:
subprocess.run(
["npm", "install", "--prefix", frontend_dir],
check=True,
)
subprocess.run(
["npm", "run", "build", "--prefix", frontend_dir],
check=True,
)
# Copy built assets to hamilton_ui/build/
if os.path.exists(build_target):
shutil.rmtree(build_target)
# Vite outputs to frontend/dist/, CRA outputs to frontend/build/
frontend_build = os.path.join(frontend_dir, "dist")
if not os.path.exists(frontend_build):
frontend_build = os.path.join(frontend_dir, "build")
shutil.copytree(frontend_build, build_target)
print(f"Frontend built and copied to {build_target}")
except (subprocess.CalledProcessError, FileNotFoundError) as e:
print(f"Error building frontend: {e}")
print("Ensure Node.js and npm are installed.")
return None

# Use flit build to create the source distribution.
try:
subprocess.run(
Expand Down
22 changes: 22 additions & 0 deletions scripts/verify-sub-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ See `examples/hamilton_ui/` — the same example above.

## apache-hamilton-ui

### Building from source (requires Node.js + npm)

The UI package includes compiled frontend assets. When building from source,
you must build the frontend first:

```bash
cd ui/frontend
npm install
npm run build

# Copy built assets to the backend package
rm -rf ../backend/hamilton_ui/build
cp -r dist/ ../backend/hamilton_ui/build/

# Now build the wheel
cd ../backend
flit build --no-use-vcs
```

The release script (`scripts/apache_release_helper.py --package ui`) handles
this automatically.

### Install and verify

```bash
Expand Down
7 changes: 6 additions & 1 deletion scripts/verify-sub-packages/verify_ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ build_dir="/tmp/build-ui-$$"
mkdir -p "$build_dir"
tar xzf "$ARTIFACTS_DIR/$SRC_TAR" -C "$build_dir"
src_dir=$(ls -d ${build_dir}/*/ | head -1)

# Note: The UI source tarball does not include compiled frontend assets.
# The release script builds the frontend (npm run build) before flit build.
# Here we verify the backend builds correctly; the wheel from SVN includes
# the pre-compiled frontend and is what's tested in step 6.
if (cd "$src_dir" && flit build --no-use-vcs) 2>&1 | grep -q "Built wheel"; then
echo " ✓ Built from source successfully"
echo " ✓ Built from source successfully (backend only, frontend is pre-compiled in wheel)"
else
echo " ✗ Build from source failed"
rm -rf "$build_dir"
Expand Down