spacr.version

The installed spaCR version, and the environment report built from it.

A source checkout or editable install reports the version in its own spacr/_version.py, because its installed metadata can be stale; an installed wheel or frozen installer reports its distribution metadata.

Copyright © 2025 olafsson lab

Functions

__getattr__(name)

Resolve version_str lazily (PEP 562).

format_version_info(→ str)

Return a human-readable multi-line summary of the current environment.

get_torch_version(→ str)

Return the installed PyTorch version, or "not available" if torch is missing.

get_version(→ str)

Return the running spacr version, or "unknown" if it cannot be found.

get_version_info(→ dict[str, str])

Return a dict of spacr, platform, Python, and torch version strings.

Module Contents

spacr.version.__getattr__(name: str)[source]

Resolve version_str lazily (PEP 562).

Parameters:

name – Module attribute requested by Python’s fallback lookup.

Returns:

The formatted environment report for version_str.

Raises:

AttributeError – If name is not version_str.

format_version_info() calls get_torch_version(), which imports torch — roughly 0.94 s. Resolving version_str lazily keeps import spacr from importing torch, so light entry points such as spacr.validate can answer in about a second before a run starts.

from spacr.version import version_str still works unchanged; torch is imported only when version_str is accessed.

spacr.version.format_version_info() → str[source]

Return a human-readable multi-line summary of the current environment.

Returns:

Tab-aligned version report suitable for CLI display.

spacr.version.get_torch_version() → str[source]

Return the installed PyTorch version, or "not available" if torch is missing.

Returns:

torch.__version__ when importable, otherwise a placeholder string.

spacr.version.get_version() → str[source]

Return the running spacr version, or "unknown" if it cannot be found.

A source checkout or editable install reports the version in its own spacr/_version.py; an installed wheel or frozen installer reports its distribution metadata, then that literal when no metadata is present.

Returns:

The version string of the spacr package that is actually imported.

spacr.version.get_version_info() → dict[str, str][source]

Return a dict of spacr, platform, Python, and torch version strings.

Returns:

Mapping with keys spacr_version, platform, python_version, torch_version.