PageRenderTime 123ms CodeModel.GetById 72ms app.highlight 11ms RepoModel.GetById 36ms app.codeStats 1ms

/setup.py

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