Skip to main content

Module python

Module python 

Source
Expand description

The Python Spec Kit’s scripts run. .specify/scripts/bash/common.sh resolves preset templates with a Python that imports PyYAML — its own override SPECKIT_PYTHON_EXECUTABLE, else python3 — and the system python3 usually has no PyYAML, so with a preset installed setup-tasks.sh finds no tasks template. The installed specify runs on a Python that has it (Spec Kit depends on PyYAML): speccoder finds that interpreter, checks that it imports yaml, and gives it to every command of a Spec Kit project — unless the person set the override.

Constants§

FIX
The fix, when no Python with PyYAML is found.
VAR
Spec Kit’s override, read by common.sh.

Functions§

command_env
The variables a command of a Spec Kit project gets: the override, set to the installed specify’s own interpreter when it imports PyYAML. env looks up the command’s environment (its PATH finds specify); nothing when the person set the override or its predecessor, or when no such interpreter is found.
discover
The first interpreter of the specify at specify (canonical) that imports PyYAML: its shebang’s (#!/…/python, or #!/usr/bin/env python3 on path), then the interpreters beside it (a virtual environment’s bin/, as uv tool and pipx install it, whose launcher may be a /bin/sh trampoline).
imports_yaml
Whether python is a Python 3 that imports yaml, as common.sh asks it (run outside any project: a yaml.py there is not PyYAML).
presets
The presets installed in the project at root (.specify/presets/<id>/).
resolver
The Python Spec Kit’s scripts would resolve preset templates with, given the person’s environment env: the override when it imports PyYAML, the installed specify’s interpreter (what speccoder passes), else python3 on PATH. Err: none imports PyYAML — the reason.
specify_interpreter
The interpreter of the specify that path finds, when it imports PyYAML and a sandboxed command can read it (remembered per specify for the process: every command asks).
warning
The warning for the project at root: presets are installed and no Python Spec Kit’s scripts would use imports PyYAML (None: no preset, or one does).
warning_before_add
The same before a preset is installed into the project at root.