src/eric7/VirtualEnv/VirtualenvManager.py

branch
eric7
changeset 10203
56ff5d86807a
parent 10200
7c282bf19646
child 10204
9a8a0bdedd80
equal deleted inserted replaced
10202:b08107707009 10203:56ff5d86807a
5 5
6 """ 6 """
7 Module implementing a class to manage Python virtual environments. 7 Module implementing a class to manage Python virtual environments.
8 """ 8 """
9 9
10 import contextlib
10 import copy 11 import copy
11 import json 12 import json
12 import os 13 import os
13 import shutil 14 import shutil
14 import sys 15 import sys
104 defaultPy = PythonUtilities.getPythonExecutable() 105 defaultPy = PythonUtilities.getPythonExecutable()
105 if "{0}.venv{0}".format(os.sep) not in defaultPy: 106 if "{0}.venv{0}".format(os.sep) not in defaultPy:
106 # only check for a non-embedded environment 107 # only check for a non-embedded environment
107 found = False 108 found = False
108 for venvName in self.__virtualEnvironments: 109 for venvName in self.__virtualEnvironments:
109 if os.path.samefile( 110 with contextlib.suppress(FileNotFoundError):
110 defaultPy, self.__virtualEnvironments[venvName].interpreter 111 if os.path.samefile(
111 ): 112 defaultPy, self.__virtualEnvironments[venvName].interpreter
112 found = True 113 ):
113 break 114 found = True
115 break
114 if not found: 116 if not found:
115 # add an environment entry for the default interpreter 117 # add an environment entry for the default interpreter
116 self.__virtualEnvironments[ 118 self.__virtualEnvironments[
117 VirtualenvManager.DefaultKey 119 VirtualenvManager.DefaultKey
118 ] = VirtualenvMetaData( 120 ] = VirtualenvMetaData(

eric ide

mercurial