Skip to contents

Use this if you already have a conda environment with the required Python packages (e.g. an environment created by your analysis project's environment.yml, or a Docker image). Performs a lightweight check that the required packages are importable.

Usage

use_spharmlithic_python(envname, check_mesh = FALSE)

Arguments

envname

Character. Name of an existing conda environment, OR a path to a virtualenv root, OR a path to a Python executable.

check_mesh

Logical. If TRUE, also verify mesh-extension packages (trimesh, open3d). Default FALSE.

Value

Invisibly, a list with elements envname, python (path to the active Python executable), and available (named logical vector of required-package availability).

Details

This function should be called before any spharm_from_directions() or spharm_from_meshes() call, and ideally before the package's first use in an R session.

The envname argument is resolved in the following order:

  1. Conda environment — if envname matches a name returned by reticulate::conda_list(), reticulate::use_condaenv() is called.

  2. Virtualenv — if reticulate::virtualenv_exists(envname) is TRUE, reticulate::use_virtualenv() is called.

  3. Python executable path — if file.exists(envname) is TRUE, reticulate::use_python() is called with the path directly.

If none of the above match, the function stops with an informative error. In all cases required = TRUE is passed to the underlying reticulate call, so any conflict with an already-initialised Python session will raise an error rather than silently use a different interpreter.

Examples

if (FALSE) { # \dontrun{
# Reuse the conda env created by your analysis project
use_spharmlithic_python("r-spharmlithic")

# Reuse and verify mesh extension is available
use_spharmlithic_python("r-spharmlithic", check_mesh = TRUE)
} # }