On Sunday, March 24, 2013 11:41:04 AM UTC-7, Lewis Levin wrote:

> Running Spyder on Windows 7.
> Use the command "explore repository" on context menu in file explorer. 
>  The selected folder is (or contains) a git repository (.git is present).
> Spyder returns:  Unable to find external program.  Please install gitk.
>
> When trying commit, Spyder returns:   .... Please install git.
>
> All of git is installed.  This installation works with Wingware ide, 
> Tortoise, and Bash (mingw).
>
> so, the problem is in making Spyder aware of the location of the various 
> git executables.  I cannot find where to do this.  There is no general 
> "install external tool" available through the ui, nor in the ini file. 
>
> I am not in love with apps that have deep layers of dependencies (many 
> points of failure).  There is some reference to sip under PyQt, which is 
> where the connection to git may need to be made.  But, there is no 
> documentation or Google search results to point to any clues.
>
> Can someone point me to some clues?
>
> Thanks.
>
> (Spyder is pretty nice, btw...)
>

TL;DR I updated the patch (_r2) with a check to see if msysgit is already 
in the path, which is probably a good idea. it is attached.

here is the patch text:

--- scm.orig Sat Jan  5 06:31:28 2013
+++ scm.py Tue Apr  2 10:22:35 2013
@@ -6,6 +6,7 @@
 
 """SCM utilities"""
 
+import os
 import os.path as osp
 
 # Local imports
@@ -22,8 +23,10 @@
                                    ('hgtk', ['log']) )
                           ),
              '.git': dict(name="git",
-                          commit=( ('git', ['gui']), ),
-                          browse=( ('gitk', []), )
+                          commit=( ('git', ['gui']),
+                                   ('sh', ['--login', '-c', 'git gui']), ),
+                          browse=( ('gitk', []),
+                                   ('sh', ['--login', '-c', 'gitk']) )
                           ),
              }
 
@@ -59,10 +62,29 @@
     Supported SCM tools: 'commit', 'browse'
     Return False if the SCM tool is not installed"""
     infos = get_scm_infos(get_scm_root(path))
+    # if git and windows, then check for msysgit and add to path
+    if infos['name'] == 'git' and os.name == 'nt':
+        if os.environ["PROCESSOR_ARCHITECTURE"] == "AMD64":
+            programfiles = "%PROGRAMFILES(X86)%"
+        else:
+            programfiles = "%PROGRAMFILES%"
+        programfiles = osp.expandvars(programfiles)
+        git_bin_path = osp.join(programfiles, 'Git', 'bin')
+        windows_path = os.environ['PATH']
+        if git_bin_path.lower() not in 
windows_path.lower().split(os.pathsep):
+            os.environ['PATH'] = os.pathsep.join([windows_path, 
git_bin_path])
     for name, args in infos[tool]:
         if programs.find_program(name):
-            programs.run_program(name, args, cwd=path)
-            return
+            try:
+                programs.run_program(name, args, cwd=path)
+            except WindowsError as windows_error:
+                if windows_error.winerror == 193:
+                    # [Error 193] %1 is not a valid Win32 application
+                    continue
+                else:
+                    raise windows_error
+            else:
+                return
     else:
         raise RuntimeError(_("Please install the %s tool named '%s'")
                            % (infos['name'], name))
 

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


--- scm.orig	Sat Jan  5 06:31:28 2013
+++ scm.py	Tue Apr  2 10:22:35 2013
@@ -6,6 +6,7 @@
 
 """SCM utilities"""
 
+import os
 import os.path as osp
 
 # Local imports
@@ -22,8 +23,10 @@
                                    ('hgtk', ['log']) )
                           ),
              '.git': dict(name="git",
-                          commit=( ('git', ['gui']), ),
-                          browse=( ('gitk', []), )
+                          commit=( ('git', ['gui']),
+                                   ('sh', ['--login', '-c', 'git gui']), ),
+                          browse=( ('gitk', []),
+                                   ('sh', ['--login', '-c', 'gitk']) )
                           ),
              }
 
@@ -59,10 +62,29 @@
     Supported SCM tools: 'commit', 'browse'
     Return False if the SCM tool is not installed"""
     infos = get_scm_infos(get_scm_root(path))
+    # if git and windows, then check for msysgit and add to path
+    if infos['name'] == 'git' and os.name == 'nt':
+        if os.environ["PROCESSOR_ARCHITECTURE"] == "AMD64":
+            programfiles = "%PROGRAMFILES(X86)%"
+        else:
+            programfiles = "%PROGRAMFILES%"
+        programfiles = osp.expandvars(programfiles)
+        git_bin_path = osp.join(programfiles, 'Git', 'bin')
+        windows_path = os.environ['PATH']
+        if git_bin_path.lower() not in windows_path.lower().split(os.pathsep):
+            os.environ['PATH'] = os.pathsep.join([windows_path, git_bin_path])
     for name, args in infos[tool]:
         if programs.find_program(name):
-            programs.run_program(name, args, cwd=path)
-            return
+            try:
+                programs.run_program(name, args, cwd=path)
+            except WindowsError as windows_error:
+                if windows_error.winerror == 193:
+                    # [Error 193] %1 is not a valid Win32 application
+                    continue
+                else:
+                    raise windows_error
+            else:
+                return
     else:
         raise RuntimeError(_("Please install the %s tool named '%s'")
                            % (infos['name'], name))

Reply via email to