# eric6.VirtualEnv.VirtualenvManager

Module implementing a class to manage Python virtual environments.

### Global Attributes

None

### Classes

VirtualenvManager | Class implementing an object to manage Python virtual environments.

### Functions

None

## VirtualenvManager

Class implementing an object to manage Python virtual environments.

### Signals

virtualEnvironmentAdded()
  emitted to indicate the addition of a virtual environment
virtualEnvironmentChanged(name)
  emitted to indicate a change of a virtual environment
virtualEnvironmentRemoved()
  emitted to indicate the removal and deletion of a virtual environment

### Derived from

QObject

### Class Attributes

DefaultKey

### Class Methods

None

### Methods

VirtualenvManager | Constructor
__isEnvironmentDeleteable | Private method to check, if a virtual environment can be deleted from disk.
__loadSettings | Private slot to load the virtual environments.
__saveSettings | Private slot to save the virtual environments.
addVirtualEnv | Public method to add a virtual environment.
createVirtualEnv | Public slot to create a new virtual environment.
deleteVirtualEnvs | Public method to delete virtual environments from the list and disk.
getDefaultEnvironment | Public method to get the default virtual environment.
getEnvironmentEntries | Public method to get a dictionary containing the defined virtual environment entries.
getVirtualenvDirectory | Public method to get the directory of a virtual environment.
getVirtualenvExecPath | Public method to get the search path prefix of a virtual environment.
getVirtualenvInterpreter | Public method to get the interpreter for a virtual environment.
getVirtualenvNames | Public method to get a list of defined virtual environments.
getVirtualenvNamesForVariant | Public method to get a list of virtual environments for a given Python variant.
getVirtualenvVariant | Public method to get the variant of a virtual environment.
isCondaEnvironment | Public method to test, if a given environment is an Anaconda environment.
isGlobalEnvironment | Public method to test, if a given environment is a global one.
isRemoteEnvironment | Public method to test, if a given environment is a remotely accessed environment.
isUnique | Public method to check, if the give logical name is unique.
removeVirtualEnvs | Public method to delete virtual environment from the list.
renameVirtualEnv | Public method to substitute a virtual environment entry with a new name.
setVirtualEnv | Public method to change a virtual environment.
showVirtualenvManagerDialog | Public slot to show the virtual environment manager dialog.
shutdown | Public method to shutdown the manager.

### Static Methods

None

#### VirtualenvManager (Constructor)

VirtualenvManager(parent=None)

Constructor

parent (QWidget)
  reference to the parent object

#### VirtualenvManager.__isEnvironmentDeleteable

__isEnvironmentDeleteable(venvName)

Private method to check, if a virtual environment can be deleted from disk.

venvName (str)
  name of the virtual environment

Returns:
  flag indicating it can be deleted

Return Type:
  bool

#### VirtualenvManager.__loadSettings

__loadSettings()

Private slot to load the virtual environments.

#### VirtualenvManager.__saveSettings

__saveSettings()

Private slot to save the virtual environments.

#### VirtualenvManager.addVirtualEnv

addVirtualEnv(venvName, venvDirectory, venvInterpreter="", venvVariant=3, isGlobal=False, isConda=False, isRemote=False, execPath="")

Public method to add a virtual environment.

venvName (str)
  logical name for the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
venvVariant (int)
  Python variant of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.createVirtualEnv

createVirtualEnv()

Public slot to create a new virtual environment.

#### VirtualenvManager.deleteVirtualEnvs

deleteVirtualEnvs(venvNames)

Public method to delete virtual environments from the list and disk.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.getDefaultEnvironment

getDefaultEnvironment()

Public method to get the default virtual environment.

Default is an environment with the key '' or the first one having an interpreter matching sys.executable (i.e. the one used to execute eric6 with)

Returns:
  tuple containing the environment name and a dictionary containing a copy of the default virtual environment

Return Type:
  tuple of (str, dict)

