VirtualEnv

class neophile.virtualenv.VirtualEnv(path: Path)

Bases: object

Manage virtual environments.

Python dependency updates using make update have to be done inside a virtual environment because they may attempt to install packages with pip. This class manages creation and execution of commands inside a virtual environment.

Parameters:path (pathlib.Path) – Path to where to create the virtual environment. If that directory already exists, it will be used as an existing virtual environment instead of creating a new one.

Methods Summary

create() Create the virtualenv if it does not already exist.
run(command, **kwargs) Run a command inside the virtualenv.

Methods Documentation

create() → None

Create the virtualenv if it does not already exist.

Raises:subprocess.CalledProcessError – On failure to install the wheel package or if the command given sets the check argument.
run(command: Sequence[str], **kwargs) → CompletedProcess

Run a command inside the virtualenv.

Sets up the virtualenv if necessary and then runs the command given.

Parameters:
  • command (Sequence[str]) – The command to run.
  • **kwargs (typing.Any) – The arguments, which except for the env parameter if any will be passed as-is to subprocess.run().
Returns:

result – The return value of subprocess.run().

Return type:

subprocess.CompletedProcess

Raises:

subprocess.CalledProcessError – On failure to install the wheel package or if the command given sets the check argument.