src/eric7/Project/Project.py

branch
eric7
changeset 9639
9e66fd88193c
parent 9638
6ee095b9d3bd
child 9640
d10c17b89372
diff -r 6ee095b9d3bd -r 9e66fd88193c src/eric7/Project/Project.py
--- a/src/eric7/Project/Project.py	Thu Dec 22 10:23:28 2022 +0100
+++ b/src/eric7/Project/Project.py	Thu Dec 22 19:46:37 2022 +0100
@@ -2819,11 +2819,22 @@
         # Show the file type associations for the user to change
         self.__showFiletypeAssociations()
 
+        ignoreList = []
+        if self.__pdata["EMBEDDED_VENV"]:
+            environmentPath = self.__findEmbeddedEnvironment()
+            if environmentPath:
+                # there is already an embeded venv; ignore thie whenn adding files
+                ignoreList = [os.path.split(environmentPath)[-1]]
         with EricOverrideCursor():
             # search the project directory for files with known extensions
             filespecs = list(self.__pdata["FILETYPES"].keys())
             for filespec in filespecs:
-                files = FileSystemUtilities.direntries(self.ppath, True, filespec)
+                files = FileSystemUtilities.direntries(
+                    self.ppath,
+                    filesonly=True,
+                    pattern=filespec,
+                    ignore=ignoreList,
+                )
                 for file in files:
                     self.appendFile(file)
 
@@ -6955,7 +6966,8 @@
             ProjectVenvCreationParametersDialog,
         )
 
-        if force or upgrade or not self.__findEmbeddedEnvironment():
+        environmentPath = self.__findEmbeddedEnvironment()
+        if force or upgrade or not environmentPath:
             dlg = ProjectVenvCreationParametersDialog(
                 withSystemSitePackages=self.__venvConfiguration["system_site_packages"]
             )
@@ -7004,6 +7016,12 @@
                 #       site-packages
                 self.__installProjectIntoEnvironment()
 
+        if (
+            environmentPath
+            and not self.__venvConfiguration["interpreter"].startswith(environmentPath)
+        ):
+            self.__configureEnvironment(environmentPath)
+
     @pyqtSlot()
     def __configureEnvironment(self, environmentPath=""):
         """
@@ -7015,7 +7033,9 @@
         from .ProjectVenvConfigurationDialog import ProjectVenvConfigurationDialog
 
         if not environmentPath:
-            environmentPath = os.path.join(self.getProjectPath(), ".venv")
+            environmentPath = self.__findEmbeddedEnvironment()
+            if not environmentPath:
+                environmentPath = os.path.join(self.getProjectPath(), ".venv")
 
         dlg = ProjectVenvConfigurationDialog(
             self.__venvConfiguration["name"],

eric ide

mercurial