mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 09:05:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3aae28174e | ||
|
|
01137f65f6 | ||
|
|
7c01d8dd16 | ||
|
|
f1ef421676 | ||
|
|
608c3f0d98 | ||
|
|
b65443f1ec | ||
|
|
88b901833c | ||
|
|
d61e452a04 | ||
|
|
f880b821c0 | ||
|
|
acda5b21cb | ||
|
|
a780b8d69e | ||
|
|
c1054edf02 | ||
|
|
dcd4d3a45c | ||
|
|
48cd9db78a | ||
|
|
719e587517 | ||
|
|
eab61dc6ac | ||
|
|
c78eb16660 | ||
|
|
fa7a336fd1 | ||
|
|
d5f6a1ad00 | ||
|
|
5bef252078 | ||
|
|
f12a6a26ac | ||
|
|
4e78de9d2a | ||
|
|
95b168355e |
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -7,24 +7,9 @@ jobs:
|
||||
if: github.ref_type != 'tag'
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v6
|
||||
- run: pipx install poetry
|
||||
- run: poetry install
|
||||
working-directory: ./jedi
|
||||
- run: poetry run pytest -vv
|
||||
working-directory: ./jedi
|
||||
|
||||
publish:
|
||||
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'pybricks_jedi/')
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: pipx install poetry
|
||||
- run: poetry install
|
||||
working-directory: ./jedi
|
||||
- run: poetry build
|
||||
working-directory: ./jedi
|
||||
- run: poetry publish
|
||||
working-directory: ./jedi
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PYBRICKS_JEDI_TOKEN }}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
name: Release @pybricks/ide-docs
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '@pybricks/ide-docs/**'
|
||||
|
||||
jobs:
|
||||
publish_ide_docs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Ubuntu packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dvisvgm preview-latex-style texlive texlive-fonts-extra texlive-latex-extra
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install poetry
|
||||
poetry run python -m pip install --upgrade pip
|
||||
poetry run python -m pip install --upgrade setuptools
|
||||
poetry install --only=doc
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '14.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: yarn build
|
||||
working-directory: npm/ide-docs
|
||||
- run: yarn publish
|
||||
working-directory: npm/ide-docs
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
@@ -9,11 +9,11 @@ jobs:
|
||||
publish_ide_docs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v6
|
||||
# Setup .npmrc file to publish to npm
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '22.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: ./build.py
|
||||
working-directory: npm/images
|
||||
|
||||
@@ -2,22 +2,42 @@ name: Release @pybricks/jedi
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '@pybricks/jedi/**'
|
||||
tags:
|
||||
- 'v4.*'
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish_jedi:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
# Setup .npmrc file to publish to npm
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@v6
|
||||
- name: Get version from tag
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
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 "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "NPM_VERSION=$NPM_VERSION" >> $GITHUB_ENV
|
||||
echo "NPM_TAG=$(echo "$NPM_VERSION" | grep -q '-' && echo 'next' || echo 'latest')" >> $GITHUB_ENV
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
node-version: '16.x'
|
||||
python-version: '3.11'
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
- name: Set pybricks-jedi version
|
||||
run: poetry version "$VERSION"
|
||||
working-directory: jedi
|
||||
- name: Set pybricks version and update jedi dependency pin
|
||||
run: |
|
||||
poetry version "$VERSION"
|
||||
sed -i "s/^pybricks = \".*\"/pybricks = \"$VERSION\"/" jedi/pyproject.toml
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: ./build.py
|
||||
working-directory: npm/jedi
|
||||
- run: yarn publish
|
||||
working-directory: npm/jedi/build
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
- run: python jedi/build.py "$NPM_VERSION"
|
||||
- run: npm publish --tag "$NPM_TAG"
|
||||
working-directory: jedi/npm-build
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v3.*'
|
||||
|
||||
name: Create release on GitHub and PyPI
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
create_release:
|
||||
name: Create release on GitHub
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Get tag
|
||||
run: echo "GITHUB_TAG=${GITHUB_REF#*refs/tags/}" >> $GITHUB_ENV
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ github.ref_name }}
|
||||
run: |
|
||||
if [[ "${{ contains(env.GITHUB_TAG, 'a') || contains(env.GITHUB_TAG, 'b') || contains(env.GITHUB_TAG, 'c') }}" == "true" ]]; then
|
||||
PRERELEASE_FLAG="--prerelease"
|
||||
else
|
||||
PRERELEASE_FLAG=""
|
||||
fi
|
||||
gh release create "$tag" \
|
||||
--repo="$GITHUB_REPOSITORY" \
|
||||
--title="${tag#v}" \
|
||||
-F CHANGELOG.md \
|
||||
$PRERELEASE_FLAG
|
||||
build_and_publish:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: pipx run poetry build
|
||||
- run: pipx run poetry publish
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
|
||||
@@ -25,6 +25,7 @@
|
||||
build/
|
||||
build-*/
|
||||
_build/
|
||||
npm-build/
|
||||
|
||||
# Tests
|
||||
######################
|
||||
|
||||
+7
-301
@@ -1,307 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
See [pybricks-micropython/CHANGELOG.md][changelog] for the changes in each release.
|
||||
|
||||
## Unreleased
|
||||
This repository is frequently updated to stay in sync with the implementation.
|
||||
|
||||
### Fixed
|
||||
Major and minor versions are synchronized with `pybricks-micropython`, which
|
||||
leads. Patch versions and prerelease version numbers may differ, as they may
|
||||
be bumped for every small change or typo in the docs.
|
||||
|
||||
- Fixed `DriveBase.angle` reporting an incorrect return type.
|
||||
The version for this repository is also used for the `@pybricks/jedi` and `@pybricks/ide-docs` npm packages.
|
||||
|
||||
## 3.6.1 - 2025-05-01
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing `hub.system.info` method on some hubs.
|
||||
|
||||
## 3.6.0 - 2025-03-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Update API for firmware 3.6.0. See upstream changelog for details.
|
||||
|
||||
## 3.6.0b5 - 2025-02-26
|
||||
|
||||
### Changed
|
||||
|
||||
- Update API for firmware 3.6.0b5. See upstream changelog for details.
|
||||
|
||||
## 3.5.0 - 2024-04-11
|
||||
|
||||
### Changed
|
||||
- Bump version to 3.5.0 without additional changes.
|
||||
|
||||
## 3.5.0b2 - 2024-04-05
|
||||
|
||||
### Added
|
||||
|
||||
- Added `pybricks.pupdevices.Remote.disconnect` method.
|
||||
- Added blocks for `up`, `ready` and `stationary` for IMUs.
|
||||
- Added `last` and `chr` parameters to `read_input_byte` and add blocks.
|
||||
- Added block for the `in` operation.
|
||||
- Add double ternary block.
|
||||
|
||||
## 3.5.0b1 - 2024-03-11
|
||||
|
||||
### Added
|
||||
|
||||
- Added `XboxController.rumble` method.
|
||||
- Added block icons for `hub.system.set_stop_button` and `hub.system.shutdown`.
|
||||
- Added program stop block (`raise SystemExit`).
|
||||
|
||||
## 3.4.1 - 2024-03-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Read The Docs virtual environment workflow.
|
||||
|
||||
## 3.4.0 - 2024-03-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Update list block screenshots to match implementation.
|
||||
|
||||
## 3.4.0b5 - 2024-03-05
|
||||
|
||||
### Changed
|
||||
|
||||
- Updates for v3.4.0b3 firmware (out of sync with docs).
|
||||
- Changed `hub.button` to `hub.buttons` on single button hubs. Access via
|
||||
`hub.button` will keep working in the firmware for backwards compatibility.
|
||||
|
||||
## 3.4.0b4 - 2024-02-14
|
||||
|
||||
### Added
|
||||
|
||||
- Added `pybricks.iodevices.XboxController` class.
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed `buttons.pressed` return type to set.
|
||||
|
||||
## 3.4.0b3 - 2024-01-30
|
||||
|
||||
### Added
|
||||
|
||||
- Added `pybricks.robotics.Car` class.
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed `pybricks.robotics.DriveBase` icon to two wheels instead of steering
|
||||
wheel, which will be used for the new car class.
|
||||
|
||||
## 3.4.0b2 - 2023-11-28
|
||||
|
||||
### Changed
|
||||
- Include first batch of block coding images.
|
||||
|
||||
## 3.3.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
- Bump beta version to release version with no further changes.
|
||||
|
||||
## 3.3.0c1 - 2023-11-20
|
||||
|
||||
### Added
|
||||
- Enabled tilt and orientation config for `MoveHub()`.
|
||||
- Documented `Motor.close()`
|
||||
|
||||
## Fixed
|
||||
- Fixed missing awaitable for `Remote.light` and LWP3 writes.
|
||||
|
||||
## 3.3.0b9 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Changed the beta feature for using the hub's gyro. Gyro control can now be
|
||||
toggled using `use_gyro` instead of using a separate `GyroDriveBase` class.
|
||||
- Documentation updates to match firmware 3.3.0b5--3.3.0b9 updates.
|
||||
|
||||
### Added
|
||||
- Added `set` to `ubuiltins` module.
|
||||
- Basic multitasking docs.
|
||||
- Awaitable keyword for awaitable methods and functions.
|
||||
|
||||
## 3.3.0b5 - 2023-05-16
|
||||
|
||||
### Added
|
||||
- Documented new `hub.ble` methods.
|
||||
|
||||
## 3.3.0b4 - 2023-04-21
|
||||
|
||||
### Added
|
||||
- Documented `integral_deadzone` in `Control.pid()`.
|
||||
- Documented `Motor.model`. This can be used to view the estimated motor
|
||||
state and change its settings.
|
||||
- Added `rotation`, `orientation`, `ready`, `stationary` and `settings` methods
|
||||
to `IMU` class.
|
||||
- Added `GyroDriveBase` class to `pybricks.robotics`.
|
||||
|
||||
### Changed
|
||||
- Change implementation status of `IMU.heading` and `IMU.reset_heading`. They
|
||||
are now implemented, with some limitations as noted in a note box.
|
||||
- Moved `Matrix` and `vector` from `pybricks.geometry` to `pybricks.tools`.
|
||||
- Moved `Axis` from `pybricks.geometry` to `pybricks.parameters`.
|
||||
|
||||
### Removed
|
||||
- Removed `pybricks.geometry` module.
|
||||
|
||||
## 3.2.0 - 2022-12-20
|
||||
|
||||
### Changed
|
||||
- Changed module TOC headings to make it easier to find things.
|
||||
|
||||
## 3.2.0c1 - 2022-12-09
|
||||
|
||||
### Changed
|
||||
- Updated "front" side of the Technic Hub to be consistent with
|
||||
the Prime Hub.
|
||||
|
||||
## 3.2.0b6 - 2022-12-02
|
||||
|
||||
### Added
|
||||
- Documented ``Stop.NONE`` and ``Stop.COAST_SMART``.
|
||||
- Documented ``ujson`` module.
|
||||
- Added `done` and `stalled` methods for `DriveBase`.
|
||||
|
||||
### Changed
|
||||
- Changed `PrimeHub.display.image()` to `PrimeHub.display.icon()` and renamed
|
||||
its kwarg from `image` to `icon`.
|
||||
- Improved presentation and docstrings of the ``ubuiltins`` and other
|
||||
MicroPython modules
|
||||
- Moved the random numbers example for Move Hub to the Move Hub page.
|
||||
- Moved `done()`, `stalled()`, `load()` from `Control` to `Motor` object.
|
||||
|
||||
## 3.2.0b5 - 2022-11-11
|
||||
|
||||
### Fixed
|
||||
- Fixed Jedi code completion for `Color` and `Icon` classes in `pybricks.parameters`.
|
||||
|
||||
## 3.2.0b4 - 2022-10-21
|
||||
|
||||
### Added
|
||||
- Code auto-completion for `EssentialHub`.
|
||||
- Added `System.storage` method.
|
||||
|
||||
### Fixed
|
||||
- Fixed some type hints in `parameters` submodule.
|
||||
|
||||
## 3.2.0b1-r3 - 2022-06-26
|
||||
|
||||
### Fixed
|
||||
- Fixed more type hints and improved compatibility with jedi.
|
||||
|
||||
## 3.2.0b1-r2 - 2022-06-24
|
||||
|
||||
### Changed
|
||||
- Moved remaining type hints from `.pyi` files to the python stub modules, and
|
||||
fixed numerous errors in the type hints throughout.
|
||||
|
||||
## 3.2.0b1-r1 - 2022-06-09
|
||||
|
||||
### Added
|
||||
- Added `__init__.py` to `pybricks` package.
|
||||
|
||||
## 3.2.0b1 - 2022-06-02
|
||||
|
||||
### Added
|
||||
- Code auto-completion for `hub.charger`, `hub.imu` and `hub.system`.
|
||||
- Moved typing from several `.pyi` files to the actual python modules.
|
||||
|
||||
### Fixed
|
||||
- Fixed code completion for `DCMotor` and `Motor` classes in MS Python VS Code extension.
|
||||
- Fixed missing `DCMotor` type in `ev3devices`.
|
||||
- Fixed type hint for `Motor.reset_angle()` in `pupdevices`.
|
||||
|
||||
### Changed
|
||||
- Setter for acceleration can now also be used to set acceleration and
|
||||
deceleration to different values, using a two-valued tuple.
|
||||
|
||||
## 3.1.0 - 2021-12-16
|
||||
|
||||
### Added
|
||||
- Added maximum voltage setter for `DCMotor` and `Motor`.
|
||||
- Documented `DriveBase.curve()` method.
|
||||
|
||||
### Changed
|
||||
- Removed `duty` setting from `Control.limits` method.
|
||||
- Removed `integral_range` setting from `Control.pid` method.
|
||||
|
||||
### Fixed
|
||||
- Fixed link to Color Light Matrix page.
|
||||
- Fixed link to Inventor Hub page.
|
||||
|
||||
## 3.1.0rc1 - 2021-11-19
|
||||
|
||||
### Added
|
||||
- Added `ColorLightMatrix` class.
|
||||
- Added `LWP3Device` class.
|
||||
|
||||
**NOTE: version number after this point were from JavaScript package and do
|
||||
not correspond to Pybricks firmware version numbers.**
|
||||
|
||||
## 1.6.0 - 2021-08-30
|
||||
|
||||
### Added
|
||||
- MicroPython module documentation.
|
||||
- Examples for hub system functions including stop button and shutdown.
|
||||
|
||||
### Changed
|
||||
- Build IDE docs as main docs with minor changes, instead of a completely
|
||||
separate build.
|
||||
- Moved motor control documentation to the motor page.
|
||||
|
||||
## 1.5.0 - 2021-07-01
|
||||
|
||||
### Added
|
||||
- Documentation for Powered Up Remote Control.
|
||||
|
||||
## 1.4.0 - 2021-06-23
|
||||
|
||||
### Added
|
||||
- Enabled beta content that was hidden for the 3.0 release.
|
||||
- Added notice about using the latest beta version.
|
||||
|
||||
## 1.3.3 - 2021-05-21
|
||||
|
||||
### Changed
|
||||
- Match example snippet styling to IDE.
|
||||
- Add more examples.
|
||||
|
||||
## 1.3.2 - 2021-04-26
|
||||
|
||||
### Changed
|
||||
- Theme style fixes.
|
||||
- Example code fixes
|
||||
- Match doc version to firmware version.
|
||||
|
||||
## 1.3.1 - 2021-04-12
|
||||
|
||||
### Changed
|
||||
- Upgrade sphinx and rtd-theme to fix style issues.
|
||||
|
||||
## 1.3.0 - 2021-04-12
|
||||
|
||||
### Removed
|
||||
- Removed features which not be in the official 3.0 release. These features
|
||||
are still in beta. They'll come back in future releases once tested.
|
||||
|
||||
## 1.2.0 - 2021-04-09
|
||||
|
||||
### Changed
|
||||
- Moved installation guide to external site.
|
||||
|
||||
## 1.1.1 - 2021-02-14
|
||||
|
||||
### Added
|
||||
- Added installation guide.
|
||||
- Various documentation fixes.
|
||||
|
||||
## 1.1.0 - 2021-01-28
|
||||
|
||||
### Added
|
||||
- Scrollbar styling.
|
||||
|
||||
## 1.0.0 - 2021-01-25
|
||||
|
||||
### Added
|
||||
- Sphinx build output.
|
||||
[changelog]: https://github.com/pybricks/pybricks-micropython/blob/master/CHANGELOG.md
|
||||
|
||||
@@ -163,6 +163,11 @@ Linting:
|
||||
poetry run flake8 # check Python
|
||||
poetry run doc8 # check Restructured Text
|
||||
|
||||
Building all release artifacts (docs, jedi, npm packages):
|
||||
|
||||
# Linux/macOS only
|
||||
./build-all.sh
|
||||
|
||||
[vscode]: https://code.visualstudio.com/
|
||||
[git]: https://git-scm.com/
|
||||
[python]: https://www.python.org/
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build all release artifacts locally (equivalent to CI workflows, minus publish).
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
# Activate the project venv so python/make/etc. all use it without poetry run
|
||||
source "$REPO_ROOT/.venv/bin/activate"
|
||||
|
||||
# Read version from pyproject.toml
|
||||
VERSION=$(grep '^version = ' "$REPO_ROOT/pyproject.toml" | head -1 | sed 's/version = "\(.*\)"/\1/')
|
||||
# Convert Python pre-release format (e.g. 4.0.0a1, 4.0.0b1, 4.0.0rc1) to npm semver (e.g. 4.0.0-alpha.1, 4.0.0-beta.1, 4.0.0-rc.1)
|
||||
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
|
||||
echo "==> Linting"
|
||||
cd "$REPO_ROOT"
|
||||
flake8
|
||||
doc8
|
||||
|
||||
# pybricks-jedi tests
|
||||
echo "==> Testing pybricks-jedi"
|
||||
cd "$REPO_ROOT/jedi"
|
||||
poetry run pytest -vv
|
||||
|
||||
# @pybricks/jedi npm package
|
||||
echo "==> Building @pybricks/jedi"
|
||||
cd "$REPO_ROOT/jedi"
|
||||
python3 build.py "$NPM_VERSION"
|
||||
|
||||
# @pybricks/ide-docs npm package
|
||||
echo "==> Building @pybricks/ide-docs"
|
||||
cd "$REPO_ROOT"
|
||||
make -C doc clean
|
||||
cd "$REPO_ROOT/npm/ide-docs"
|
||||
yarn build
|
||||
|
||||
echo ""
|
||||
echo "Build complete."
|
||||
echo " jedi npm package : jedi/npm-build/"
|
||||
echo " ide-docs : npm/ide-docs/html/"
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
#!/usr/bin/env python3
|
||||
# Builds the @pybricks/jedi npm package into npm-build/.
|
||||
|
||||
import email.parser
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tomllib
|
||||
import zipfile
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <version>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
VERSION = sys.argv[1]
|
||||
|
||||
ROOT_DIR = pathlib.Path(__file__).parent.resolve()
|
||||
REPO_ROOT_DIR = (ROOT_DIR / "..").resolve()
|
||||
BUILD_DIR = ROOT_DIR / "npm-build"
|
||||
|
||||
package_json = {
|
||||
"name": "@pybricks/jedi",
|
||||
"version": VERSION,
|
||||
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pybricks/pybricks-api.git",
|
||||
"directory": "jedi",
|
||||
},
|
||||
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
|
||||
}
|
||||
|
||||
license_identifiers: set[str] = set()
|
||||
license_text: dict[str, str] = {}
|
||||
whl_map: dict[str, str] = {}
|
||||
|
||||
# ensure empty build directory so we don't end up with stale files
|
||||
shutil.rmtree(BUILD_DIR, True)
|
||||
BUILD_DIR.mkdir()
|
||||
|
||||
# build pybricks api wheel from local source so pip uses it instead of fetching from PyPI
|
||||
subprocess.check_call(["poetry", "build", "--format=wheel"], cwd=REPO_ROOT_DIR)
|
||||
|
||||
# copy locally built pybricks wheel to build dir
|
||||
for whl in (REPO_ROOT_DIR / "dist").glob("pybricks-*.whl"):
|
||||
shutil.copy(whl, BUILD_DIR)
|
||||
|
||||
# build pybricks-jedi wheel from local source
|
||||
subprocess.check_call(["poetry", "build", "--format=wheel"], cwd=ROOT_DIR)
|
||||
|
||||
# copy locally built wheel to build dir
|
||||
for whl in (ROOT_DIR / "dist").glob("pybricks_jedi-*.whl"):
|
||||
shutil.copy(whl, BUILD_DIR)
|
||||
|
||||
# download transitive dependencies using versions pinned in poetry.lock
|
||||
transitive_packages = ["jedi", "parso", "docstring-parser", "typing-extensions"]
|
||||
with open(ROOT_DIR / "poetry.lock", "rb") as f:
|
||||
lock = tomllib.load(f)
|
||||
lock_versions = {pkg["name"]: pkg["version"] for pkg in lock["package"]}
|
||||
transitive = [f"{pkg}=={lock_versions[pkg]}" for pkg in transitive_packages]
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "pip", "download", "--only-binary=any"] + transitive,
|
||||
cwd=BUILD_DIR,
|
||||
)
|
||||
|
||||
# extract info from wheel files to generate javascript package files
|
||||
for whl in BUILD_DIR.glob("*.whl"):
|
||||
with zipfile.ZipFile(whl) as f:
|
||||
|
||||
def is_dist_info_metadata(info: zipfile.ZipInfo):
|
||||
return info.filename.endswith(".dist-info/METADATA")
|
||||
|
||||
def is_dist_info_license(info: zipfile.ZipInfo):
|
||||
return ".dist-info" in info.filename and "LICENSE" in info.filename
|
||||
|
||||
metadata = next(filter(is_dist_info_metadata, f.filelist))
|
||||
|
||||
with f.open(metadata.filename) as mf:
|
||||
meta = email.parser.BytesParser().parse(mf)
|
||||
|
||||
# extract package name from metadata
|
||||
name = meta["Name"]
|
||||
|
||||
if not name:
|
||||
raise RuntimeError(f"missing 'Name' in {whl.name} METADATA")
|
||||
|
||||
whl_map[name] = whl.name
|
||||
|
||||
# extract license identifier from metadata
|
||||
|
||||
license = meta["License"]
|
||||
|
||||
if not license:
|
||||
# some packages are missing license in metadata
|
||||
if whl.name.startswith("typing_extensions-"):
|
||||
license = "Python-2.0"
|
||||
else:
|
||||
raise RuntimeError(f"missing 'License' in {whl.name} METADATA")
|
||||
|
||||
license_identifiers.add(license)
|
||||
|
||||
if whl.name.startswith("pybricks_jedi-"):
|
||||
with open(ROOT_DIR / "LICENSE") as lf:
|
||||
license_text[whl.name] = lf.read()
|
||||
else:
|
||||
try:
|
||||
license = next(filter(is_dist_info_license, f.filelist))
|
||||
except StopIteration:
|
||||
raise RuntimeError(f"missing license for {whl.name}")
|
||||
|
||||
with f.open(license) as lf:
|
||||
license_text[whl.name] = lf.read().decode()
|
||||
|
||||
|
||||
# generate package.json file
|
||||
|
||||
# create "license" item from collected license identifiers
|
||||
package_json["license"] = (
|
||||
license_identifiers[0]
|
||||
if len(license_identifiers) < 2
|
||||
else f"({' AND '.join(license_identifiers)})"
|
||||
)
|
||||
|
||||
# create "exports" item from collect whl map
|
||||
package_json["exports"] = {f"./{k}.whl": f"./{v}" for k, v in whl_map.items()}
|
||||
|
||||
with open(BUILD_DIR / "package.json", "w") as f:
|
||||
json.dump(package_json, f, indent=2)
|
||||
|
||||
# generate LICENSE file
|
||||
|
||||
NEWLINE = "\n"
|
||||
DIVIDER = "=" * 80 + NEWLINE
|
||||
with open(BUILD_DIR / "LICENSE", "w") as f:
|
||||
for whl, text in license_text.items():
|
||||
f.write(DIVIDER)
|
||||
f.write(whl)
|
||||
f.writelines([NEWLINE, DIVIDER, NEWLINE])
|
||||
f.write(text)
|
||||
f.write(NEWLINE)
|
||||
|
||||
# copy additional files
|
||||
|
||||
for file in ("README.md",):
|
||||
shutil.copy(ROOT_DIR / file, BUILD_DIR / file)
|
||||
+4
-2
@@ -1,13 +1,15 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks_jedi"
|
||||
version = "1.17.0"
|
||||
# Version is set automatically at build time from the root pyproject.toml. Do not edit.
|
||||
version = "0.0.0"
|
||||
description = "Code completion for Pybricks."
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">= 3.10, < 3.12"
|
||||
pybricks = "3.6.0b5"
|
||||
# Version is set automatically at build time from the root pyproject.toml. Do not edit.
|
||||
pybricks = "0.0.0"
|
||||
jedi = "0.18.1"
|
||||
typing-extensions = "4.2.0"
|
||||
docstring-parser = "0.14.1"
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
version-tag-prefix "@pybricks/ide-docs/v"
|
||||
version-git-message "@pybricks/ide-docs v%s"
|
||||
@@ -1,114 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## 2.20.0 - 2024-02-26
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.6.0b5.
|
||||
|
||||
## 2.19.0 - 2024-04-11
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.5.0.
|
||||
|
||||
## 2.18.0 - 2024-04-05
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.5.0b2.
|
||||
|
||||
## 2.17.0 - 2024-03-21
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.5.0b1.
|
||||
|
||||
## 2.16.0 - 2024-03-11
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0.
|
||||
|
||||
## 2.15.0 - 2024-03-05
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0b5.
|
||||
|
||||
## 2.14.0 - 2024-01-30
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0b3.
|
||||
|
||||
## 2.13.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0b1.
|
||||
|
||||
## 2.12.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0.
|
||||
|
||||
## 2.11.0 - 2023-11-20
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0c1.
|
||||
|
||||
## 2.10.0 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0b9.
|
||||
|
||||
## 2.9.0 - 2023-05-16
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0b5.
|
||||
|
||||
## 2.8.0 - 2023-04-21
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0b4.
|
||||
|
||||
## 2.7.0 - 2022-12-20
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0c2.
|
||||
|
||||
## 2.6.0 - 2022-12-09
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0c1.
|
||||
|
||||
## 2.5.0 - 2022-12-02
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0b6.
|
||||
|
||||
## 2.4.0 - 2022-11-11
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0b5.
|
||||
|
||||
## 2.3.0 - 2022-10-21
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0b4.
|
||||
|
||||
## 2.2.0 - 2022-06-02
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.2.0b1.
|
||||
|
||||
## 2.1.0 - 2021-12-16
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.1.0.
|
||||
|
||||
## 2.0.1 - 2021-11-19
|
||||
|
||||
### Fixed
|
||||
- Fixed link to Color Light Matrix page.
|
||||
|
||||
## 2.0.0 - 2021-11-19
|
||||
|
||||
### Changed
|
||||
- Changed package directory structure.
|
||||
- Updated docs to v3.1.0rc1.
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@pybricks/ide-docs",
|
||||
"version": "2.20.0",
|
||||
"version": "0.0.0",
|
||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pybricks/pybricks-api",
|
||||
"url": "git+https://github.com/pybricks/pybricks-api.git",
|
||||
"directory": "npm/ide-docs"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package_json = {
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pybricks/pybricks-api",
|
||||
"url": "git+https://github.com/pybricks/pybricks-api.git",
|
||||
"directory": "npm/images",
|
||||
},
|
||||
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
version-tag-prefix "@pybricks/jedi/v"
|
||||
version-git-message "@pybricks/jedi v%s"
|
||||
@@ -1,99 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.17.0 - 2025-02-26
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.17.0.
|
||||
|
||||
## 1.16.0 - 2024-04-05
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.16.0.
|
||||
|
||||
## 1.15.0 - 2024-03-21
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.15.0.
|
||||
|
||||
## 1.14.0 - 2024-03-05
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.14.0.
|
||||
|
||||
## 1.13.0 - 2024-01-30
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.13.0.
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.12.0.
|
||||
|
||||
## 1.12.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.12.0.
|
||||
|
||||
## 1.11.0 - 2023-11-20
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.11.0.
|
||||
|
||||
## 1.10.0 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.10.0.
|
||||
|
||||
## 1.9.0 - 2023-05-16
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.9.0.
|
||||
|
||||
## 1.8.0 - 2023-04-21
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.8.0.
|
||||
|
||||
## 1.7.0 - 2022-12-28
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.7.0.
|
||||
|
||||
## 1.6.0 - 2022-12-09
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.6.0.
|
||||
|
||||
## 1.5.0 - 2022-12-02
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.5.0.
|
||||
|
||||
## 1.4.0 - 2022-12-02
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.4.0.
|
||||
|
||||
## 1.3.0 - 2022-11-11
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.3.0.
|
||||
|
||||
## 1.2.0 - 2022-10-21
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.2.0.
|
||||
|
||||
## 1.0.1 - 2022-09-07
|
||||
|
||||
### Fixed
|
||||
- Fixed exports.
|
||||
- Fixed missing README and CHANGELOG.
|
||||
|
||||
## 1.0.0 - 2022-09-07
|
||||
|
||||
### Added
|
||||
- Added new @pybricks/jedi package.
|
||||
Executable → Regular
+44
-21
@@ -8,15 +8,24 @@ import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <version>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
VERSION = sys.argv[1]
|
||||
|
||||
ROOT_DIR = pathlib.Path(__file__).parent.resolve()
|
||||
REPO_ROOT_DIR = (ROOT_DIR / ".." / "..").resolve()
|
||||
JEDI_SRC_DIR = (ROOT_DIR / ".." / ".." / "jedi").resolve()
|
||||
BUILD_DIR = (ROOT_DIR / "build").resolve()
|
||||
|
||||
package_json = {
|
||||
"name": "@pybricks/jedi",
|
||||
"version": "1.17.0",
|
||||
"version": VERSION,
|
||||
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pybricks/pybricks-api",
|
||||
"url": "git+https://github.com/pybricks/pybricks-api.git",
|
||||
"directory": "npm/jedi",
|
||||
},
|
||||
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
|
||||
@@ -30,16 +39,37 @@ whl_map: dict[str, str] = {}
|
||||
shutil.rmtree(BUILD_DIR, True)
|
||||
BUILD_DIR.mkdir()
|
||||
|
||||
# download package and dependencies (*.whl files)
|
||||
# build pybricks api wheel from local source so pip uses it instead of fetching from PyPI
|
||||
subprocess.check_call(["poetry", "build", "--format=wheel"], cwd=REPO_ROOT_DIR)
|
||||
|
||||
# copy locally built pybricks wheel to build dir
|
||||
for whl in (REPO_ROOT_DIR / "dist").glob("pybricks-*.whl"):
|
||||
shutil.copy(whl, BUILD_DIR)
|
||||
|
||||
# build pybricks-jedi wheel from local source
|
||||
subprocess.check_call(["poetry", "build", "--format=wheel"], cwd=JEDI_SRC_DIR)
|
||||
|
||||
# copy locally built wheel to build dir
|
||||
for whl in (JEDI_SRC_DIR / "dist").glob("pybricks_jedi-*.whl"):
|
||||
shutil.copy(whl, BUILD_DIR)
|
||||
|
||||
# download transitive dependencies using the versions already installed in the venv
|
||||
# (installed by poetry from the lockfile, so versions are pinned correctly)
|
||||
transitive_packages = ["jedi", "parso", "docstring-parser", "typing-extensions"]
|
||||
# use the jedi venv's Python to query metadata since packages are installed there
|
||||
jedi_venv_python = JEDI_SRC_DIR / ".venv" / "bin" / "python"
|
||||
pkg_versions = json.loads(
|
||||
subprocess.check_output(
|
||||
[
|
||||
jedi_venv_python,
|
||||
"-c",
|
||||
f"import importlib.metadata, json; print(json.dumps({{p: importlib.metadata.version(p) for p in {transitive_packages!r}}}))",
|
||||
]
|
||||
)
|
||||
)
|
||||
transitive = [f"{pkg}=={pkg_versions[pkg]}" for pkg in transitive_packages]
|
||||
subprocess.check_call(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"download",
|
||||
"--only-binary=any",
|
||||
"pybricks-jedi==1.17.0",
|
||||
],
|
||||
[sys.executable, "-m", "pip", "download", "--only-binary=any"] + transitive,
|
||||
cwd=BUILD_DIR,
|
||||
)
|
||||
|
||||
@@ -79,13 +109,8 @@ for whl in BUILD_DIR.glob("*.whl"):
|
||||
|
||||
license_identifiers.add(license)
|
||||
|
||||
# TODO: The LICENSE workaround for the pybricks-jedi package can be
|
||||
# dropped after the next release of that package
|
||||
if whl.name.startswith("pybricks_jedi-"):
|
||||
LICENSE = (
|
||||
pathlib.Path(__file__).parent.parent.parent / "jedi" / "LICENSE"
|
||||
).resolve()
|
||||
with open(LICENSE) as lf:
|
||||
with open(JEDI_SRC_DIR / "LICENSE") as lf:
|
||||
license_text[whl.name] = lf.read()
|
||||
else:
|
||||
try:
|
||||
@@ -126,7 +151,5 @@ with open(BUILD_DIR / "LICENSE", "w") as f:
|
||||
|
||||
# copy additional files
|
||||
|
||||
ROOT_DIR = (pathlib.Path(__file__).parent).resolve()
|
||||
|
||||
for file in "README.md", "CHANGELOG.md":
|
||||
for file in ("README.md",):
|
||||
shutil.copy(ROOT_DIR / file, BUILD_DIR / file)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks"
|
||||
version = "3.6.1"
|
||||
version = "4.0.0b9"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||
|
||||
Reference in New Issue
Block a user