Janus / Docs / Building

Docs

Building Janus from source

Build Janus from source, run its tests and self-tests, make the packages, and where its data lives.

Janus is a Rust workspace (crates/, see Architecture). It needs Rust 1.90 or later and GDAL, e.g. from a conda-forge environment:

conda create -n geo -c conda-forge gdal=3.11 libgdal-netcdf=3.11 libgdal-hdf5=3.11 libgdal-jp2openjpeg=3.11 numpy

GDAL 3.11 or older: the gdal-sys crate carries bindings up to 3.11 (a newer GDAL needs its bindgen feature, and libclang).

(the three plugins read NetCDF, HDF5 and JPEG 2000 (the Sentinel-2 L1C bands); numpy and GDAL's Python bindings are only for tools/make_selftest_data.py, which makes the self-tests' inputs). Everything else, from the interface (egui, wgpu) to Zeit's methods, comes from crates.io and the workspace. Zeit is part of the program: no Python runs at any time.

Windows

gdal-sys links GDAL's import library under the name the OSGeo builds give it, gdal_i.lib; conda-forge calls it gdal.lib. Copy it once, and tell Cargo where GDAL is in .cargo/config.toml (not committed; .cargo/config.example.toml is the template):

powershell
mkdir .cargo\gdal; copy <conda-env>\Library\lib\gdal.lib .cargo\gdal\gdal_i.lib
copy .cargo\config.example.toml .cargo\config.toml   # then set GDAL_INCLUDE_DIR and GDAL_VERSION
cargo build --release
.\target\release\janus.exe <series>

The build puts the GDAL of GDAL_INCLUDE_DIR's environment beside janus.exe (build.rs): gdal.dll and every DLL it loads from there, the netCDF, HDF5 and JPEG 2000 plugins (gdalplugins\), PROJ's database and GDAL's data (share\), as the installed program has them. So target\release\janus.exe runs with its own GDAL, with no GDAL on the machine and whatever GDAL comes first on PATH (an OSGeo4W or GISInternals one, QGIS's); one started with another GDAL (a copy of janus.exe alone) says so at start. The tests (cargo test) still need the environment's Library\bin on PATH.

Linux and macOS

pkg-config finds GDAL in the environment; the programs built need its libraries at run time:

bash
conda activate geo
export PKG_CONFIG_PATH="$CONDA_PREFIX/lib/pkgconfig"
export RUSTFLAGS="-C link-arg=-Wl,-rpath,$CONDA_PREFIX/lib"   # or LD_LIBRARY_PATH / DYLD_FALLBACK_LIBRARY_PATH
cargo build --release
./target/release/janus <series>

The map draws through wgpu: Vulkan on Linux (any driver; Mesa's lavapipe without a GPU), Metal on macOS, Direct3D 12 on Windows (WGPU_BACKEND chooses another).

Tests

bash
cargo fmt --all --check
cargo clippy --release --workspace --all-targets -- -D warnings
cargo test --release --workspace
python tools/make_selftest_data.py td           # the self-tests' inputs
janus --selftest-zeit td/serie                  # every Zeit tool, pixel and raster, no window
janus --selftest-zeit td/landsat                # the multiband ones (CCDC, CODED, NDFI, Tmask)
janus --selftest-validation                     # the estimators against Olofsson et al. (2014)
janus --selftest-embeddings                     # the embedding kernels and PCA
cd td && janus --selftest-ui A B C D E F G      # the interface, frame by frame (a window)

The UI self-test's Python stages run the code Janus gives with a Python that has Zeit and rasterio (JANUS_PYTHON, else python; the scripts of the other tools need zeit-cdts>=3.2), and a warp run's rerun.py that stays gdal.Warp with a Python that has GDAL's bindings (JANUS_GDAL_PYTHON, else JANUS_PYTHON); without one they are skipped.

janus --profile-tour <series> times a fixed tour of a series (the overview, cursor series, every date, the display modes, zoom and pan at full resolution, an ROI) stage by stage; --tour-json FILE writes the timings as JSON (bench/ keeps the baselines).

Packages

bash
python tools/package.py      # builds, then: dist/janus-<version>-setup.exe (Windows, Inno Setup 6),
                             # dist/janus-<version>-linux-x86_64.tar.xz, dist/janus-<version>-macos-arm64.dmg

It takes GDAL's libraries, plugins and data from the conda environment ($CONDA_PREFIX, or --prefix): on Windows the DLLs the program imports, found by walking their import tables; on Linux what ldd finds there (RPATH $ORIGIN/lib, set with patchelf); on macOS what otool finds (RPATH @executable_path/../Frameworks, ad hoc signature). The Windows installer needs Inno Setup 6; without it the files are left in target/package.

Every package carries Janus's LICENSE and a THIRD_PARTY_NOTICES.txt (tools/notices.py): the Rust crates compiled into the program (cargo metadata), the conda-forge packages its libraries and data come from (conda-meta), and the embedded fonts, each with its license's text. The conda packages' texts are read from the package cache (pkgs/<package>/info/licenses), which an environment restored from a cache may not have; --strict-notices (the CI's) fails then instead of leaving a work without its text.

The CI (.github/workflows/build.yml) does all of the above on Windows, Linux and macOS and publishes the three packages on a v* tag.

The guides' screenshots

janus --shots TOUR IN OUT walks through a guide of the website in a window of 1680 × 1050 and saves its screenshots in OUT: validation (IN from tools/make_tutorial_data.py), landtrendr, ccdc and coded (tools/make_guide_data.py), bfast and phenology (an EVI series). tune (the folder of the synthetic forest frontier of the validation tests: ndvi_annual/ and landtrendr_two_interpreters.gpkg with its strata raster) calibrates LandTrendr on an interpreted project: it copies the project into the temporary files, runs the 200 sets, runs the whole image with the defaults and with the best set, assesses both maps on the accuracy points, and prints what the guide quotes (janus --threads 4 --shots tune DATA site/assets/img/tune). Its PNGs become the JPEGs and WebPs of the page with ffmpeg and tools/make_webp.py.

Data folders

The overview and full-resolution caches, settings, layout, labels and results live in %LOCALAPPDATA%\Janus (Windows), ~/.local/share/janus (Linux) and ~/Library/Application Support/Janus (macOS; the overview cache in ~/Library/Caches/Janus). The cache files are the same as the C++ versions' (up to 0.39), which Janus 1.0 reads.

This page is made from docs/building.md; to change it, change that file.