Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/docs-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
# To add a new release version: append an entry under `versions:`, and update
# `default:` / `stable:` if the new release should become the landing page.

default: "1.0.0" # served at the site root (microsoft.github.io/PyRIT/)
stable: "1.0.0" # served at /stable/ and shown as "(stable)" in the picker
default: "1.0.1" # served at the site root (microsoft.github.io/PyRIT/)
stable: "1.0.1" # served at /stable/ and shown as "(stable)" in the picker

versions:
- slug: latest
name: "latest (dev, main)"
ref: main
- slug: "1.0.0"
name: "1.0.0"
ref: releases/v1.0.0
- slug: "1.0.1"
name: "1.0.1"
ref: releases/v1.0.1
- slug: "0.14.0"
name: "0.14.0"
ref: releases/v0.14.0
Expand Down
22 changes: 21 additions & 1 deletion build_scripts/prepare_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@
This builds the TypeScript/React frontend and copies artifacts into the Python package structure.
"""

import contextlib
import shutil
import subprocess
import sys
from pathlib import Path


def _configure_utf8_stdio() -> None:
"""
Force UTF-8 encoding on stdout/stderr so status glyphs cannot abort the build.

On Windows, Python encodes standard output with the legacy ANSI code page (e.g. cp1252)
whenever it is not attached to a console -- piped, redirected, or captured by CI. The
non-ASCII status characters printed below are not representable there, so the print
raises ``UnicodeEncodeError`` and a purely decorative character fails the build.
"""
for stream in (sys.stdout, sys.stderr):
reconfigure = getattr(stream, "reconfigure", None)
if reconfigure is None:
continue
with contextlib.suppress(OSError, ValueError):
reconfigure(encoding="utf-8", errors="replace")


def build_frontend(frontend_dir: Path) -> bool:
"""
Build the TypeScript/React frontend using npm.
Expand Down Expand Up @@ -116,8 +134,10 @@ def copy_frontend_to_package(frontend_dist: Path, backend_frontend: Path) -> boo
return False


def main():
def main() -> int:
"""Build frontend and prepare package for distribution."""
_configure_utf8_stdio()

# Define paths
root = Path(__file__).parent.parent
frontend_dir = root / "frontend"
Expand Down
Loading