Statistics
| Branch: | Tag: | Revision:

root / snf-django-lib / setup.py @ 34bd6588

History | View | Annotate | Download (6.4 kB)

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

93 a712571b Christos Stavrakakis
    The dictionary looks like::
94 a712571b Christos Stavrakakis

95 a712571b Christos Stavrakakis
        {"package": [files]}
96 a712571b Christos Stavrakakis

97 a712571b Christos Stavrakakis
    Where ``files`` is a list of all the files in that package that
98 a712571b Christos Stavrakakis
    don"t match anything in ``exclude``.
99 a712571b Christos Stavrakakis

100 a712571b Christos Stavrakakis
    If ``only_in_packages`` is true, then top-level directories that
101 a712571b Christos Stavrakakis
    are not packages won"t be included (but directories under packages
102 a712571b Christos Stavrakakis
    will).
103 a712571b Christos Stavrakakis

104 a712571b Christos Stavrakakis
    Directories matching any pattern in ``exclude_directories`` will
105 a712571b Christos Stavrakakis
    be ignored; by default directories with leading ``.``, ``CVS``,
106 a712571b Christos Stavrakakis
    and ``_darcs`` will be ignored.
107 a712571b Christos Stavrakakis

108 a712571b Christos Stavrakakis
    If ``show_ignored`` is true, then all the files that aren"t
109 a712571b Christos Stavrakakis
    included in package data are shown on stderr (for debugging
110 a712571b Christos Stavrakakis
    purposes).
111 a712571b Christos Stavrakakis

112 a712571b Christos Stavrakakis
    Note patterns use wildcards, or can be exact paths (including
113 a712571b Christos Stavrakakis
    leading ``./``), and all searching is case-insensitive.
114 a712571b Christos Stavrakakis
    """
115 a712571b Christos Stavrakakis
    out = {}
116 a712571b Christos Stavrakakis
    stack = [(convert_path(where), "", package, only_in_packages)]
117 a712571b Christos Stavrakakis
    while stack:
118 a712571b Christos Stavrakakis
        where, prefix, package, only_in_packages = stack.pop(0)
119 a712571b Christos Stavrakakis
        for name in os.listdir(where):
120 a712571b Christos Stavrakakis
            fn = os.path.join(where, name)
121 a712571b Christos Stavrakakis
            if os.path.isdir(fn):
122 a712571b Christos Stavrakakis
                bad_name = False
123 a712571b Christos Stavrakakis
                for pattern in exclude_directories:
124 a712571b Christos Stavrakakis
                    if (fnmatchcase(name, pattern)
125 a712571b Christos Stavrakakis
                        or fn.lower() == pattern.lower()):
126 a712571b Christos Stavrakakis
                        bad_name = True
127 a712571b Christos Stavrakakis
                        if show_ignored:
128 a712571b Christos Stavrakakis
                            print >> sys.stderr, (
129 a712571b Christos Stavrakakis
                                "Directory %s ignored by pattern %s"
130 a712571b Christos Stavrakakis
                                % (fn, pattern))
131 a712571b Christos Stavrakakis
                        break
132 a712571b Christos Stavrakakis
                if bad_name:
133 a712571b Christos Stavrakakis
                    continue
134 a712571b Christos Stavrakakis
                if (os.path.isfile(os.path.join(fn, "__init__.py"))
135 a712571b Christos Stavrakakis
                    and not prefix):
136 a712571b Christos Stavrakakis
                    if not package:
137 a712571b Christos Stavrakakis
                        new_package = name
138 a712571b Christos Stavrakakis
                    else:
139 a712571b Christos Stavrakakis
                        new_package = package + "." + name
140 a712571b Christos Stavrakakis
                    stack.append((fn, "", new_package, False))
141 a712571b Christos Stavrakakis
                else:
142 a712571b Christos Stavrakakis
                    stack.append((fn, prefix + name + "/", package, only_in_packages))
143 a712571b Christos Stavrakakis
            elif package or not only_in_packages:
144 a712571b Christos Stavrakakis
                # is a file
145 a712571b Christos Stavrakakis
                bad_name = False
146 a712571b Christos Stavrakakis
                for pattern in exclude:
147 a712571b Christos Stavrakakis
                    if (fnmatchcase(name, pattern)
148 a712571b Christos Stavrakakis
                        or fn.lower() == pattern.lower()):
149 a712571b Christos Stavrakakis
                        bad_name = True
150 a712571b Christos Stavrakakis
                        if show_ignored:
151 a712571b Christos Stavrakakis
                            print >> sys.stderr, (
152 a712571b Christos Stavrakakis
                                "File %s ignored by pattern %s"
153 a712571b Christos Stavrakakis
                                % (fn, pattern))
154 a712571b Christos Stavrakakis
                        break
155 a712571b Christos Stavrakakis
                if bad_name:
156 a712571b Christos Stavrakakis
                    continue
157 a712571b Christos Stavrakakis
                out.setdefault(package, []).append(prefix+name)
158 a712571b Christos Stavrakakis
    return out
159 a712571b Christos Stavrakakis
160 a712571b Christos Stavrakakis
setup(
161 a712571b Christos Stavrakakis
    name='snf-django-lib',
162 a712571b Christos Stavrakakis
    version=VERSION,
163 a712571b Christos Stavrakakis
    license='BSD',
164 a712571b Christos Stavrakakis
    url='http://www.synnefo.org/',
165 a712571b Christos Stavrakakis
    description=SHORT_DESCRIPTION,
166 a712571b Christos Stavrakakis
    classifiers=CLASSIFIERS,
167 a712571b Christos Stavrakakis
168 a712571b Christos Stavrakakis
    author='Synnefo development team',
169 a712571b Christos Stavrakakis
    author_email='synnefo-devel@googlegroups.com',
170 a712571b Christos Stavrakakis
    maintainer='Synnefo development team',
171 a712571b Christos Stavrakakis
    maintainer_email='synnefo-devel@googlegroups.com',
172 a712571b Christos Stavrakakis
173 a712571b Christos Stavrakakis
    packages=PACKAGES,
174 a712571b Christos Stavrakakis
    package_dir={'': PACKAGES_ROOT},
175 a712571b Christos Stavrakakis
    include_package_data=True,
176 a712571b Christos Stavrakakis
    package_data=find_package_data('.'),
177 a712571b Christos Stavrakakis
    zip_safe=False,
178 a712571b Christos Stavrakakis
179 a712571b Christos Stavrakakis
    install_requires=INSTALL_REQUIRES,
180 a712571b Christos Stavrakakis
    dependency_links=['http://www.synnefo.org/packages/pypi'],
181 a712571b Christos Stavrakakis
    entry_points={},
182 a712571b Christos Stavrakakis
)