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.

Attributes

NO_WGPU_OVERRIDE

A requirement with a never-true marker that overrides every wgpu requirement.

NO_WGPU_OVERRIDE_NAME

The file no_wgpu_override() writes beside the installer profile.

Functions

build_parser(→ argparse.ArgumentParser)

Return the argument parser for the command line the installers use.

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.

no_wgpu_override(→ Optional[pathlib.Path])

The uv --override file that keeps wgpu out, when the install did.

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]

Return the argument parser for the command line the installers use.

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 three 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.

--sign-in-now is still accepted and ignored: installers released before setup stopped offering GitHub and AI sign-in pass it, and an install must not fail on an option that no longer does anything.

--without-wgpu ("0" / "1") records an install that left wgpu out, so in-app updates leave it out too.

Returns:

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

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.no_wgpu_override(profile: Dict[str, Any] | None, path: pathlib.Path | None = None) → pathlib.Path | None[source]

The uv --override file that keeps wgpu out, when the install did.

Parameters:
  • profile – a profile from read_profile(), or None.

  • path – where to write the file; defaults to beside the profile.

Returns:

the written file when the profile records without_wgpu, else None (also when the file cannot be written).

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, without_wgpu: 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.

  • without_wgpu – the install left wgpu out (the installers’ “Install without wgpu” option, or Linux with glibc older than 2.28); recorded so an in-app update leaves it out too (no_wgpu_override()).

spacr.install_profile.NO_WGPU_OVERRIDE = 'wgpu; sys_platform == "never"'[source]

A requirement with a never-true marker that overrides every wgpu requirement.

spacr.install_profile.NO_WGPU_OVERRIDE_NAME = 'no-wgpu-override.txt'[source]

The file no_wgpu_override() writes beside the installer profile.