Skip to main content

Pybricks developer tools

Project description

Coverage Status Documentation Status

Pybricks tools & interface library

This is a package with tools for Pybricks developers. For regular users we recommend the Pybricks Code web IDE.

This package contains both command line tools and a library to call equivalent operations from within a Python script.

Installation

Python Runtime

pybricksdev requires Python 3.10 or higher.

Command Line Tool

We recommend using pipx to run pybricksdev as a command line tool. This ensures that you are always running the latest version of pybricksdev.

We also highly recommend installing pipx using a package manager such as apt, brew, etc. as suggested in the official pipx installation instructions.

Then use pipx to run pybricksdev:

pipx run pybricksdev ...

If you don't like typing pipx run ... all of the time, you can install pybrickdev with:

pipx install pybricksdev

Then you can just type:

pybricksdev run ...

And check for updates with:

pipx upgrade pybricksdev

Windows users

If you are using the Python Launcher for Windows (installed by default with the official Python installer), then you will need to use py -3 instead of python3.

py -3 -m pip install --upgrade pip # ensure pip is up to date first
py -3 -m pip install pipx
py -3 -m pipx run pybricksdev ...

Linux USB

On Linux, udev rules are needed to allow access via USB. The pybricksdev command line tool contains a function to generate the required rules. Run the following:

pipx run pybricksdev udev | sudo tee /etc/udev/rules.d/99-pybricksdev.rules

Library

To install pybricksdev as a library, we highly recommend using a virtual environment for your project. Our tool of choice for this is poetry:

poetry env use python3.12
poetry add pybricksdev

Of course you can always use pip as well:

pip install pybricksdev --pre

Using the Command Line Tool

The following are some examples of how to use the pybricksdev command line tool. For additional info, run pybricksdev --help.

Flashing Pybricks MicroPython firmware

Turn on the hub, and run:

pipx run pybricksdev flash <firmware.zip>

Replace <firmware.zip> with the actual path to the firmware archive.

Running Pybricks MicroPython programs

This compiles a MicroPython script and sends it to a hub with Pybricks firmware.

pipx run pybricksdev run --help

#
# ble connection examples:
#

# Run script on any Pybricks device
pipx run pybricksdev run ble demo/shortdemo.py

# Download script to any Pybricks device but don't start it
pipx run pybricksdev run ble demo/shortdemo.py --no-start

# Run script on the first device we find called Pybricks hub
pipx run pybricksdev run ble --name "Pybricks Hub" demo/shortdemo.py

# Run script on device with address 90:84:2B:4A:2B:75 (doesn't work on Mac)
pipx run pybricksdev run ble --name 90:84:2B:4A:2B:75 demo/shortdemo.py
       
#
# usb connection examples:
#

# Run script on any Pybricks device
pipx run pybricksdev run usb demo/shortdemo.py

Compiling Pybricks MicroPython programs without running

This can be used to compile programs. Instead of also running them as above, it just prints the output on the screen instead.

pipx run pybricksdev compile demo/shortdemo.py

pipx run pybricksdev compile "print('Hello!'); print('world!');"

This is mainly intended for developers who want to quickly inspect the contents of the .mpy file. To get the actual file, just use mpy-cross directly. We have used this tool in the past to test bare minimum MicroPython ports that have neither a builtin compiler or any form of I/O yet. You can paste the generated const uint8_t script[] directly ito your C code.

Additional Documentation

https://docs.pybricks.com/projects/pybricksdev (work in progress)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybricksdev-2.3.2.tar.gz (238.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybricksdev-2.3.2-py3-none-any.whl (257.5 kB view details)

Uploaded Python 3

File details

Details for the file pybricksdev-2.3.2.tar.gz.

File metadata

  • Download URL: pybricksdev-2.3.2.tar.gz
  • Upload date:
  • Size: 238.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.12 Linux/6.8.0-1044-azure

File hashes

Hashes for pybricksdev-2.3.2.tar.gz
Algorithm Hash digest
SHA256 7c060ce60dbdde96fb6544dfbcd8cd51dcb2d4d7d5cd5796dd79c40f0287e765
MD5 e58ee0467354e9cffd6a92ebad3ce484
BLAKE2b-256 54a98efa1d7c7ad7d2a8306a7dcf146b13b527a6232ec9f81cad28a895de18c4

See more details on using hashes here.

File details

Details for the file pybricksdev-2.3.2-py3-none-any.whl.

File metadata

  • Download URL: pybricksdev-2.3.2-py3-none-any.whl
  • Upload date:
  • Size: 257.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.12 Linux/6.8.0-1044-azure

File hashes

Hashes for pybricksdev-2.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7d9f024931c412e7e5e3578f1dd811ba4449519d85706a7e36611d4a27de4acc
MD5 71a31bb8024ebb6c385544f7e13fb576
BLAKE2b-256 d4847ba3b51300818266b7ffd03c7170572b8f1c9d9f46978e929da7c8d7d00b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page