Python Virtual Environment
Overview
When provisioning the csspin_python.python plugin or plugins extending the
SimpleProvisioner protocol, a Python virtual environment will be created at
{python.venv}. This is the Python environment that spin uses when executing
subcommands like spin pytest and spin run <something>.
Environment Activation
Basic Activation
The virtual environment can be activated as described in spin env. This allows executing non-spin commands and
executables like foo.exe within the environment without the need for calling
spin run foo.exe.
Warning
When manually activating the environment, configure and
init hooks of provisioned spin plugins are not executed. This
leads to a slightly different environment than the one used when
running spin run.
Recommended Approach
Instead of manually activating the Python virtual environment, we recommend
using spin run zsh (or your preferred shell). This approach ensures that:
All
initandconfigurehooks of provisioned plugins are executedCommands obtain the same environment as if executed via
spin run <command>The environment setup is consistent and reliable
Important Considerations
Nested Environment Usage: Running spin from within an activated virtual environment is discouraged, as this can lead to unexpected behavior.
Activation Script Integrity: The activation scripts created during spin
provision must not be modified manually. This can and will break the setup!