spacr.install_profile

Read and write the hardware choice made by the desktop installer.

The online installers live outside the Python environment they create, so their durable hand-off is a tiny JSON file beside the private venv. This module owns the schema and probes the installed torch build before writing it. Keeping that probe here means spacr-doctor reports facts rather than trying to infer an install-time choice from whatever hardware is visible later.

Functions

build_parser(→ argparse.ArgumentParser)

The command line the installers call this module with.

build_profile(→ Dict[str, Any])

Build a validated profile using the torch installation now on disk.

default_profile_path(→ pathlib.Path)

Return the installer profile path for this Python environment.

main(→ int)

Write the installer profile and print it, for the installer to read.

read_profile(→ Optional[Dict[str, Any]])

Return a valid installer profile, or None when absent/invalid.

write_profile(→ Dict[str, Any])

Atomically write and return an installer profile.

Module Contents

spacr.install_profile.build_parser() → argparse.ArgumentParser[source]

The command line the installers call this module with.

Separate from main() so the installer scripts and the tests can inspect the accepted options without running an install – an argument that silently stopped being accepted would otherwise only show up as a failed install on somebody’s machine.

The four consent flags take "0" / "1" rather than being store_true switches: the installer passes a value for every one of them on every run, so an unchecked box is recorded as a deliberate NO rather than as an absent answer.

Returns:

the parser, with --path, --requested, --detected and the consent flags.

spacr.install_profile.build_profile(requested_backend: str, detected_accelerator: str) → Dict[str, Any][source]

Build a validated profile using the torch installation now on disk.

Parameters:
  • requested_backend – installer backend choice, normalized and validated before recording.

  • detected_accelerator – detected hardware class from VALID_DETECTED_ACCELERATORS.

spacr.install_profile.default_profile_path() → pathlib.Path[source]

Return the installer profile path for this Python environment.

spacr.install_profile.main(argv: Sequence[str] | None = None) → int[source]

Write the installer profile and print it, for the installer to read.

The entry point behind python -m spacr.install_profile. The profile is echoed to stdout as sorted JSON so the installer can log exactly what was recorded, and so a support request can quote it.

Parameters:

argv – command line to parse; None reads sys.argv.

Returns:

a process exit code – 0, since a profile that cannot be written raises rather than returning a code nobody checks.

spacr.install_profile.read_profile(path: pathlib.Path | None = None) → Dict[str, Any] | None[source]

Return a valid installer profile, or None when absent/invalid.

spacr.install_profile.write_profile(path: pathlib.Path, requested_backend: str, detected_accelerator: str, *, consent_collected: bool = False, share_diagnostics: bool = False, report_issues: bool = False, sign_in_now: bool = False) → Dict[str, Any][source]

Atomically write and return an installer profile.

Parameters:
  • path – destination of the JSON installer profile.

  • requested_backend – installer backend choice to validate and record.

  • detected_accelerator – detected hardware class to validate and record.