/PC/VC6/build_tkinter.py

http://unladen-swallow.googlecode.com/ · Python · 81 lines · 69 code · 12 blank · 0 comment · 17 complexity · 410416debd65a1a3ea363860afa4c7ee MD5 · raw file

  1. import os
  2. import sys
  3. import subprocess
  4. TCL_MAJOR = 8
  5. TCL_MINOR = 5
  6. TCL_PATCH = 2
  7. TIX_MAJOR = 8
  8. TIX_MINOR = 4
  9. TIX_PATCH = 3
  10. def abspath(name):
  11. par = os.path.pardir
  12. return os.path.abspath(os.path.join(__file__, par, par, par, par, name))
  13. TCL_DIR = abspath("tcl%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH))
  14. TK_DIR = abspath("tk%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH))
  15. TIX_DIR = abspath("tix%d.%d.%d" % (TIX_MAJOR, TIX_MINOR, TIX_PATCH))
  16. OUT_DIR = abspath("tcltk")
  17. def have_args(*a):
  18. return any(s in sys.argv[1:] for s in a)
  19. def enter(dir):
  20. os.chdir(os.path.join(dir, "win"))
  21. def main():
  22. debug = have_args("-d", "--debug")
  23. clean = have_args("clean")
  24. install = have_args("install")
  25. tcl = have_args("tcl")
  26. tk = have_args("tk")
  27. tix = have_args("tix")
  28. if not(tcl) and not(tk) and not(tix):
  29. tcl = tk = tix = True
  30. def nmake(makefile, *a):
  31. args = ["nmake", "/nologo", "/f", makefile, "DEBUG=%d" % debug]
  32. args.extend(a)
  33. subprocess.check_call(args)
  34. if tcl:
  35. enter(TCL_DIR)
  36. def nmake_tcl(*a):
  37. nmake("makefile.vc", *a)
  38. if clean:
  39. nmake_tcl("clean")
  40. elif install:
  41. nmake_tcl("install", "INSTALLDIR=" + OUT_DIR)
  42. else:
  43. nmake_tcl()
  44. if tk:
  45. enter(TK_DIR)
  46. def nmake_tk(*a):
  47. nmake("makefile.vc", "TCLDIR=" + TCL_DIR, *a)
  48. if clean:
  49. nmake_tk("clean")
  50. elif install:
  51. nmake_tk("install", "INSTALLDIR=" + OUT_DIR)
  52. else:
  53. nmake_tk()
  54. if tix:
  55. enter(TIX_DIR)
  56. def nmake_tix(*a):
  57. nmake("python.mak",
  58. "TCL_MAJOR=%d" % TCL_MAJOR,
  59. "TCL_MINOR=%d" % TCL_MINOR,
  60. "TCL_PATCH=%d" % TCL_PATCH,
  61. "MACHINE=IX86", *a)
  62. if clean:
  63. nmake_tix("clean")
  64. elif install:
  65. nmake_tix("install", "INSTALL_DIR=" + OUT_DIR)
  66. else:
  67. nmake_tix()
  68. if __name__ == '__main__':
  69. main()