PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/setup.py

https://bitbucket.org/pfw/durusworks
Python | 196 lines | 170 code | 17 blank | 9 comment | 14 complexity | f089308475b37a6cc648b3be8dcbf5fb MD5 | raw file
  1. """
  2. open/DurusWorks/setup.py
  3. This is the setup.py file for DurusWorks.
  4. """
  5. DurusWorks_Version = "1.2"
  6. import re, sys, os
  7. assert sys.version >= "2.6"
  8. from glob import glob
  9. from distutils.core import setup
  10. from distutils.command.build_ext import build_ext
  11. from distutils.command.build_py import build_py
  12. from distutils.command.sdist import sdist
  13. from distutils.extension import Extension
  14. if 'sdist' in sys.argv:
  15. if sys.platform == 'darwin':
  16. # Omit extended attributes from tarfile
  17. os.environ['COPYFILE_DISABLE'] = 'true'
  18. # Make sure that copyright statements are current.
  19. from datetime import datetime
  20. year = datetime.now().year
  21. copyright = \
  22. "Copyright (c) %s Corporation for National Research Initiatives" % year
  23. assert open("README.txt").read().count(copyright) == 1, repr(copyright)
  24. assert open("durus/__init__.py").read().count(copyright) == 1, repr(copyright)
  25. assert open("sancho/__init__.py").read().count(copyright) == 1, repr(copyright)
  26. assert open("qp/__init__.py").read().count(copyright) == 1, repr(copyright)
  27. assert open("qpy/__init__.py").read().count(copyright) == 1, repr(copyright)
  28. class DurusWorks_build_py (build_py):
  29. def find_package_modules(self, package, package_dir):
  30. self.check_package(package, package_dir)
  31. module_files = (glob(os.path.join(package_dir, "*.py")) +
  32. glob(os.path.join(package_dir, "*.qpy")))
  33. modules = []
  34. setup_script = os.path.abspath(self.distribution.script_name)
  35. for f in module_files:
  36. abs_f = os.path.abspath(f)
  37. module = os.path.splitext(os.path.basename(f))[0]
  38. modules.append((package, module, f))
  39. return modules
  40. def build_module(self, module, module_file, package):
  41. if type(package) is str:
  42. package = package.split('.')
  43. elif type(package) not in (list, tuple):
  44. raise TypeError(
  45. "'package' must be a string (dot-separated), list, or tuple")
  46. # Now put the module source file into the "build" area.
  47. outfile = self.get_module_outfile(self.build_lib, package, module)
  48. if module_file.endswith(".qpy"):
  49. outfile = outfile[0:outfile.rfind('.')] + ".qpy"
  50. dir = os.path.dirname(outfile)
  51. self.mkpath(dir)
  52. return self.copy_file(module_file, outfile, preserve_mode=0)
  53. def byte_compile(self, files):
  54. try:
  55. from qpy.compile import compile_qpy_file
  56. except ImportError:
  57. build_py.byte_compile(self, files)
  58. else:
  59. existing = []
  60. for file in files:
  61. if os.path.exists(file):
  62. existing.append(file)
  63. else:
  64. alt = file[:-3] + ".qpy"
  65. compile_qpy_file(alt)
  66. sys.stdout.write('byte-compiling %s\n' % alt)
  67. build_py.byte_compile(self, existing)
  68. class DurusWorks_sdist (sdist):
  69. def get_file_list(self):
  70. sdist.get_file_list(self)
  71. self.filelist.files = []
  72. self.filelist.findall()
  73. print('')
  74. for name in sorted(self.filelist.allfiles):
  75. if ".svn" in name:
  76. continue
  77. if name.endswith('.pyc'):
  78. continue
  79. if name.endswith('.o'):
  80. continue
  81. if name.endswith('.so'):
  82. continue
  83. if name.endswith('.class'):
  84. continue
  85. if name.endswith('~'):
  86. continue
  87. if name.endswith('#'):
  88. continue
  89. if name.startswith('build/'):
  90. continue
  91. if name.startswith('dist/'):
  92. continue
  93. self.filelist.files.append(name)
  94. print('ADDING', name)
  95. print
  96. def write_manifest(self):
  97. pass
  98. class DurusWorks_build_ext (build_ext):
  99. def run(self):
  100. self.force = True # Always rebuild.
  101. self.inplace = True # Always build in place.
  102. build_ext.run(self)
  103. persistent = Extension(name="durus._persistent", sources=["durus/_persistent.c"])
  104. quoted = Extension(name="qpy.quoted", sources=["qpy/quoted.c"])
  105. passfd = Extension(name="qp.hub.passfd", sources=['qp/hub/passfd.c'])
  106. setup(
  107. name = "DurusWorks",
  108. version = DurusWorks_Version,
  109. description = "A Web Application Framework Using Durus",
  110. long_description = """
  111. A small and powerful web application framwork that includes a
  112. transactional object database,
  113. a flexible http or scgi deployment system,
  114. multiple-site management tools,
  115. a way of specifying and checking attribute types,
  116. user and session management,
  117. a form framework,
  118. a unit testing system,
  119. a script for identifying unused imports and unknown names,
  120. and programmer-oriented
  121. package for generating safely quoted html.
  122. """,
  123. scripts = [
  124. "durus/durus",
  125. "qp/bin/qp", "qp/bin/qpcensus.py",
  126. "qpy/qpcheck.py", "qpy/qpyrun.py",
  127. "sancho/urun.py"],
  128. packages = [
  129. "durus", "durus.test",
  130. "qpy", "qpy.test", "qpy.example",
  131. "qp",
  132. "qp.http", "qp.http.test",
  133. "qp.hub", "qp.hub.test",
  134. "qp.pub", "qp.pub.test",
  135. "qp.fill", "qp.fill.test",
  136. "qp.lib", "qp.lib.test",
  137. "qp.mail", "qp.mail.test",
  138. "qp.sites",
  139. "sancho", "sancho.test"
  140. ],
  141. platforms = ['Python 2.6 - 3.3 on posix or darwin'],
  142. author = "CNRI",
  143. author_email = "webmaster@mems-exchange.org",
  144. url = "http://www.mems-exchange.org/software/DurusWorks/",
  145. ext_modules = [persistent, quoted, passfd],
  146. cmdclass=dict(
  147. build_py=DurusWorks_build_py,
  148. build_ext=DurusWorks_build_ext,
  149. sdist=DurusWorks_sdist),
  150. license = "see LICENSE.txt",
  151. classifiers = [
  152. 'Development Status :: 5 - Production/Stable',
  153. 'Environment :: Web Environment',
  154. 'Framework :: DurusWorks',
  155. 'Intended Audience :: Developers',
  156. 'Operating System :: MacOS :: MacOS X',
  157. 'Operating System :: POSIX',
  158. 'Operating System :: Unix',
  159. 'Programming Language :: Python :: 2.6',
  160. 'Programming Language :: Python :: 2.7',
  161. 'Programming Language :: Python :: 3',
  162. 'Programming Language :: Python :: 3.0',
  163. 'Programming Language :: Python :: 3.1',
  164. 'Programming Language :: Python :: 3.2',
  165. 'Programming Language :: Python :: 3.3',
  166. 'Topic :: Database',
  167. 'Topic :: Database :: Database Engines/Servers',
  168. 'Topic :: Database :: Front-Ends',
  169. 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  170. 'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
  171. 'Topic :: Internet :: WWW/HTTP :: Site Management',
  172. 'Topic :: Software Development :: Libraries :: Application Frameworks',
  173. 'Topic :: Software Development :: Widget Sets',
  174. 'Topic :: Text Processing :: Markup :: HTML',
  175. 'Topic :: Text Processing :: Markup :: XML',
  176. ]
  177. )