PageRenderTime 14ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/setup.py

https://bitbucket.org/ianb/silverlining/
Python | 135 lines | 124 code | 6 blank | 5 comment | 16 complexity | 201d77ed0d204a3202c3879e81c62ed4 MD5 | raw file
Possible License(s): GPL-2.0
  1. from setuptools import setup, find_packages
  2. import sys, os
  3. from fnmatch import fnmatchcase
  4. from distutils.util import convert_path
  5. version = '0.1'
  6. # Provided as an attribute, so you can append to these instead
  7. # of replicating them:
  8. standard_exclude = ('*.pyc', '*~', '.*', '*.bak')
  9. standard_exclude_directories = (
  10. '.*', 'CVS', '.svn', '.hg', '_darcs', './build',
  11. './dist', 'EGG-INFO', '*.egg-info')
  12. def find_package_data(
  13. where='.', package='',
  14. exclude=standard_exclude,
  15. exclude_directories=standard_exclude_directories,
  16. only_in_packages=True,
  17. show_ignored=False,
  18. fake_packages=()):
  19. """
  20. Return a dictionary suitable for use in ``package_data``
  21. in a distutils ``setup.py`` file.
  22. The dictionary looks like::
  23. {'package': [files]}
  24. Where ``files`` is a list of all the files in that package that
  25. don't match anything in ``exclude``.
  26. If ``only_in_packages`` is true, then top-level directories that
  27. are not packages won't be included (but directories under packages
  28. will).
  29. Directories matching any pattern in ``exclude_directories`` will
  30. be ignored; by default directories with leading ``.``, ``CVS``,
  31. and ``_darcs`` will be ignored.
  32. If ``show_ignored`` is true, then all the files that aren't
  33. included in package data are shown on stderr (for debugging
  34. purposes).
  35. Note patterns use wildcards, or can be exact paths (including
  36. leading ``./``), and all searching is case-insensitive.
  37. """
  38. out = {}
  39. stack = [(convert_path(where), '', package, only_in_packages)]
  40. while stack:
  41. where, prefix, package, only_in_packages = stack.pop(0)
  42. for name in os.listdir(where):
  43. fn = os.path.join(where, name)
  44. if os.path.isdir(fn):
  45. bad_name = False
  46. for pattern in exclude_directories:
  47. if (fnmatchcase(name, pattern)
  48. or fn.lower() == pattern.lower()):
  49. bad_name = True
  50. if show_ignored:
  51. print >> sys.stderr, (
  52. "Directory %s ignored by pattern %s"
  53. % (fn, pattern))
  54. break
  55. if bad_name:
  56. continue
  57. if (os.path.isfile(os.path.join(fn, '__init__.py'))
  58. and not prefix
  59. and os.path.basename(fn) not in fake_packages):
  60. if not package:
  61. new_package = name
  62. else:
  63. new_package = package + '.' + name
  64. stack.append((fn, '', new_package, False))
  65. else:
  66. stack.append((fn, prefix + name + '/', package, only_in_packages))
  67. elif package or not only_in_packages:
  68. # is a file
  69. bad_name = False
  70. for pattern in exclude:
  71. if (fnmatchcase(name, pattern)
  72. or fn.lower() == pattern.lower()):
  73. bad_name = True
  74. if show_ignored:
  75. print >> sys.stderr, (
  76. "File %s ignored by pattern %s"
  77. % (fn, pattern))
  78. break
  79. if (name.endswith('.py')
  80. and os.path.exists(os.path.join(where, '__init__.py'))
  81. and os.path.basename(where) not in fake_packages):
  82. bad_name = True
  83. if bad_name:
  84. continue
  85. out.setdefault(package, []).append(prefix+name)
  86. return out
  87. package_data = find_package_data(
  88. where=os.path.join(os.path.dirname(__file__), 'silverlining'),
  89. package='silverlining')
  90. package_data.update(find_package_data(
  91. where=os.path.join(os.path.dirname(__file__), 'silversupport'),
  92. package='silversupport'))
  93. setup(name='SilverLining',
  94. version=version,
  95. description="Library for creating cloud servers",
  96. long_description="""\
  97. """,
  98. classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
  99. keywords='',
  100. author='Ian Bicking',
  101. author_email='ianb@openplans.org',
  102. url='',
  103. license='GPL',
  104. packages=['silverlining', 'silverlining.commands', 'silversupport', 'silversupport.service'],
  105. zip_safe=False,
  106. install_requires=[
  107. 'CmdUtils',
  108. 'apache-libcloud',
  109. 'Tempita',
  110. 'argparse',
  111. 'virtualenv>=1.4.3',
  112. 'INITools',
  113. 'zope.interface',
  114. 'Paste',
  115. ],
  116. entry_points="""
  117. [console_scripts]
  118. silver = silverlining.runner:main
  119. """,
  120. package_data=package_data,
  121. )