A fork of hyde, the static site generation. Some patches will be pushed upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

171 lines
6.0 KiB

  1. from setuptools import setup, find_packages
  2. from hyde.version import __version__
  3. from distutils.util import convert_path
  4. from fnmatch import fnmatchcase
  5. import os
  6. import sys
  7. PROJECT = 'hyde'
  8. try:
  9. long_description = open('README.rst', 'rt').read()
  10. except IOError:
  11. long_description = ''
  12. ##############################################################################
  13. # find_package_data is an Ian Bicking creation.
  14. # Provided as an attribute, so you can append to these instead
  15. # of replicating them:
  16. standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*')
  17. standard_exclude_directories = ('.*', 'CVS', '_darcs', './build',
  18. './dist', 'EGG-INFO', '*.egg-info')
  19. def find_package_data(
  20. where='.', package='',
  21. exclude=standard_exclude,
  22. exclude_directories=standard_exclude_directories,
  23. only_in_packages=True,
  24. show_ignored=False):
  25. """
  26. Return a dictionary suitable for use in ``package_data``
  27. in a distutils ``setup.py`` file.
  28. The dictionary looks like::
  29. {'package': [files]}
  30. Where ``files`` is a list of all the files in that package that
  31. don't match anything in ``exclude``.
  32. If ``only_in_packages`` is true, then top-level directories that
  33. are not packages won't be included (but directories under packages
  34. will).
  35. Directories matching any pattern in ``exclude_directories`` will
  36. be ignored; by default directories with leading ``.``, ``CVS``,
  37. and ``_darcs`` will be ignored.
  38. If ``show_ignored`` is true, then all the files that aren't
  39. included in package data are shown on stderr (for debugging
  40. purposes).
  41. Note patterns use wildcards, or can be exact paths (including
  42. leading ``./``), and all searching is case-insensitive.
  43. This function is by Ian Bicking.
  44. """
  45. out = {}
  46. stack = [(convert_path(where), '', package, only_in_packages)]
  47. while stack:
  48. where, prefix, package, only_in_packages = stack.pop(0)
  49. for name in os.listdir(where):
  50. fn = os.path.join(where, name)
  51. if os.path.isdir(fn):
  52. bad_name = False
  53. for pattern in exclude_directories:
  54. if fnmatchcase(name, pattern) or \
  55. fn.lower() == pattern.lower():
  56. bad_name = True
  57. if show_ignored:
  58. msg = "Directory {} ignored by pattern {}"
  59. sys.stderr.write(msg.format(fn, pattern))
  60. break
  61. if bad_name:
  62. continue
  63. if os.path.isfile(os.path.join(fn, '__init__.py')):
  64. if not package:
  65. new_package = name
  66. else:
  67. new_package = package + '.' + name
  68. stack.append((fn, '', new_package, False))
  69. else:
  70. stack.append((fn, prefix + name + '/', package,
  71. only_in_packages))
  72. elif package or not only_in_packages:
  73. # is a file
  74. bad_name = False
  75. for pattern in exclude:
  76. if fnmatchcase(name, pattern) \
  77. or fn.lower() == pattern.lower():
  78. bad_name = True
  79. if show_ignored:
  80. msg = "File {} ignored by pattern {}"
  81. sys.stderr.write(msg.format(fn, pattern))
  82. break
  83. if bad_name:
  84. continue
  85. out.setdefault(package, []).append(prefix+name)
  86. return out
  87. ##############################################################################
  88. def read_requirements(f):
  89. reqs = []
  90. with open(f, "r") as h:
  91. reqs = [req.split('#', 1)[0].strip() for req in h]
  92. reqs = [req for req in reqs if req]
  93. return reqs
  94. install_requires = read_requirements('requirements.txt')
  95. dev_requires = read_requirements('dev-only.txt')
  96. setup(name=PROJECT,
  97. version=__version__,
  98. description='hyde is a static website generator',
  99. long_description=long_description,
  100. author='hyde developers',
  101. author_email='hyde-dev@googlegroups.com',
  102. url='http://hyde.github.io',
  103. packages=find_packages(),
  104. requires=['python (>= 2.7)'],
  105. install_requires=install_requires,
  106. tests_require=dev_requires,
  107. test_suite='nose.collector',
  108. include_package_data=True,
  109. # Scan the input for package information
  110. # to grab any data files (text, images, etc.)
  111. # associated with sub-packages.
  112. package_data=find_package_data(PROJECT,
  113. package=PROJECT,
  114. only_in_packages=False,),
  115. entry_points={
  116. 'console_scripts': [
  117. 'hyde = hyde.main:main'
  118. ]
  119. },
  120. license='MIT',
  121. classifiers=[
  122. 'Development Status :: 4 - Beta',
  123. 'Environment :: Console',
  124. 'Intended Audience :: End Users/Desktop',
  125. 'Intended Audience :: Developers',
  126. 'Intended Audience :: System Administrators',
  127. 'License :: OSI Approved :: MIT License',
  128. 'Operating System :: MacOS :: MacOS X',
  129. 'Operating System :: Unix',
  130. 'Operating System :: POSIX',
  131. 'Operating System :: Microsoft :: Windows',
  132. 'Programming Language :: Python',
  133. 'Programming Language :: Python :: 2',
  134. 'Programming Language :: Python :: 2.7',
  135. 'Programming Language :: Python :: 3',
  136. 'Programming Language :: Python :: 3.3',
  137. 'Programming Language :: Python :: 3.4',
  138. 'Programming Language :: Python :: 3.5',
  139. 'Topic :: Software Development',
  140. 'Topic :: Software Development :: Build Tools',
  141. 'Topic :: Software Development :: Code Generators',
  142. 'Topic :: Internet',
  143. 'Topic :: Internet :: WWW/HTTP :: Site Management',
  144. ],
  145. zip_safe=False,)