# 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.

### 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.
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.
isGlobalEnvironment | Public method to test, if a given environment is a global one.
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)

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

#### 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.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()

Public method to get a list of defined virtual environments.

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.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.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)

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

#### VirtualenvManager.setVirtualEnv

setVirtualEnv(venvName, venvDirectory, venvInterpreter, venvVariant, isGlobal)

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

#### 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