Statistics
| Branch: | Tag: | Revision:

root / setup.py @ 866bb9c1

History | View | Annotate | Download (6.9 kB)

1
# Copyright 2012 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33
#
34
import distribute_setup
35
distribute_setup.use_setuptools()
36

    
37
import os
38
import sys
39

    
40
from distutils.util import convert_path
41
from fnmatch import fnmatchcase
42
from setuptools import setup, find_packages
43

    
44
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
45
try:
46
    from devflow import versioning
47
    # use devflow to update the version file
48
    versioning.update_version('devflow', 'version', HERE)
49
except ImportError:
50
    version_fpath = os.path.join(HERE, 'devflow', 'version.py')
51
    sys.stdout.write("WARNING: Can not update version because `devflow` is"
52
                    " not installed. Please make sure to manually"
53
                    " update version file %s" % version_fpath)
54

    
55
from devflow.version import __version__
56

    
57
# Package info
58
VERSION = __version__
59
README = open(os.path.join(HERE, 'README')).read()
60
CHANGES = open(os.path.join(HERE, 'Changelog')).read()
61
SHORT_DESCRIPTION = 'A set of tools to ease versioning and use of git flow.'
62

    
63
PACKAGES_ROOT = '.'
64
PACKAGES = find_packages(PACKAGES_ROOT)
65

    
66
# Package meta
67
CLASSIFIERS = []
68

    
69
# Package requirements
70
INSTALL_REQUIRES = [
71
    'gitpython'
72
]
73

    
74
# Provided as an attribute, so you can append to these instead
75
# of replicating them:
76
standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"]
77
standard_exclude_directories = [".*", "CVS", "_darcs", "./build", "./dist",
78
                                "EGG-INFO", "*.egg-info"]
79

    
80
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
81
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
82
# Note: you may want to copy this into your setup.py file verbatim, as
83
# you can't import this from another package, when you don't know if
84
# that package is installed yet.
85
def find_package_data(
86
    where=".",
87
    package="",
88
    exclude=standard_exclude,
89
    exclude_directories=standard_exclude_directories,
90
    only_in_packages=True,
91
    show_ignored=False):
92
    """
93
    Return a dictionary suitable for use in ``package_data``
94
    in a distutils ``setup.py`` file.
95

96
    The dictionary looks like::
97

98
        {"package": [files]}
99

100
    Where ``files`` is a list of all the files in that package that
101
    don"t match anything in ``exclude``.
102

103
    If ``only_in_packages`` is true, then top-level directories that
104
    are not packages won"t be included (but directories under packages
105
    will).
106

107
    Directories matching any pattern in ``exclude_directories`` will
108
    be ignored; by default directories with leading ``.``, ``CVS``,
109
    and ``_darcs`` will be ignored.
110

111
    If ``show_ignored`` is true, then all the files that aren"t
112
    included in package data are shown on stderr (for debugging
113
    purposes).
114

115
    Note patterns use wildcards, or can be exact paths (including
116
    leading ``./``), and all searching is case-insensitive.
117
    """
118
    out = {}
119
    stack = [(convert_path(where), "", package, only_in_packages)]
120
    while stack:
121
        where, prefix, package, only_in_packages = stack.pop(0)
122
        for name in os.listdir(where):
123
            fn = os.path.join(where, name)
124
            if os.path.isdir(fn):
125
                bad_name = False
126
                for pattern in exclude_directories:
127
                    if (fnmatchcase(name, pattern)
128
                        or fn.lower() == pattern.lower()):
129
                        bad_name = True
130
                        if show_ignored:
131
                            print >> sys.stderr, (
132
                                "Directory %s ignored by pattern %s"
133
                                % (fn, pattern))
134
                        break
135
                if bad_name:
136
                    continue
137
                if (os.path.isfile(os.path.join(fn, "__init__.py"))
138
                    and not prefix):
139
                    if not package:
140
                        new_package = name
141
                    else:
142
                        new_package = package + "." + name
143
                    stack.append((fn, "", new_package, False))
144
                else:
145
                    stack.append((fn, prefix + name + "/", package,
146
                                  only_in_packages))
147
            elif package or not only_in_packages:
148
                # is a file
149
                bad_name = False
150
                for pattern in exclude:
151
                    if (fnmatchcase(name, pattern)
152
                        or fn.lower() == pattern.lower()):
153
                        bad_name = True
154
                        if show_ignored:
155
                            print >> sys.stderr, (
156
                                "File %s ignored by pattern %s"
157
                                % (fn, pattern))
158
                        break
159
                if bad_name:
160
                    continue
161
                out.setdefault(package, []).append(prefix + name)
162
    return out
163

    
164
setup(
165
    name='devflow',
166
    version=VERSION,
167
    license='BSD',
168
    url='http://www.synnefo.ogr/',
169
    description=SHORT_DESCRIPTION,
170
    long_description=README + '\n\n' + CHANGES,
171
    classifiers=CLASSIFIERS,
172

    
173
    author='GRNET dev team',
174
    author_email='okeanos-dev@lists.grnet.gr',
175
    maintainer='GRNET dev team',
176
    maintainer_email='okeanos-dev@lists.grnet.gr',
177

    
178
    packages=PACKAGES,
179
    package_dir={'': PACKAGES_ROOT},
180
    include_package_data=True,
181
    package_data=find_package_data('.'),
182
    zip_safe=False,
183

    
184
    install_requires=INSTALL_REQUIRES,
185

    
186
    entry_points={
187
     'console_scripts': [
188
         'devflow-version=devflow.versioning:main',
189
         'devflow-autopkg=devflow.autopkg:main',
190
         ],
191
      },
192
)