diff --git a/build-all.sh b/build-all.sh index 97d9977..4f5be51 100755 --- a/build-all.sh +++ b/build-all.sh @@ -4,6 +4,26 @@ set -euo pipefail REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" +# Option: --pybricks-code copies built npm packages into that +# checkout's node_modules/@pybricks/ for easy local testing. +PYBRICKS_CODE="" +while [[ $# -gt 0 ]]; do + case "$1" in + --pybricks-code) + PYBRICKS_CODE="$(realpath "$2")" + shift 2 + ;; + *) + echo "usage: $0 [--pybricks-code ]" >&2 + exit 1 + ;; + esac +done +if [[ -n "$PYBRICKS_CODE" && ! -d "$PYBRICKS_CODE/node_modules/@pybricks" ]]; then + echo "error: $PYBRICKS_CODE/node_modules/@pybricks not found (run yarn install there first)" >&2 + exit 1 +fi + # Activate the project venv so python/make/etc. all use it without poetry run source "$REPO_ROOT/.venv/bin/activate" @@ -13,13 +33,19 @@ VERSION=$(grep '^version = ' "$REPO_ROOT/pyproject.toml" | head -1 | sed 's/vers NPM_VERSION=$(echo "$VERSION" | sed 's/\([0-9]\)a\([0-9]\)/\1-alpha.\2/;s/\([0-9]\)b\([0-9]\)/\1-beta.\2/;s/\([0-9]\)rc\([0-9]\)/\1-rc.\2/') echo "==> Building version $VERSION (npm: $NPM_VERSION)" -# lint +# lint (same as CI build.yml) echo "==> Linting" cd "$REPO_ROOT" -flake8 +ruff check +ruff format --check doc8 -# pybricks-jedi tests +# Python package +echo "==> Building Python package" +rm -rf "$REPO_ROOT/dist" # stale wheels would get globbed into the jedi npm package +poetry build + +# pybricks-jedi tests (own poetry env, same as CI jedi.yml) echo "==> Testing pybricks-jedi" cd "$REPO_ROOT/jedi" poetry run pytest -vv @@ -27,16 +53,37 @@ poetry run pytest -vv # @pybricks/jedi npm package echo "==> Building @pybricks/jedi" cd "$REPO_ROOT/jedi" +rm -rf dist # build.py globs dist/*.whl, stale wheels would get shipped python3 build.py "$NPM_VERSION" -# @pybricks/ide-docs npm package -echo "==> Building @pybricks/ide-docs" +# html docs for Read the Docs +echo "==> Building Read the Docs html docs" cd "$REPO_ROOT" +make -C doc clean html + +# @pybricks/ide-docs npm package (builds the TAG=ide docs) +echo "==> Building @pybricks/ide-docs" make -C doc clean cd "$REPO_ROOT/npm/ide-docs" yarn build echo "" echo "Build complete." +echo " python package : dist/" echo " jedi npm package : jedi/npm-build/" echo " ide-docs : npm/ide-docs/html/" + +if [[ -n "$PYBRICKS_CODE" ]]; then + DEST="$PYBRICKS_CODE/node_modules/@pybricks" + echo "==> Copying packages to $DEST" + rm -rf "$DEST/jedi" "$DEST/ide-docs" + mkdir -p "$DEST/jedi" "$DEST/ide-docs" + cp -r "$REPO_ROOT/jedi/npm-build/." "$DEST/jedi/" + cp -r "$REPO_ROOT/npm/ide-docs/package.json" \ + "$REPO_ROOT/npm/ide-docs/LICENSE" \ + "$REPO_ROOT/npm/ide-docs/README.md" \ + "$REPO_ROOT/npm/ide-docs/html" \ + "$DEST/ide-docs/" + echo "Copied @pybricks/jedi and @pybricks/ide-docs. Restart the dev server to pick them up." +fi + diff --git a/src/pybricks/_common.py b/src/pybricks/_common.py index 3529a00..13cb068 100644 --- a/src/pybricks/_common.py +++ b/src/pybricks/_common.py @@ -1114,7 +1114,8 @@ class IMU: heading_correction: float | None = None, angular_velocity_bias: tuple[float, float, float] | None = None, angular_velocity_scale: tuple[float, float, float] | None = None, - acceleration_correction: tuple[float, float, float, float, float, float] | None = None, + acceleration_correction: tuple[float, float, float, float, float, float] + | None = None, ) -> None: ... @overload