VirtualEnv#

class neophile.virtualenv.VirtualEnv(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 (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()#

Create the virtualenv if it does not already exist.

Raises:

subprocess.CalledProcessError – Raised on failure to install the wheel package.

Return type:

None

run(command, **kwargs)#

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 (Any) – The arguments, which except for the env parameter if any will be passed as-is to subprocess.run.

Returns:

Return value of subprocess.run.

Return type:

subprocess.CompletedProcess

Raises:

subprocess.CalledProcessError – Raised on failure to install the wheel package or failure of the provided command.