Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-tools / setup.py @ 9a4600b7

History | View | Annotate | Download (6.9 kB)

1 f2d7b5ab Antony Chazapis
#!/usr/bin/env python
2 f2d7b5ab Antony Chazapis
3 2e662088 Antony Chazapis
# Copyright 2011-2012 GRNET S.A. All rights reserved.
4 05f6d5c0 chazapis
#
5 05f6d5c0 chazapis
# Redistribution and use in source and binary forms, with or
6 05f6d5c0 chazapis
# without modification, are permitted provided that the following
7 05f6d5c0 chazapis
# conditions are met:
8 05f6d5c0 chazapis
#
9 05f6d5c0 chazapis
#   1. Redistributions of source code must retain the above
10 05f6d5c0 chazapis
#      copyright notice, this list of conditions and the following
11 05f6d5c0 chazapis
#      disclaimer.
12 05f6d5c0 chazapis
#
13 05f6d5c0 chazapis
#   2. Redistributions in binary form must reproduce the above
14 05f6d5c0 chazapis
#      copyright notice, this list of conditions and the following
15 05f6d5c0 chazapis
#      disclaimer in the documentation and/or other materials
16 05f6d5c0 chazapis
#      provided with the distribution.
17 05f6d5c0 chazapis
#
18 05f6d5c0 chazapis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19 05f6d5c0 chazapis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 05f6d5c0 chazapis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 05f6d5c0 chazapis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22 05f6d5c0 chazapis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 05f6d5c0 chazapis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 05f6d5c0 chazapis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 05f6d5c0 chazapis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 05f6d5c0 chazapis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 05f6d5c0 chazapis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 05f6d5c0 chazapis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 05f6d5c0 chazapis
# POSSIBILITY OF SUCH DAMAGE.
30 05f6d5c0 chazapis
#
31 05f6d5c0 chazapis
# The views and conclusions contained in the software and
32 05f6d5c0 chazapis
# documentation are those of the authors and should not be
33 05f6d5c0 chazapis
# interpreted as representing official policies, either expressed
34 05f6d5c0 chazapis
# or implied, of GRNET S.A.
35 8c306eab Kostas Papadimitriou
#
36 8c306eab Kostas Papadimitriou
37 8c306eab Kostas Papadimitriou
import distribute_setup
38 8c306eab Kostas Papadimitriou
distribute_setup.use_setuptools()
39 05f6d5c0 chazapis
40 1ad8831f root
import os
41 5adcc57e Christos Stavrakakis
import sys
42 05f6d5c0 chazapis
43 05f6d5c0 chazapis
from distutils.util import convert_path
44 8c306eab Kostas Papadimitriou
from fnmatch import fnmatchcase
45 1ad8831f root
from setuptools import setup, find_packages
46 8c306eab Kostas Papadimitriou
47 8c306eab Kostas Papadimitriou
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
48 f5d58753 Kostas Papadimitriou
49 ee71c0d5 Kostas Papadimitriou
from pithos.tools.version import __version__
50 8c306eab Kostas Papadimitriou
51 8c306eab Kostas Papadimitriou
# Package info
52 8c306eab Kostas Papadimitriou
VERSION = __version__
53 8c306eab Kostas Papadimitriou
README = open(os.path.join(HERE, 'README')).read()
54 8c306eab Kostas Papadimitriou
CHANGES = open(os.path.join(HERE, 'Changelog')).read()
55 5adcc57e Christos Stavrakakis
SHORT_DESCRIPTION = 'Tools for Pithos file storage service'
56 1ad8831f root
57 8c306eab Kostas Papadimitriou
PACKAGES_ROOT = '.'
58 8c306eab Kostas Papadimitriou
PACKAGES = find_packages(PACKAGES_ROOT)
59 5a96180b Antony Chazapis
60 8c306eab Kostas Papadimitriou
# Package meta
61 8c306eab Kostas Papadimitriou
CLASSIFIERS = []
62 5a96180b Antony Chazapis
63 8c306eab Kostas Papadimitriou
# Package requirements
64 5a96180b Antony Chazapis
INSTALL_REQUIRES = [
65 8f63a115 Christos Stavrakakis
    'snf-common',
66 6f6cec5a Sofia Papagiannaki
    'progress>=1.0'
67 5a96180b Antony Chazapis
]
68 f2d7b5ab Antony Chazapis
69 8c306eab Kostas Papadimitriou
EXTRAS_REQUIRES = {
70 8c306eab Kostas Papadimitriou
}
71 8c306eab Kostas Papadimitriou
72 8c306eab Kostas Papadimitriou
TESTS_REQUIRES = [
73 8c306eab Kostas Papadimitriou
]
74 05f6d5c0 chazapis
75 8c306eab Kostas Papadimitriou
76 8c306eab Kostas Papadimitriou
# Provided as an attribute, so you can append to these instead
77 8c306eab Kostas Papadimitriou
# of replicating them:
78 8c306eab Kostas Papadimitriou
standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"]
79 8c306eab Kostas Papadimitriou
standard_exclude_directories = [
80 8c306eab Kostas Papadimitriou
    ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7"
81 8c306eab Kostas Papadimitriou
]
82 05f6d5c0 chazapis
83 05f6d5c0 chazapis
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
84 05f6d5c0 chazapis
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
85 05f6d5c0 chazapis
# Note: you may want to copy this into your setup.py file verbatim, as
86 05f6d5c0 chazapis
# you can't import this from another package, when you don't know if
87 05f6d5c0 chazapis
# that package is installed yet.
88 2715ade4 Sofia Papagiannaki
89 2715ade4 Sofia Papagiannaki
90 05f6d5c0 chazapis
def find_package_data(
91 8c306eab Kostas Papadimitriou
    where=".",
92 8c306eab Kostas Papadimitriou
    package="",
93 05f6d5c0 chazapis
    exclude=standard_exclude,
94 05f6d5c0 chazapis
    exclude_directories=standard_exclude_directories,
95 05f6d5c0 chazapis
    only_in_packages=True,
96 2715ade4 Sofia Papagiannaki
        show_ignored=False):
