We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As per https://stackoverflow.com/questions/8507368/programmatically-not-manually-finding-the-path-where-git-is-installed-on-a-win
It looks like one could use the winreg in order to find git executable. Is this something you tried or are willing to take patch?
The text was updated successfully, but these errors were encountered:
FWIW, the following method do works for me:
import sys if sys.platform == 'win32': import os import winreg def get_git_binary_path(): proc_arch = os.getenv('PROCESSOR_ARCHITECTURE', '').lower() proc_arch64 = os.getenv('PROCESSOR_ARCHITEW6432','').lower() if proc_arch == 'x86' and not proc_arch64: arch_keys = {0} elif proc_arch == 'x86' or proc_arch == 'amd64': arch_keys = {winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY} else: raise Exception("Unhandled arch: %s" % proc_arch) for arch_key in arch_keys: for base_key in [winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER]: try: with winreg.OpenKey( base_key, r"Software\GitForWindows", 0, winreg.KEY_READ | arch_key) as key: path = winreg.QueryValueEx(key, 'InstallPath')[0] git_path = os.path.join(path, 'bin', 'git.exe') if os.path.exists(git_path): return git_path except FileNotFoundError: continue return None else: # on normal platforms, git is just in the PATH def get_git_binary_path(): return 'git'
Sorry, something went wrong.
@tardyp thanks a lot for the suggestion and the research! If you could provide the code above in a PR I would happily merge it.
No branches or pull requests
As per https://stackoverflow.com/questions/8507368/programmatically-not-manually-finding-the-path-where-git-is-installed-on-a-win
It looks like one could use the winreg in order to find git executable. Is this something you tried or are willing to take patch?
The text was updated successfully, but these errors were encountered: