/win32/config.py

https://bitbucket.org/tortoisehg/hgtk/ · Python · 35 lines · 18 code · 5 blank · 12 comment · 2 complexity · 1bc3fa23743b3b78752d67a65474b138 MD5 · raw file

  1. """
  2. config.py
  3. Copyright (C) 2009 Steve Borho <steve@borho.org>
  4. This software may be used and distributed according to the terms
  5. of the GNU General Public License, incorporated herein by reference.
  6. """
  7. # This version of config.py is used in the binary installer
  8. # distributions of TortoiseHg on Windows. Since we no longer need to
  9. # worry about Python shell extensions, we can use the path of the
  10. # current executable to find our package data.
  11. import os
  12. import sys
  13. import win32api, win32process
  14. proc = win32api.GetCurrentProcess()
  15. try:
  16. # This will fail on windows < NT
  17. procpath = win32process.GetModuleFileNameEx(proc, 0)
  18. except:
  19. procpath = win32api.GetModuleFileName(0)
  20. bin_path = os.path.dirname(procpath)
  21. license_path = os.path.join(bin_path, 'COPYING.txt')
  22. locale_path = os.path.join(bin_path, 'locale')
  23. icon_path = os.path.join(bin_path, 'icons')
  24. enc = sys.getfilesystemencoding()
  25. if enc:
  26. bin_path = bin_path.encode(enc)
  27. license_path = license_path.encode(enc)
  28. locale_path = locale_path.encode(enc)
  29. icon_path = icon_path.encode(enc)