97 05f6d5c0 chazapis
    """
98 05f6d5c0 chazapis
    Return a dictionary suitable for use in ``package_data``
99 05f6d5c0 chazapis
    in a distutils ``setup.py`` file.
100 05f6d5c0 chazapis

101 05f6d5c0 chazapis
    The dictionary looks like::
102 05f6d5c0 chazapis

103 8c306eab Kostas Papadimitriou
        {"package": [files]}
104 05f6d5c0 chazapis

105 05f6d5c0 chazapis
    Where ``files`` is a list of all the files in that package that
106 8c306eab Kostas Papadimitriou
    don"t match anything in ``exclude``.
107 05f6d5c0 chazapis

108 05f6d5c0 chazapis
    If ``only_in_packages`` is true, then top-level directories that
109 8c306eab Kostas Papadimitriou
    are not packages won"t be included (but directories under packages
110 05f6d5c0 chazapis
    will).
111 05f6d5c0 chazapis

112 05f6d5c0 chazapis
    Directories matching any pattern in ``exclude_directories`` will
113 05f6d5c0 chazapis
    be ignored; by default directories with leading ``.``, ``CVS``,
114 05f6d5c0 chazapis
    and ``_darcs`` will be ignored.
115 05f6d5c0 chazapis

116 8c306eab Kostas Papadimitriou
    If ``show_ignored`` is true, then all the files that aren"t
117 05f6d5c0 chazapis
    included in package data are shown on stderr (for debugging
118 05f6d5c0 chazapis
    purposes).
119 05f6d5c0 chazapis

120 05f6d5c0 chazapis
    Note patterns use wildcards, or can be exact paths (including
121 05f6d5c0 chazapis
    leading ``./``), and all searching is case-insensitive.
122 05f6d5c0 chazapis
    """
123 05f6d5c0 chazapis
    out = {}
124 8c306eab Kostas Papadimitriou
    stack = [(convert_path(where), "", package, only_in_packages)]
125 05f6d5c0 chazapis
    while stack:
126 05f6d5c0 chazapis
        where, prefix, package, only_in_packages = stack.pop(0)
127 05f6d5c0 chazapis
        for name in os.listdir(where):
128 05f6d5c0 chazapis
            fn = os.path.join(where, name)
129 05f6d5c0 chazapis
            if os.path.isdir(fn):
130 05f6d5c0 chazapis
                bad_name = False
131 05f6d5c0 chazapis
                for pattern in exclude_directories:
132 05f6d5c0 chazapis
                    if (fnmatchcase(name, pattern)
133 2715ade4 Sofia Papagiannaki
                            or fn.lower() == pattern.lower()):
134 05f6d5c0 chazapis
                        bad_name = True
135 05f6d5c0 chazapis
                        if show_ignored:
136 05f6d5c0 chazapis
                            print >> sys.stderr, (
137 05f6d5c0 chazapis
                                "Directory %s ignored by pattern %s"
138 05f6d5c0 chazapis
                                % (fn, pattern))
139 05f6d5c0 chazapis
                        break
140 05f6d5c0 chazapis
                if bad_name:
141 05f6d5c0 chazapis
                    continue
142 8c306eab Kostas Papadimitriou
                if (os.path.isfile(os.path.join(fn, "__init__.py"))
143 2715ade4 Sofia Papagiannaki
                        and not prefix):
144 05f6d5c0 chazapis
                    if not package:
