setup.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env python3
  2. import os
  3. import re
  4. from distutils.core import setup
  5. try:
  6. import py2exe
  7. except ImportError as e:
  8. py2exe = None
  9. try:
  10. if py2exe and "py2exe" in sys.argv:
  11. raise ImportError
  12. from cx_Freeze import setup, Executable
  13. cx_Freeze = True
  14. except ImportError as e:
  15. cx_Freeze = False
  16. isWindows = os.name.lower() in {"nt", "ce"}
  17. extraKeywords = {}
  18. # Workaround for mbcs codec bug in distutils
  19. # http://bugs.python.org/issue10945
  20. import codecs
  21. try:
  22. codecs.lookup("mbcs")
  23. except LookupError:
  24. codecs.register(lambda name: codecs.lookup("ascii") if name == "mbcs" else None)
  25. # Create freeze executable list.
  26. guiBase = None
  27. if isWindows:
  28. guiBase = "Win32GUI"
  29. freezeExecutables = [ ("piccol", None, guiBase), ]
  30. if py2exe:
  31. extraKeywords["console"] = [ s for s, e, b in freezeExecutables ]
  32. if cx_Freeze:
  33. executables = []
  34. for script, exe, base in freezeExecutables:
  35. if exe:
  36. if isWindows:
  37. exe += ".exe"
  38. executables.append(Executable(script = script,
  39. targetName = exe,
  40. base = base))
  41. else:
  42. executables.append(Executable(script = script,
  43. base = base))
  44. extraKeywords["executables"] = executables
  45. extraKeywords["options"] = {
  46. "build_exe" : {
  47. "packages" : [ ],
  48. }
  49. }
  50. version = "unknown_version"
  51. m = re.match(r'.*^\s*PICCOL_VERSION\s*=\s*"([\w\d\.\-_]+)"\s*$.*',
  52. open("piccol").read(),
  53. re.DOTALL | re.MULTILINE)
  54. if m:
  55. version = m.group(1)
  56. print("piccol version %s" % version)
  57. setup( name = "piccol",
  58. version = version,
  59. description = "Color picker and translator",
  60. license = "GNU General Public License v2 or later",
  61. author = "Michael Buesch",
  62. author_email = "m@bues.ch",
  63. url = "https://bues.ch/",
  64. scripts = [ "piccol", ],
  65. keywords = [ "color", "RGB", "HLS", "HSL", ],
  66. classifiers = [
  67. "Development Status :: 5 - Production/Stable",
  68. "Environment :: Win32 (MS Windows)",
  69. "Environment :: X11 Applications",
  70. "Environment :: X11 Applications :: Qt",
  71. "Intended Audience :: End Users/Desktop",
  72. "Intended Audience :: Developers",
  73. "Intended Audience :: Education",
  74. "Intended Audience :: Information Technology",
  75. "Intended Audience :: System Administrators",
  76. "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
  77. "Operating System :: Microsoft :: Windows",
  78. "Operating System :: POSIX",
  79. "Operating System :: POSIX :: Linux",
  80. "Programming Language :: Python",
  81. "Programming Language :: Python :: 3",
  82. "Programming Language :: Python :: Implementation :: CPython",
  83. "Topic :: Desktop Environment",
  84. "Topic :: Education",
  85. "Topic :: Scientific/Engineering",
  86. "Topic :: Software Development",
  87. ],
  88. long_description = open("README.md").read(),
  89. **extraKeywords
  90. )