#### VirtualenvManager.getEnvironmentEntries

getEnvironmentEntries()

Public method to get a dictionary containing the defined virtual environment entries.

Returns:
  dictionary containing a copy of the defined virtual environments

Return Type:
  dict

#### VirtualenvManager.getVirtualenvDirectory

getVirtualenvDirectory(venvName)

Public method to get the directory of a virtual environment.

venvName (str)
  logical name for the virtual environment

Returns:
  directory path

Return Type:
  str

#### VirtualenvManager.getVirtualenvExecPath

getVirtualenvExecPath(venvName)

Public method to get the search path prefix of a virtual environment.

venvName (str)
  logical name for the virtual environment

Returns:
  search path prefix

Return Type:
  str

#### VirtualenvManager.getVirtualenvInterpreter

getVirtualenvInterpreter(venvName)

Public method to get the interpreter for a virtual environment.

venvName (str)
  logical name for the virtual environment

Returns:
  interpreter path

Return Type:
  str

#### VirtualenvManager.getVirtualenvNames

getVirtualenvNames(noRemote=False)

Public method to get a list of defined virtual environments.

noRemote (bool)
  flag indicating to exclude environments for remote debugging

Returns:
  list of defined virtual environments

Return Type:
  list of str

#### VirtualenvManager.getVirtualenvNamesForVariant

getVirtualenvNamesForVariant(variant)

Public method to get a list of virtual environments for a given Python variant.

variant (int)
  Python variant (2 or 3)

Returns:
  list of defined virtual environments

Return Type:
  list of str

#### VirtualenvManager.getVirtualenvVariant

getVirtualenvVariant(venvName)

Public method to get the variant of a virtual environment.

venvName (str)
  logical name for the virtual environment

Returns:
  Python variant of the environment

Return Type:
  str

#### VirtualenvManager.isCondaEnvironment

isCondaEnvironment(venvName)

Public method to test, if a given environment is an Anaconda environment.

venvName (str)
  logical name of the virtual environment

Returns:
  flag indicating an Anaconda environment

Return Type:
  bool

#### VirtualenvManager.isGlobalEnvironment

isGlobalEnvironment(venvName)

Public method to test, if a given environment is a global one.

venvName (str)
  logical name of the virtual environment

Returns:
  flag indicating a global environment

Return Type:
  bool

#### VirtualenvManager.isRemoteEnvironment

isRemoteEnvironment(venvName)

Public method to test, if a given environment is a remotely accessed environment.

venvName (str)
  logical name of the virtual environment

Returns:
  flag indicating a remotely accessed environment

Return Type:
  bool

#### VirtualenvManager.isUnique

isUnique(venvName)

Public method to check, if the give logical name is unique.

venvName (str)
  logical name for the virtual environment

Returns:
  flag indicating uniqueness

Return Type:
  bool

#### VirtualenvManager.removeVirtualEnvs

removeVirtualEnvs(venvNames)

Public method to delete virtual environment from the list.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.renameVirtualEnv

renameVirtualEnv(oldVenvName, venvName, venvDirectory, venvInterpreter, venvVariant, isGlobal, isConda, isRemote, execPath)

Public method to substitute a virtual environment entry with a new name.

oldVenvName (str)
  old name of the virtual environment
venvName (str)
  logical name for the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
venvVariant (int)
  Python variant of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.setVirtualEnv

setVirtualEnv(venvName, venvDirectory, venvInterpreter, venvVariant, isGlobal, isConda, isRemote, execPath)

Public method to change a virtual environment.

venvName (str)
  logical name of the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
venvVariant (int)
  Python variant of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.showVirtualenvManagerDialog

showVirtualenvManagerDialog(modal=False)

Public slot to show the virtual environment manager dialog.

modal
  flag indicating that the dialog should be shown in a blocking mode

#### VirtualenvManager.shutdown

shutdown()

Public method to shutdown the manager.

Up