145 05f6d5c0 chazapis
                        new_package = name
146 05f6d5c0 chazapis
                    else:
147 8c306eab Kostas Papadimitriou
                        new_package = package + "." + name
148 8c306eab Kostas Papadimitriou
                    stack.append((fn, "", new_package, False))
149 05f6d5c0 chazapis
                else:
150 2715ade4 Sofia Papagiannaki
                    stack.append(
151 2715ade4 Sofia Papagiannaki
                        (fn, prefix + name + "/", package, only_in_packages))
152 05f6d5c0 chazapis
            elif package or not only_in_packages:
153 05f6d5c0 chazapis
                # is a file
154 05f6d5c0 chazapis
                bad_name = False
155 05f6d5c0 chazapis
                for pattern in exclude:
156 05f6d5c0 chazapis
                    if (fnmatchcase(name, pattern)
157 2715ade4 Sofia Papagiannaki
                            or fn.lower() == pattern.lower()):
158 05f6d5c0 chazapis
                        bad_name = True
159 05f6d5c0 chazapis
                        if show_ignored:
160 05f6d5c0 chazapis
                            print >> sys.stderr, (
161 05f6d5c0 chazapis
                                "File %s ignored by pattern %s"
162 05f6d5c0 chazapis
                                % (fn, pattern))
163 05f6d5c0 chazapis
                        break
164 05f6d5c0 chazapis
                if bad_name:
165 05f6d5c0 chazapis
                    continue
166 2715ade4 Sofia Papagiannaki
                out.setdefault(package, []).append(prefix + name)
167 05f6d5c0 chazapis
    return out
168 05f6d5c0 chazapis
169 f2d7b5ab Antony Chazapis
setup(
170 2715ade4 Sofia Papagiannaki
    name='snf-pithos-tools',
171 2715ade4 Sofia Papagiannaki
    version=VERSION,
172 2715ade4 Sofia Papagiannaki
    license='BSD',
173 5adcc57e Christos Stavrakakis
    url='http://www.synnefo.org/',
174 2715ade4 Sofia Papagiannaki
    description=SHORT_DESCRIPTION,
175 2715ade4 Sofia Papagiannaki
    long_description=README + '\n\n' + CHANGES,
176 2715ade4 Sofia Papagiannaki
    classifiers=CLASSIFIERS,
177 2715ade4 Sofia Papagiannaki
178 5adcc57e Christos Stavrakakis
    author='Synnefo development team',
179 5adcc57e Christos Stavrakakis
    author_email='synnefo-devel@googlegroups.com',
180 5adcc57e Christos Stavrakakis
    maintainer='Synnefo development team',
181 5adcc57e Christos Stavrakakis
    maintainer_email='synnefo-devel@googlegroups.com',
182 2715ade4 Sofia Papagiannaki
183 2715ade4 Sofia Papagiannaki
    namespace_packages=['pithos'],
184 2715ade4 Sofia Papagiannaki
    packages=PACKAGES,
185 2715ade4 Sofia Papagiannaki
    package_dir={'': PACKAGES_ROOT},
186 2715ade4 Sofia Papagiannaki
    include_package_data=True,
187 2715ade4 Sofia Papagiannaki
    package_data=find_package_data('.'),
188 2715ade4 Sofia Papagiannaki
    zip_safe=False,
189 2715ade4 Sofia Papagiannaki
190 5adcc57e Christos Stavrakakis
    dependency_links=['http://docs.dev.grnet.gr/pypi/'],
191 8c306eab Kostas Papadimitriou
192 2715ade4 Sofia Papagiannaki
    install_requires=INSTALL_REQUIRES,
193 2715ade4 Sofia Papagiannaki
    extras_require=EXTRAS_REQUIRES,
194 2715ade4 Sofia Papagiannaki
    tests_require=TESTS_REQUIRES,
195 2715ade4 Sofia Papagiannaki
196 2715ade4 Sofia Papagiannaki
    entry_points={
197 2715ade4 Sofia Papagiannaki
        'console_scripts': [
198 2715ade4 Sofia Papagiannaki
            'pithos-sh = pithos.tools.sh:main',
199 2715ade4 Sofia Papagiannaki
            'pithos-sync = pithos.tools.sync:main',
200 2715ade4 Sofia Papagiannaki
            'pithos-test = pithos.tools.test:main',
201 2715ade4 Sofia Papagiannaki
            'pithos-fs = pithos.tools.fs:main',
202 2715ade4 Sofia Papagiannaki
            'pithos-dispatcher = pithos.tools.dispatcher:main',
203 2715ade4 Sofia Papagiannaki
        ],
204 2715ade4 Sofia Papagiannaki
    },
205 f2d7b5ab Antony Chazapis
)