Fri, 23 Dec 2022 08:46:59 +0100
Implemented a scanning solution to find the path name of an existing embedded environment (see issue480, msg1848).
src/eric7/Project/Project.py | file | annotate | diff | comparison | revisions |
--- a/src/eric7/Project/Project.py Thu Dec 22 19:46:37 2022 +0100 +++ b/src/eric7/Project/Project.py Fri Dec 23 08:46:59 2022 +0100 @@ -2035,6 +2035,7 @@ if filetype == "__IGNORE__" ] + # TODO: replace os.listdir() with os.scandir() # now recurse into subdirectories for name in os.listdir(source): ns = os.path.join(source, name) @@ -6922,6 +6923,14 @@ @return path of the embedded virtual environment (empty if not found) @rtype str """ + with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator: + for dirEntry in ppathDirEntriesIterator: + if dirEntry.is_dir(): + # potential venv directory; check for 'pyvenv.cfg' + if os.path.exists(os.path.join(dirEntry.path, "pyvenv.cfg")): + return dirEntry.path + + # check for some common names in case 'pyvenv.cfg' is missing for venvPathName in (".venv", "venv", ".env", "env"): venvPath = os.path.join(self.getProjectPath(), venvPathName) if os.path.isdir(venvPath):