Skip to content

Commit

Permalink
Fix external data loader plugins on Windows (#4840)
Browse files Browse the repository at this point in the history
### What

* fix reading PATH
* fix python instructions on external loader example

### 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:
[app.rerun.io](https://app.rerun.io/pr/4840/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/4840/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/4840/index.html?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

- [PR Build Summary](https://build.rerun.io/pr/4840)
- [Docs
preview](https://rerun.io/preview/27c5aab2cc5be03d06bf3d443fd01846c57c2933/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/27c5aab2cc5be03d06bf3d443fd01846c57c2933/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
  • Loading branch information
Wumpf and emilk committed Jan 17, 2024
1 parent 495ad54 commit fb50414
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 12 additions & 1 deletion crates/re_data_source/src/data_loader/loader_external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@ pub const EXTERNAL_DATA_LOADER_INCOMPATIBLE_EXIT_CODE: i32 = 66;
pub static EXTERNAL_LOADER_PATHS: Lazy<Vec<std::path::PathBuf>> = Lazy::new(|| {
re_tracing::profile_function!();

let dir_separator = if cfg!(target_os = "windows") {
';'
} else {
':'
};

let dirpaths = std::env::var("PATH")
.ok()
.into_iter()
.flat_map(|paths| paths.split(':').map(ToOwned::to_owned).collect::<Vec<_>>())
.flat_map(|paths| {
paths
.split(dir_separator)
.map(ToOwned::to_owned)
.collect::<Vec<_>>()
})
.map(std::path::PathBuf::from);

let mut executables = HashMap::<String, Vec<std::path::PathBuf>>::default();
Expand Down
2 changes: 2 additions & 0 deletions docs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
"obj",
"odometry",
"omahs",
"onefile",
"pablovela",
"pacman",
"parametrizations",
Expand All @@ -293,6 +294,7 @@
"proto",
"protoc",
"pycollada",
"pyinstaller",
"pyopf",
"pypi",
"pyright",
Expand Down
7 changes: 6 additions & 1 deletion examples/python/external_data_loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ thumbnail_dimensions: [480, 302]
This is an example executable data-loader plugin for the Rerun Viewer.

It will log Python source code files as markdown documents.
To try it out, copy it in your $PATH as `rerun-loader-python-file`, then open a Python source file with Rerun (`rerun file.py`).

On Linux & Mac you can simply copy it in your $PATH as `rerun-loader-python-file.py`, then open a Python source file with Rerun (`rerun file.py`).
Make sure the file has a shebang (`#!/usr/bin/env python3`) and is executable (`chmod +x`).

On Windows you have to install the script as an executable first and then put the executable under %PATH%.
One way to do this is to use `pyinstaller`: `pyinstaller .\examples\python\external_data_loader\main.py -n rerun-loader-python-file --onefile`

0 comments on commit fb50414

Please sign in to comment.