slap venv
The slap venv
command is a utility for managing virtual environments created using the standard library venv
module in the current directory or globally (in ~/.local/venvs
).
Slap keeps track of an "active" environment that is used activated by default by commands such as slap install
,
slap link
, slap run
and slap test
before they perform their regular duties. This allows you to not have to
actually activate a virtual environment while still operating within it while using Slap commands (similar to
poetry run
, etc.).
Configuration
The venv
command does not have any Slap configuration options. However, in order to use the slap venv --activate
option properly, you need to configure your shell to shadow the slap
command with a function such that it can
source the activate script.
To do this, run $ slap venv -i <shell>
and add the output to your shell init scripts. Currently, the -i
option
only supports bash
as an argument.
What will be evaluated in your init script then implements the shadow function:
Now you can enjoy using slap venv -a [-g] [<env>]
to activate a virtual environment.
Activate behaviour
Using -a,--activate
without arguments will pick the most recently activated environment in the current context,
or if that is not available, the one and only virtual environment. If multiple environments exist in that case,
it is an error.