src/eric7/Project/Project.py

branch
eric7
changeset 9640
d10c17b89372
parent 9639
9e66fd88193c
child 9644
9875d5f11cbf
diff -r 9e66fd88193c -r d10c17b89372 src/eric7/Project/Project.py
--- 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):

eric ide

mercurial