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...)
>

**Okay, please disregard my previous patch 
(spyderlib_utils_programs.patch)! **

I posted this with a new patch as a new issue here:
https://code.google.com/p/spyderlib/issues/detail?id=1333

Here is the new patch. Instead of editing programs.py, which should be 
agnostic of scm, I made all the changes in scm.py, which make more sense 
since we are trying to run scm on windows pc, esp. msysgit. I also followed 
the convention previously laid out of adding commands to the SCM_INFOS 
global at the top of the file. The only one that really needs to be added 
is ('sh', ['--login', '-c', 'gitk']) because gitk is actually a shell 
script, and so it will not run if called from windows. I also added a check 
for msysgit and if present adds it to the path. Finally I put try-except 
around run program to catch WindowsError which happens when it tries to run 
gitk without sh -c, because it is a shell script, not an win32 application.

--- /c/Python27/lib/site-packages/spyderlib/utils/scm.orig Sat Jan  5 
06:31:28 2013
+++ /c/Python27/lib/site-packages/spyderlib/utils/scm.py Tue Mar 26 
00:10:05 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,28 @@
     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']
+        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.


--- /c/Python27/lib/site-packages/spyderlib/utils/scm.orig	Sat Jan  5 06:31:28 2013
+++ /c/Python27/lib/site-packages/spyderlib/utils/scm.py	Tue Mar 26 00:10:05 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,28 @@
     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']
+        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