forked from rerun-io/rerun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update python readme and add
py-wheel
command (rerun-io#5912)
### What ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using newly built examples: [rerun.io/viewer](https://rerun.io/viewer/pr/5912) * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5912?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5912?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5912) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
- Loading branch information
Showing
3 changed files
with
43 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# The Rerun Python Log SDK | ||
# The Rerun Python SDK | ||
|
||
Use the Rerun SDK to log data like images, tensors, point clouds, and text. Logs are streamed to the Rerun Viewer for live visualization or to file for later use. | ||
Use the Rerun SDK to record data like images, tensors, point clouds, and text. Data is streamed to the Rerun Viewer for live visualization or to file for later use. | ||
|
||
<p align="center"> | ||
<img width="800" alt="Rerun Viewer" src="https://github.com/rerun-io/rerun/assets/2624717/c4900538-fc3a-43b8-841a-8d226e7b5a2e"> | ||
|
@@ -15,6 +15,8 @@ pip3 install rerun-sdk | |
ℹ️ Note: | ||
The Python module is called `rerun`, while the package published on PyPI is `rerun-sdk`. | ||
|
||
For other SDK languages see [Installing Rerun](https://www.rerun.io/docs/getting-started/installing-viewer). | ||
|
||
## Example | ||
```py | ||
import rerun as rr | ||
|
@@ -47,114 +49,32 @@ python3 -m rerun | |
|
||
In a second terminal, run the example with the `--connect` option: | ||
```sh | ||
python3 python examples/python/plots/main.py --connect | ||
python3 examples/python/plots/main.py --connect | ||
``` | ||
Note that SDK and Viewer can run on different machines! | ||
|
||
------------------------- | ||
|
||
# From source | ||
|
||
Setup: | ||
|
||
* Install the Rust toolchain: <https://rustup.rs/> | ||
* `git clone [email protected]:rerun-io/rerun.git && cd rerun` | ||
* Run `./scripts/setup_dev.sh`. | ||
* Make sure `cargo --version` prints `1.74.0` once you are done | ||
# Building Rerun from source | ||
|
||
## Building | ||
To build from source and install Rerun into your *current* Python environment run: | ||
We use the [`pixi`](https://prefix.dev/) for managing dev-tool versioning, download and task running. See [here](https://github.com/casey/just#installation) for installation instructions. | ||
|
||
```sh | ||
python3 -m pip install --upgrade pip | ||
pip3 install -r rerun_py/requirements-build.txt | ||
pip3 install "./rerun_py" | ||
pixi run py-build --release | ||
``` | ||
To build SDK & viewer for python (or `pixi run py-build` for a debug build) and install it in the pixi environment. | ||
|
||
ℹ️ Note: | ||
If you are unable to upgrade pip to version `>=21.3`, you need to pass `--use-feature=in-tree-build` to the `pip3 install` command. | ||
|
||
## Development | ||
|
||
To set up a new virtualenv for development: | ||
You can then run examples from the repository, either by making the pixi shell active with `pixi shell` and then running python or by using `pixi run`, e.g. `pixi run python examples/python/minimal/main.py`. | ||
|
||
Respectively, to build a wheel instead for manual install use: | ||
```sh | ||
just py-dev-env | ||
# For bash/zsh users: | ||
source venv/bin/activate | ||
# Or if you're using fish: | ||
source venv/bin/activate.fish | ||
pixi run py-wheel --release | ||
``` | ||
|
||
## Build, test, and run | ||
Refer to [BUILD.md](../BUILD.md) for details on the various different build options of the Rerun Viewer and SDKs for all target languages. | ||
|
||
For ease of development you can build and install in "editable" mode. This means you can edit the `rerun` Python code without having to re-build and install to see changes. | ||
|
||
```sh | ||
# Build the SDK and install in develop mode into the virtualenv | ||
# Re-run this if the Rust code has changed! | ||
source venv/bin/activate | ||
just py-build | ||
``` | ||
|
||
### Test | ||
```sh | ||
# Run the unit tests | ||
just py-test | ||
# Installing a pre-release | ||
|
||
# Run the linting checks | ||
just py-lint | ||
Prebuilt dev wheels from head of main are available at <https://github.com/rerun-io/rerun/releases/tag/prerelease>. | ||
|
||
# Run an example | ||
python examples/python/minimal/main.py | ||
``` | ||
|
||
## Building an installable Python Wheel | ||
The Python bindings to the core Rust library are built using https://github.com/PyO3/pyo3. | ||
|
||
To build an installable Python wheel run: | ||
``` | ||
pip install -r rerun_py/requirements-build.txt | ||
maturin build -m rerun_py/Cargo.toml --release | ||
``` | ||
|
||
By default the wheels will be built to `target/wheels` (use the `-o` flag to set a different output directory). | ||
|
||
Now you can install `rerun` in any Python3 environment using: | ||
|
||
```sh | ||
pip3 install target/wheels/*.whl | ||
``` | ||
|
||
## Viewing the docs locally | ||
The rerun python docs are generated using `mkdocs` | ||
|
||
Install the doc requirements: | ||
``` | ||
pip install -r rerun_py/requirements-doc.txt | ||
``` | ||
|
||
Serve the docs: | ||
```sh | ||
mkdocs serve -f rerun_py/mkdocs.yml -w rerun_py | ||
``` | ||
or | ||
```sh | ||
just py-docs-serve | ||
``` | ||
|
||
For information on how the docs system works, see: [docs/writing_docs.md](docs/writing_docs.md) | ||
|
||
|
||
## Troubleshooting | ||
You can run with `RUST_LOG=debug` to get more output out of the rerun SDK. | ||
|
||
If you are using an Apple-silicon Mac, make sure `rustc -vV` outputs `host: aarch64-apple-darwin`. If not, this should fix it: | ||
|
||
``` sh | ||
rustup set default-host aarch64-apple-darwin && rustup install 1.74 | ||
``` | ||
|
||
If you want to switch back, this is how: | ||
``` sh | ||
rustup set default-host x86_64-apple-darwin && rustup install 1.74 | ||
``` | ||
While we try to keep the main branch usable at all times, it may be unstable occasionally. Use at your own risk. |