Thu, 22 Dec 2022 19:46:37 +0100
Corrected the logic for the project creation if the project directory already contains files and an embedded environment (see issue 480).
--- a/src/eric7/APIs/Python3/eric7.api Thu Dec 22 10:23:28 2022 +0100 +++ b/src/eric7/APIs/Python3/eric7.api Thu Dec 22 19:46:37 2022 +0100 @@ -9294,7 +9294,7 @@ eric7.SystemUtilities.FileSystemUtilities.absolutePath?4(path, start) eric7.SystemUtilities.FileSystemUtilities.absoluteUniversalPath?4(path, start) eric7.SystemUtilities.FileSystemUtilities.compactPath?4(path, width, measure=len) -eric7.SystemUtilities.FileSystemUtilities.direntries?4(path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None) +eric7.SystemUtilities.FileSystemUtilities.direntries?4(path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None, ignore=None, ) eric7.SystemUtilities.FileSystemUtilities.findVolume?4(volumeName, findAll=False) eric7.SystemUtilities.FileSystemUtilities.fromNativeSeparators?4(path) eric7.SystemUtilities.FileSystemUtilities.getDirs?4(path, excludeDirs)
--- a/src/eric7/Documentation/Source/eric7.SystemUtilities.FileSystemUtilities.html Thu Dec 22 10:23:28 2022 +0100 +++ b/src/eric7/Documentation/Source/eric7.SystemUtilities.FileSystemUtilities.html Thu Dec 22 19:46:37 2022 +0100 @@ -218,7 +218,7 @@ <hr /> <a NAME="direntries" ID="direntries"></a> <h2>direntries</h2> -<b>direntries</b>(<i>path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None</i>) +<b>direntries</b>(<i>path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None, ignore=None, </i>) <p> Function returning a list of all files and directories. @@ -247,6 +247,10 @@ <dd> function to be called to check for a stop </dd> +<dt><i>ignore</i> (list of str)</dt> +<dd> +list of entries to be ignored +</dd> </dl> <dl> <dt>Return:</dt>
--- 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"],
--- a/src/eric7/SystemUtilities/FileSystemUtilities.py Thu Dec 22 10:23:28 2022 +0100 +++ b/src/eric7/SystemUtilities/FileSystemUtilities.py Thu Dec 22 19:46:37 2022 +0100 @@ -425,7 +425,12 @@ def direntries( - path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None + path, + filesonly=False, + pattern=None, + followsymlinks=True, + checkStop=None, + ignore=None, ): """ Function returning a list of all files and directories. @@ -442,26 +447,32 @@ @type bool @param checkStop function to be called to check for a stop @type function + @param ignore list of entries to be ignored + @type list of str @return list of all files and directories in the tree rooted at path. The names are expanded to start with path. @rtype list of strs """ patterns = pattern if isinstance(pattern, list) else [pattern] files = [] if filesonly else [path] + ignoreList = [ + ".svn", + ".hg", + ".git", + ".ropeproject", + ".eric7project", + ".jedi", + ] + if ignore is not None: + ignoreList.extend(ignore) + try: entries = os.listdir(path) for entry in entries: if checkStop and checkStop(): break - if entry in [ - ".svn", - ".hg", - ".git", - ".ropeproject", - ".eric7project", - ".jedi", - ]: + if entry in ignoreList: continue fentry = os.path.join(path, entry)