API
- microvenv.IN_VIRTUAL_ENV
A boolean representing whether the running interpreter is from a virtual environment.
- microvenv.DEFAULT_ENV_DIR
The default name of the virtual envirnoment directory created by
create()
. The value is.venv
.
- exception microvenv.ActivationError
An error trying to calculate environment activation via
activation()
.
- microvenv.parse_config(env_dir)
Parse the
pyvenv.cfg
file in the specified virtual environment.A dict is returned with strings for keys and values. All keys are lowercased, but otherwise no validation is performed. No changes are made to the values (e.g.,
include-system-site-packages
is not converted to a boolean, nor lowercased).Parsing is done in a way identical to how the
site
module does it. This means that ANY line with an=
sign is considered a line with a key/value pair on it. As such, all other lines are treated as if they are comments. But this also means that having a line start with e.g.,#
does not signify a comment either if there is a=
in the line.
- microvenv.activation(env_vars=os.environ)
Returns a dict with env vars to activate the current virtual environment.
If the current interpreter is not from a virtual environment,
ActivationError
is raised.Since this API is designed to be additive to a environment variables dict (i.e.,
os.environ | activation()
), key deletions are not supported. As such,ActivationError
is raised ifPYTHONHOME
is found to be set.No environment variables are provided in the returned dict in relation to shell prompts.
- microvenv.create(env_dir='.venv', *, scm_ignore_files={'git'})
Create a minimal virtual environment.
Analogous to calling
venv.create()
asvenv.create(..., symlinks=True, with_pip=False)
.Note
Not available on Windows.