ProjectPyramid/Project.py

changeset 91
893e1f0baf23
parent 88
464745dfb03a
child 95
2b0933087db9
--- a/ProjectPyramid/Project.py	Thu Aug 18 16:25:15 2016 +0200
+++ b/ProjectPyramid/Project.py	Fri Nov 11 18:51:53 2016 +0100
@@ -604,10 +604,9 @@
                 if fullCmd != cmd:
                     variants.append(variant)
             else:
+                fullCmd = self.getPyramidCommand(cmd, variant)
                 if isWindowsPlatform():
-                    debugEnv = self.__getDebugEnvironment(variant)
-                    fullCmd = os.path.join(debugEnv, "Scripts", cmd)
-                    if variant.lower() in fullCmd.lower():
+                    if fullCmd != cmd:
                         variants.append(variant)
                 else:
                     try:
@@ -693,7 +692,14 @@
         if isWindowsPlatform() and not virtualEnv:
             virtualEnv = self.__getDebugEnvironment(language)
         if isWindowsPlatform():
-            cmd = os.path.join(virtualEnv, "Scripts", cmd + '.exe')
+            fullCmds = [
+                os.path.join(virtualEnv, "Scripts", cmd + '.exe'),
+                os.path.join(virtualEnv, "bin", cmd + '.exe'),
+                cmd     # fall back to just cmd
+            ]
+            for cmd in fullCmds:
+                if os.path.exists(cmd):
+                    break
         else:
             fullCmds = [
                 os.path.join(virtualEnv, "bin", cmd),
@@ -713,28 +719,50 @@
         @return python command (string)
         """
         language = self.__e5project.getProjectLanguage()
-        pythonExe = "python"
+        virtualEnv = self.__getVirtualEnvironment()
         if isWindowsPlatform():
-            pythonExe += ".exe"
+            pythonExeList = ["python.exe", "pypy.exe"]
+            if not virtualEnv:
+                virtualEnv = self.__getDebugEnvironment(language)
+            for pythonExe in pythonExeList:
+                for python in [
+                    os.path.join(virtualEnv, "Scripts", pythonExe),
+                    os.path.join(virtualEnv, "bin", pythonExe),
+                    os.path.join(virtualEnv, pythonExe)
+                ]:
+                    if os.path.exists(python):
+                        break
+                else:
+                    python = ""
+                
+                if python:
+                    break
+            else:
+                python = ""
         else:
             if language == "Python3":
-                pythonExe = "python3"
+                pythonExeList = ["python3", "pypy3"]
             elif language == "Python2":
-                pythonExe = "python2"
-        virtualEnv = self.__getVirtualEnvironment()
-        if isWindowsPlatform() and not virtualEnv:
-            virtualEnv = self.__getDebugEnvironment(language)
-        if virtualEnv:
-            if isWindowsPlatform():
-                python = os.path.join(virtualEnv, "Scripts", pythonExe)
-                if not os.path.exists(python):
-                    python = os.path.join(virtualEnv, pythonExe)
+                pythonExeList = ["python2", "pypy2"]
+            if not virtualEnv:
+                pythonExeList.append("pypy")
+                virtualEnv = self.__getDebugEnvironment(language)
+            
+            for pythonExe in pythonExeList:
+                for python in [
+                    os.path.join(virtualEnv, "bin", pythonExe),
+                    # omit the version character
+                    os.path.join(virtualEnv, "bin", pythonExe)[:-1],
+                ]:
+                    if os.path.exists(python):
+                        break
+                else:
+                    python = ""
+            
+                if python:
+                    break
             else:
-                python = os.path.join(virtualEnv, "bin", pythonExe)
-                if not os.path.exists(python):
-                    python = python[:-1]    # omit the version character
-        else:
-            python = pythonExe
+                python = ""
         
         return python
     

eric ide

mercurial