@@ -4,6 +4,26 @@ set -euo pipefail
44
55REPO_ROOT=" $( realpath " $( dirname " ${BASH_SOURCE[0]} " ) " ) "
66
7+ # Option: --pybricks-code <path> copies built npm packages into that
8+ # checkout's node_modules/@pybricks/ for easy local testing.
9+ PYBRICKS_CODE=" "
10+ while [[ $# -gt 0 ]]; do
11+ case " $1 " in
12+ --pybricks-code)
13+ PYBRICKS_CODE=" $( realpath " $2 " ) "
14+ shift 2
15+ ;;
16+ * )
17+ echo " usage: $0 [--pybricks-code <path-to-pybricks-code-checkout>]" >&2
18+ exit 1
19+ ;;
20+ esac
21+ done
22+ if [[ -n " $PYBRICKS_CODE " && ! -d " $PYBRICKS_CODE /node_modules/@pybricks" ]]; then
23+ echo " error: $PYBRICKS_CODE /node_modules/@pybricks not found (run yarn install there first)" >&2
24+ exit 1
25+ fi
26+
727# Activate the project venv so python/make/etc. all use it without poetry run
828source " $REPO_ROOT /.venv/bin/activate"
929
@@ -13,30 +33,57 @@ VERSION=$(grep '^version = ' "$REPO_ROOT/pyproject.toml" | head -1 | sed 's/vers
1333NPM_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/' )
1434echo " ==> Building version $VERSION (npm: $NPM_VERSION )"
1535
16- # lint
36+ # lint (same as CI build.yml)
1737echo " ==> Linting"
1838cd " $REPO_ROOT "
19- flake8
39+ ruff check
40+ ruff format --check
2041doc8
2142
22- # pybricks-jedi tests
43+ # Python package
44+ echo " ==> Building Python package"
45+ rm -rf " $REPO_ROOT /dist" # stale wheels would get globbed into the jedi npm package
46+ poetry build
47+
48+ # pybricks-jedi tests (own poetry env, same as CI jedi.yml)
2349echo " ==> Testing pybricks-jedi"
2450cd " $REPO_ROOT /jedi"
2551poetry run pytest -vv
2652
2753# @pybricks/jedi npm package
2854echo " ==> Building @pybricks/jedi"
2955cd " $REPO_ROOT /jedi"
56+ rm -rf dist # build.py globs dist/*.whl, stale wheels would get shipped
3057python3 build.py " $NPM_VERSION "
3158
32- # @pybricks/ide- docs npm package
33- echo " ==> Building @pybricks/ide- docs"
59+ # html docs for Read the Docs
60+ echo " ==> Building Read the Docs html docs"
3461cd " $REPO_ROOT "
62+ make -C doc clean html
63+
64+ # @pybricks/ide-docs npm package (builds the TAG=ide docs)
65+ echo " ==> Building @pybricks/ide-docs"
3566make -C doc clean
3667cd " $REPO_ROOT /npm/ide-docs"
3768yarn build
3869
3970echo " "
4071echo " Build complete."
72+ echo " python package : dist/"
4173echo " jedi npm package : jedi/npm-build/"
4274echo " ide-docs : npm/ide-docs/html/"
75+
76+ if [[ -n " $PYBRICKS_CODE " ]]; then
77+ DEST=" $PYBRICKS_CODE /node_modules/@pybricks"
78+ echo " ==> Copying packages to $DEST "
79+ rm -rf " $DEST /jedi" " $DEST /ide-docs"
80+ mkdir -p " $DEST /jedi" " $DEST /ide-docs"
81+ cp -r " $REPO_ROOT /jedi/npm-build/." " $DEST /jedi/"
82+ cp -r " $REPO_ROOT /npm/ide-docs/package.json" \
83+ " $REPO_ROOT /npm/ide-docs/LICENSE" \
84+ " $REPO_ROOT /npm/ide-docs/README.md" \
85+ " $REPO_ROOT /npm/ide-docs/html" \
86+ " $DEST /ide-docs/"
87+ echo " Copied @pybricks/jedi and @pybricks/ide-docs. Restart the dev server to pick them up."
88+ fi
89+
0 commit comments