Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-tools / setup.py @ 7deaaa5f

History | View | Annotate | Download (7.1 kB)

1
#!/usr/bin/env python
2

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

    
37
import distribute_setup
38
distribute_setup.use_setuptools()
39

    
40
import os
41

    
42
from distutils.util import convert_path
43
from fnmatch import fnmatchcase
44
from setuptools import setup, find_packages
45

    
46
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
47

    
48
try:
49
    # use devtools to update the version file
50
    from devtools.version import update_version
51
    update_version('pithos.tools', 'version', HERE)
52
except ImportError:
53
    raise RuntimeError("devtools is a build dependency")
54

    
55
from pithos.tools.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 = 'Package short description'
62

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

    
66
# Package meta
67
CLASSIFIERS = []
68

    
69
# Package requirements
70
INSTALL_REQUIRES = [
71
    'snf-common>0.9.13',
72
    'progress>=1.0'
73
]
74

    
75
EXTRAS_REQUIRES = {
76
}
77

    
78
TESTS_REQUIRES = [
79
]
80

    
81

    
82
# Provided as an attribute, so you can append to these instead
83
# of replicating them:
84
standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"]
85
standard_exclude_directories = [
86
    ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7"
87
]
88

    
89
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
90
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
91
# Note: you may want to copy this into your setup.py file verbatim, as
92
# you can't import this from another package, when you don't know if
93
# that package is installed yet.
94

    
95

    
96
def find_package_data(
97
    where=".",
98
    package="",
99
    exclude=standard_exclude,
100
    exclude_directories=standard_exclude_directories,
101
    only_in_packages=True,
102
        show_ignored=False):
103
    """
104
    Return a dictionary suitable for use in ``package_data``
105
    in a distutils ``setup.py`` file.
106

107
    The dictionary looks like::
108

109
        {"package": [files]}
110

111
    Where ``files`` is a list of all the files in that package that
112
    don"t match anything in ``exclude``.
113

114
    If ``only_in_packages`` is true, then top-level directories that
115
    are not packages won"t be included (but directories under packages
116
    will).
117

118
    Directories matching any pattern in ``exclude_directories`` will
119
    be ignored; by default directories with leading ``.``, ``CVS``,
120
    and ``_darcs`` will be ignored.
121

122
    If ``show_ignored`` is true, then all the files that aren"t
123
    included in package data are shown on stderr (for debugging
124
    purposes).
125

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

    
175
setup(
176
    name='snf-pithos-tools',
177
    version=VERSION,
178
    license='BSD',
179
    url='http://code.grnet.gr/',
180
    description=SHORT_DESCRIPTION,
181
    long_description=README + '\n\n' + CHANGES,
182
    classifiers=CLASSIFIERS,
183

    
184
    author='Package author',
185
    author_email='author@grnet.gr',
186
    maintainer='Package maintainer',
187
    maintainer_email='maintainer@grnet.gr',
188

    
189
    namespace_packages=['pithos'],
190
    packages=PACKAGES,
191
    package_dir={'': PACKAGES_ROOT},
192
    include_package_data=True,
193
    package_data=find_package_data('.'),
194
    zip_safe=False,
195

    
196
    dependency_links=[
197
        'http://docs.dev.grnet.gr/pypi/'],
198

    
199
    install_requires=INSTALL_REQUIRES,
200
    extras_require=EXTRAS_REQUIRES,
201
    tests_require=TESTS_REQUIRES,
202

    
203
    entry_points={
204
        'console_scripts': [
205
            'pithos-sh = pithos.tools.sh:main',
206
            'pithos-sync = pithos.tools.sync:main',
207
            'pithos-test = pithos.tools.test:main',
208
            'pithos-fs = pithos.tools.fs:main',
209
            'pithos-dispatcher = pithos.tools.dispatcher:main',
210
        ],
211
    },
212
)