3194 self.newProject.emit() |
3194 self.newProject.emit() |
3195 |
3195 |
3196 # set the auto save flag to its supposed value |
3196 # set the auto save flag to its supposed value |
3197 Preferences.setProject("AutoSaveProject", autoSaveProject) |
3197 Preferences.setProject("AutoSaveProject", autoSaveProject) |
3198 |
3198 |
3199 if self.__pdata["EMBEDDED_VENV"]: |
3199 if self.__pdata[ |
|
3200 "EMBEDDED_VENV" |
|
3201 ] and not FileSystemUtilities.isRemoteFileName(self.ppath): |
3200 self.__createEmbeddedEnvironment() |
3202 self.__createEmbeddedEnvironment() |
3201 self.menuEnvironmentAct.setEnabled( |
3203 self.menuEnvironmentAct.setEnabled( |
3202 self.__pdata["EMBEDDED_VENV"] |
3204 self.__pdata["EMBEDDED_VENV"] |
3203 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
3205 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
3204 ) |
3206 ) |
3506 self.projectPropertiesChanged.emit() |
3508 self.projectPropertiesChanged.emit() |
3507 |
3509 |
3508 if self.__pdata["FILETYPES"] != fileTypesDict: |
3510 if self.__pdata["FILETYPES"] != fileTypesDict: |
3509 self.__reorganizeFiles() |
3511 self.__reorganizeFiles() |
3510 |
3512 |
3511 if self.__pdata["EMBEDDED_VENV"] and not self.__findEmbeddedEnvironment(): |
3513 if ( |
|
3514 self.__pdata["EMBEDDED_VENV"] |
|
3515 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
|
3516 and not self.__findEmbeddedEnvironment() |
|
3517 ): |
3512 self.__createEmbeddedEnvironment() |
3518 self.__createEmbeddedEnvironment() |
3513 |
3519 |
3514 def __showUserProperties(self): |
3520 def __showUserProperties(self): |
3515 """ |
3521 """ |
3516 Private slot to display the user specific properties dialog. |
3522 Private slot to display the user specific properties dialog. |
3785 if Preferences.getProject("AutoLoadDbgProperties"): |
3791 if Preferences.getProject("AutoLoadDbgProperties"): |
3786 self.__readDebugProperties(True) |
3792 self.__readDebugProperties(True) |
3787 |
3793 |
3788 self.__model.projectOpened() |
3794 self.__model.projectOpened() |
3789 |
3795 |
3790 if self.__pdata["EMBEDDED_VENV"]: |
3796 if self.__pdata[ |
|
3797 "EMBEDDED_VENV" |
|
3798 ] and not FileSystemUtilities.isRemoteFileName(self.ppath): |
3791 envPath = self.__findEmbeddedEnvironment() |
3799 envPath = self.__findEmbeddedEnvironment() |
3792 if bool(envPath): |
3800 if bool(envPath): |
3793 self.__loadEnvironmentConfiguration() |
3801 self.__loadEnvironmentConfiguration() |
3794 if not bool( |
3802 if not bool( |
3795 self.__venvConfiguration["interpreter"] |
3803 self.__venvConfiguration["interpreter"] |
4579 environment name via the debugger settings if none was configured |
4587 environment name via the debugger settings if none was configured |
4580 @type bool |
4588 @type bool |
4581 @return name of the project's virtual environment |
4589 @return name of the project's virtual environment |
4582 @rtype str |
4590 @rtype str |
4583 """ |
4591 """ |
4584 # TODO: remote server not supported yet |
|
4585 venvName = ( |
4592 venvName = ( |
4586 self.__venvConfiguration["name"] |
4593 self.__venvConfiguration["name"] |
4587 if self.__pdata["EMBEDDED_VENV"] and bool(self.__venvConfiguration["name"]) |
4594 if ( |
|
4595 self.__pdata["EMBEDDED_VENV"] |
|
4596 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
|
4597 and bool(self.__venvConfiguration["name"]) |
|
4598 ) |
4588 else self.getDebugProperty("VIRTUALENV") |
4599 else self.getDebugProperty("VIRTUALENV") |
4589 ) |
4600 ) |
4590 if ( |
4601 if ( |
4591 not venvName |
4602 not venvName |
4592 and resolveDebugger |
4603 and resolveDebugger |
4601 Public method to get the path name of the embedded virtual environment. |
4612 Public method to get the path name of the embedded virtual environment. |
4602 |
4613 |
4603 @return path name of the embedded virtual environment |
4614 @return path name of the embedded virtual environment |
4604 @rtype str |
4615 @rtype str |
4605 """ |
4616 """ |
4606 # TODO: remote server not supported yet |
4617 if ( |
4607 if self.__pdata["EMBEDDED_VENV"]: |
4618 self.__pdata["EMBEDDED_VENV"] |
|
4619 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
|
4620 ): |
4608 return self.__findEmbeddedEnvironment() |
4621 return self.__findEmbeddedEnvironment() |
4609 else: |
4622 else: |
4610 return "" |
4623 return "" |
4611 |
4624 |
4612 def getProjectInterpreter(self, resolveGlobal=True): |
4625 def getProjectInterpreter(self, resolveGlobal=True): |
4618 environment was configured |
4631 environment was configured |
4619 @type bool |
4632 @type bool |
4620 @return path of the project's interpreter |
4633 @return path of the project's interpreter |
4621 @rtype str |
4634 @rtype str |
4622 """ |
4635 """ |
4623 # TODO: remote server not supported yet |
|
4624 interpreter = ( |
4636 interpreter = ( |
4625 self.__venvConfiguration["interpreter"] |
4637 self.__venvConfiguration["interpreter"] |
4626 if self.__pdata["EMBEDDED_VENV"] |
4638 if ( |
|
4639 self.__pdata["EMBEDDED_VENV"] |
|
4640 and not FileSystemUtilities.isRemoteFileName(self.ppath) |
|
4641 ) |
4627 else "" |
4642 else "" |
4628 ) |
4643 ) |
4629 if not interpreter: |
4644 if not interpreter: |
4630 venvName = self.getProjectVenv() |
4645 venvName = self.getProjectVenv() |
4631 if venvName: |
4646 if venvName: |
7752 |
7767 |
7753 @return path of the embedded virtual environment (empty if not found) |
7768 @return path of the embedded virtual environment (empty if not found) |
7754 @rtype str |
7769 @rtype str |
7755 """ |
7770 """ |
7756 ppath = self.getProjectPath() |
7771 ppath = self.getProjectPath() |
7757 if ppath and os.path.exists(ppath): |
7772 if FileSystemUtilities.isRemoteFileName(ppath): |
7758 with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator: |
7773 # check for some common names |
7759 for dirEntry in ppathDirEntriesIterator: |
|
7760 # potential venv directory; check for 'pyvenv.cfg' |
|
7761 if dirEntry.is_dir() and os.path.exists( |
|
7762 os.path.join(dirEntry.path, "pyvenv.cfg") |
|
7763 ): |
|
7764 return dirEntry.path |
|
7765 |
|
7766 # check for some common names in case 'pyvenv.cfg' is missing |
|
7767 for venvPathName in (".venv", "venv", ".env", "env"): |
7774 for venvPathName in (".venv", "venv", ".env", "env"): |
7768 venvPath = os.path.join(self.getProjectPath(), venvPathName) |
7775 venvPath = self.__remotefsInterface.join(ppath, venvPathName) |
7769 if os.path.isdir(venvPath): |
7776 if self.__remotefsInterface.isdir(venvPath): |
7770 return venvPath |
7777 return venvPath |
|
7778 else: |
|
7779 if ppath and os.path.exists(ppath): |
|
7780 with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator: |
|
7781 for dirEntry in ppathDirEntriesIterator: |
|
7782 # potential venv directory; check for 'pyvenv.cfg' |
|
7783 if dirEntry.is_dir() and os.path.exists( |
|
7784 os.path.join(dirEntry.path, "pyvenv.cfg") |
|
7785 ): |
|
7786 return dirEntry.path |
|
7787 |
|
7788 # check for some common names in case 'pyvenv.cfg' is missing |
|
7789 for venvPathName in (".venv", "venv", ".env", "env"): |
|
7790 venvPath = os.path.join(ppath, venvPathName) |
|
7791 if os.path.isdir(venvPath): |
|
7792 return venvPath |
7771 |
7793 |
7772 return "" |
7794 return "" |
7773 |
7795 |
7774 def __setEmbeddedEnvironmentProjectConfig(self, value): |
7796 def __setEmbeddedEnvironmentProjectConfig(self, value): |
7775 """ |
7797 """ |