root / snf-pithos-web-client / setup.py @ 29c75250
History | View | Annotate | Download (9.8 kB)
1 | f9fee161 | Antony Chazapis | #!/usr/bin/env python
|
---|---|---|---|
2 | f9fee161 | Antony Chazapis | |
3 | f9fee161 | Antony Chazapis | # Copyright 2011-2012 GRNET S.A. All rights reserved.
|
4 | f9fee161 | Antony Chazapis | #
|
5 | f9fee161 | Antony Chazapis | # Redistribution and use in source and binary forms, with or
|
6 | f9fee161 | Antony Chazapis | # without modification, are permitted provided that the following
|
7 | f9fee161 | Antony Chazapis | # conditions are met:
|
8 | f9fee161 | Antony Chazapis | #
|
9 | f9fee161 | Antony Chazapis | # 1. Redistributions of source code must retain the above
|
10 | f9fee161 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
11 | f9fee161 | Antony Chazapis | # disclaimer.
|
12 | f9fee161 | Antony Chazapis | #
|
13 | f9fee161 | Antony Chazapis | # 2. Redistributions in binary form must reproduce the above
|
14 | f9fee161 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
15 | f9fee161 | Antony Chazapis | # disclaimer in the documentation and/or other materials
|
16 | f9fee161 | Antony Chazapis | # provided with the distribution.
|
17 | f9fee161 | Antony Chazapis | #
|
18 | f9fee161 | Antony Chazapis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
19 | f9fee161 | Antony Chazapis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20 | f9fee161 | Antony Chazapis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21 | f9fee161 | Antony Chazapis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
22 | f9fee161 | Antony Chazapis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23 | f9fee161 | Antony Chazapis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24 | f9fee161 | Antony Chazapis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
25 | f9fee161 | Antony Chazapis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
26 | f9fee161 | Antony Chazapis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27 | f9fee161 | Antony Chazapis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
28 | f9fee161 | Antony Chazapis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 | f9fee161 | Antony Chazapis | # POSSIBILITY OF SUCH DAMAGE.
|
30 | f9fee161 | Antony Chazapis | #
|
31 | f9fee161 | Antony Chazapis | # The views and conclusions contained in the software and
|
32 | f9fee161 | Antony Chazapis | # documentation are those of the authors and should not be
|
33 | f9fee161 | Antony Chazapis | # interpreted as representing official policies, either expressed
|
34 | f9fee161 | Antony Chazapis | # or implied, of GRNET S.A.
|
35 | f9fee161 | Antony Chazapis | import distribute_setup |
36 | f9fee161 | Antony Chazapis | distribute_setup.use_setuptools() |
37 | f9fee161 | Antony Chazapis | |
38 | f9fee161 | Antony Chazapis | import os |
39 | f9fee161 | Antony Chazapis | import sys |
40 | f9fee161 | Antony Chazapis | |
41 | f9fee161 | Antony Chazapis | from fnmatch import fnmatchcase |
42 | f9fee161 | Antony Chazapis | from distutils.util import convert_path |
43 | f9fee161 | Antony Chazapis | |
44 | f9fee161 | Antony Chazapis | from setuptools import setup, find_packages |
45 | f9fee161 | Antony Chazapis | |
46 | f9fee161 | Antony Chazapis | |
47 | f9fee161 | Antony Chazapis | HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__))) |
48 | f9fee161 | Antony Chazapis | try:
|
49 | f9fee161 | Antony Chazapis | # try to update the version file
|
50 | f9fee161 | Antony Chazapis | from synnefo.util import version |
51 | f9fee161 | Antony Chazapis | version.update_version('pithos_web_client', 'version', HERE) |
52 | f9fee161 | Antony Chazapis | except ImportError: |
53 | f9fee161 | Antony Chazapis | pass
|
54 | f9fee161 | Antony Chazapis | |
55 | f9fee161 | Antony Chazapis | from pithos_web_client.version import __version__ |
56 | f9fee161 | Antony Chazapis | |
57 | f9fee161 | Antony Chazapis | # Package info
|
58 | f9fee161 | Antony Chazapis | VERSION = __version__ |
59 | f9fee161 | Antony Chazapis | README = open(os.path.join(HERE, 'README')).read() |
60 | f9fee161 | Antony Chazapis | CHANGES = open(os.path.join(HERE, 'Changelog')).read() |
61 | f9fee161 | Antony Chazapis | SHORT_DESCRIPTION = 'Package short description'
|
62 | f9fee161 | Antony Chazapis | |
63 | f9fee161 | Antony Chazapis | PACKAGES_ROOT = '.'
|
64 | f9fee161 | Antony Chazapis | PACKAGES = find_packages(PACKAGES_ROOT) |
65 | f9fee161 | Antony Chazapis | |
66 | f9fee161 | Antony Chazapis | # Package meta
|
67 | f9fee161 | Antony Chazapis | CLASSIFIERS = [ |
68 | f9fee161 | Antony Chazapis | 'Development Status :: 3 - Alpha',
|
69 | f9fee161 | Antony Chazapis | 'Operating System :: OS Independent',
|
70 | f9fee161 | Antony Chazapis | 'Programming Language :: Python',
|
71 | f9fee161 | Antony Chazapis | 'Topic :: Utilities',
|
72 | f9fee161 | Antony Chazapis | 'License :: OSI Approved :: BSD License',
|
73 | f9fee161 | Antony Chazapis | ] |
74 | f9fee161 | Antony Chazapis | |
75 | f9fee161 | Antony Chazapis | # Package requirements
|
76 | f9fee161 | Antony Chazapis | INSTALL_REQUIRES = [ |
77 | f9fee161 | Antony Chazapis | 'Django>=1.2, <1.3',
|
78 | f9fee161 | Antony Chazapis | 'snf-common>=0.9.0rc'
|
79 | f9fee161 | Antony Chazapis | ] |
80 | f9fee161 | Antony Chazapis | |
81 | f9fee161 | Antony Chazapis | EXTRAS_REQUIRES = { |
82 | f9fee161 | Antony Chazapis | } |
83 | f9fee161 | Antony Chazapis | |
84 | f9fee161 | Antony Chazapis | TESTS_REQUIRES = [ |
85 | f9fee161 | Antony Chazapis | ] |
86 | f9fee161 | Antony Chazapis | |
87 | f9fee161 | Antony Chazapis | # Provided as an attribute, so you can append to these instead
|
88 | f9fee161 | Antony Chazapis | # of replicating them:
|
89 | f9fee161 | Antony Chazapis | standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"] |
90 | f9fee161 | Antony Chazapis | standard_exclude_directories = [ |
91 | f9fee161 | Antony Chazapis | ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7" |
92 | f9fee161 | Antony Chazapis | ] |
93 | f9fee161 | Antony Chazapis | |
94 | f9fee161 | Antony Chazapis | # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
|
95 | f9fee161 | Antony Chazapis | # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
96 | f9fee161 | Antony Chazapis | # Note: you may want to copy this into your setup.py file verbatim, as
|
97 | f9fee161 | Antony Chazapis | # you can't import this from another package, when you don't know if
|
98 | f9fee161 | Antony Chazapis | # that package is installed yet.
|
99 | f9fee161 | Antony Chazapis | def find_package_data( |
100 | f9fee161 | Antony Chazapis | where=".",
|
101 | f9fee161 | Antony Chazapis | package="",
|
102 | f9fee161 | Antony Chazapis | exclude=standard_exclude, |
103 | f9fee161 | Antony Chazapis | exclude_directories=standard_exclude_directories, |
104 | f9fee161 | Antony Chazapis | only_in_packages=True,
|
105 | f9fee161 | Antony Chazapis | show_ignored=False):
|
106 | f9fee161 | Antony Chazapis | """
|
107 | f9fee161 | Antony Chazapis | Return a dictionary suitable for use in ``package_data``
|
108 | f9fee161 | Antony Chazapis | in a distutils ``setup.py`` file.
|
109 | f9fee161 | Antony Chazapis |
|
110 | f9fee161 | Antony Chazapis | The dictionary looks like::
|
111 | f9fee161 | Antony Chazapis |
|
112 | f9fee161 | Antony Chazapis | {"package": [files]}
|
113 | f9fee161 | Antony Chazapis |
|
114 | f9fee161 | Antony Chazapis | Where ``files`` is a list of all the files in that package that
|
115 | f9fee161 | Antony Chazapis | don"t match anything in ``exclude``.
|
116 | f9fee161 | Antony Chazapis |
|
117 | f9fee161 | Antony Chazapis | If ``only_in_packages`` is true, then top-level directories that
|
118 | f9fee161 | Antony Chazapis | are not packages won"t be included (but directories under packages
|
119 | f9fee161 | Antony Chazapis | will).
|
120 | f9fee161 | Antony Chazapis |
|
121 | f9fee161 | Antony Chazapis | Directories matching any pattern in ``exclude_directories`` will
|
122 | f9fee161 | Antony Chazapis | be ignored; by default directories with leading ``.``, ``CVS``,
|
123 | f9fee161 | Antony Chazapis | and ``_darcs`` will be ignored.
|
124 | f9fee161 | Antony Chazapis |
|
125 | f9fee161 | Antony Chazapis | If ``show_ignored`` is true, then all the files that aren"t
|
126 | f9fee161 | Antony Chazapis | included in package data are shown on stderr (for debugging
|
127 | f9fee161 | Antony Chazapis | purposes).
|
128 | f9fee161 | Antony Chazapis |
|
129 | f9fee161 | Antony Chazapis | Note patterns use wildcards, or can be exact paths (including
|
130 | f9fee161 | Antony Chazapis | leading ``./``), and all searching is case-insensitive.
|
131 | f9fee161 | Antony Chazapis | """
|
132 | f9fee161 | Antony Chazapis | out = {} |
133 | f9fee161 | Antony Chazapis | stack = [(convert_path(where), "", package, only_in_packages)]
|
134 | f9fee161 | Antony Chazapis | while stack:
|
135 | f9fee161 | Antony Chazapis | where, prefix, package, only_in_packages = stack.pop(0)
|
136 | f9fee161 | Antony Chazapis | for name in os.listdir(where): |
137 | f9fee161 | Antony Chazapis | fn = os.path.join(where, name) |
138 | f9fee161 | Antony Chazapis | if os.path.isdir(fn):
|
139 | f9fee161 | Antony Chazapis | bad_name = False
|
140 | f9fee161 | Antony Chazapis | for pattern in exclude_directories: |
141 | f9fee161 | Antony Chazapis | if (fnmatchcase(name, pattern)
|
142 | f9fee161 | Antony Chazapis | or fn.lower() == pattern.lower()):
|
143 | f9fee161 | Antony Chazapis | bad_name = True
|
144 | f9fee161 | Antony Chazapis | if show_ignored:
|
145 | f9fee161 | Antony Chazapis | print >> sys.stderr, (
|
146 | f9fee161 | Antony Chazapis | "Directory %s ignored by pattern %s"
|
147 | f9fee161 | Antony Chazapis | % (fn, pattern)) |
148 | f9fee161 | Antony Chazapis | break
|
149 | f9fee161 | Antony Chazapis | if bad_name:
|
150 | f9fee161 | Antony Chazapis | continue
|
151 | f9fee161 | Antony Chazapis | if (os.path.isfile(os.path.join(fn, "__init__.py")) |
152 | f9fee161 | Antony Chazapis | and not prefix): |
153 | f9fee161 | Antony Chazapis | if not package: |
154 | f9fee161 | Antony Chazapis | new_package = name |
155 | f9fee161 | Antony Chazapis | else:
|
156 | f9fee161 | Antony Chazapis | new_package = package + "." + name
|
157 | f9fee161 | Antony Chazapis | stack.append((fn, "", new_package, False)) |
158 | f9fee161 | Antony Chazapis | else:
|
159 | f9fee161 | Antony Chazapis | stack.append((fn, prefix + name + "/", package, only_in_packages))
|
160 | f9fee161 | Antony Chazapis | elif package or not only_in_packages: |
161 | f9fee161 | Antony Chazapis | # is a file
|
162 | f9fee161 | Antony Chazapis | bad_name = False
|
163 | f9fee161 | Antony Chazapis | for pattern in exclude: |
164 | f9fee161 | Antony Chazapis | if (fnmatchcase(name, pattern)
|
165 | f9fee161 | Antony Chazapis | or fn.lower() == pattern.lower()):
|
166 | f9fee161 | Antony Chazapis | bad_name = True
|
167 | f9fee161 | Antony Chazapis | if show_ignored:
|
168 | f9fee161 | Antony Chazapis | print >> sys.stderr, (
|
169 | f9fee161 | Antony Chazapis | "File %s ignored by pattern %s"
|
170 | f9fee161 | Antony Chazapis | % (fn, pattern)) |
171 | f9fee161 | Antony Chazapis | break
|
172 | f9fee161 | Antony Chazapis | if bad_name:
|
173 | f9fee161 | Antony Chazapis | continue
|
174 | f9fee161 | Antony Chazapis | out.setdefault(package, []).append(prefix+name) |
175 | f9fee161 | Antony Chazapis | return out
|
176 | f9fee161 | Antony Chazapis | |
177 | a577f110 | Kostas Papadimitriou | |
178 | a577f110 | Kostas Papadimitriou | """
|
179 | a577f110 | Kostas Papadimitriou | Gwt clea/build helpers
|
180 | a577f110 | Kostas Papadimitriou | """
|
181 | a577f110 | Kostas Papadimitriou | import subprocess as sp |
182 | a577f110 | Kostas Papadimitriou | import glob |
183 | a577f110 | Kostas Papadimitriou | |
184 | a577f110 | Kostas Papadimitriou | def clean_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"): |
185 | 29c75250 | Kostas Papadimitriou | # skip if no build.xml found (debian build process)
|
186 | 29c75250 | Kostas Papadimitriou | if not os.path.exists(os.path.join(root, "build.xml")): |
187 | 29c75250 | Kostas Papadimitriou | return
|
188 | 29c75250 | Kostas Papadimitriou | |
189 | a577f110 | Kostas Papadimitriou | curdir = os.getcwd() |
190 | a577f110 | Kostas Papadimitriou | os.chdir(root) |
191 | a577f110 | Kostas Papadimitriou | rcode = sp.call(["ant", "clean"]) |
192 | a577f110 | Kostas Papadimitriou | if rcode == 1: |
193 | a577f110 | Kostas Papadimitriou | raise Exception("GWT clean failed") |
194 | a577f110 | Kostas Papadimitriou | os.chdir(curdir) |
195 | a577f110 | Kostas Papadimitriou | pub_dir = os.path.abspath(os.path.join(root, public_dir)) |
196 | a577f110 | Kostas Papadimitriou | static_dir = os.path.abspath(os.path.join("pithos_web_client", "static", \ |
197 | a577f110 | Kostas Papadimitriou | "pithos_web_client"))
|
198 | a577f110 | Kostas Papadimitriou | templates_dir = os.path.abspath(os.path.join("pithos_web_client", \
|
199 | a577f110 | Kostas Papadimitriou | "templates", "pithos_web_client")) |
200 | a577f110 | Kostas Papadimitriou | clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*")) |
201 | a577f110 | Kostas Papadimitriou | clean_templates = ["rm", "-r"] + glob.glob(os.path.join(templates_dir, "*")) |
202 | a577f110 | Kostas Papadimitriou | |
203 | a577f110 | Kostas Papadimitriou | # clean dirs
|
204 | a577f110 | Kostas Papadimitriou | if len(clean_static) > 2: |
205 | a577f110 | Kostas Papadimitriou | sp.call(clean_static) |
206 | a577f110 | Kostas Papadimitriou | if len(clean_static) > 2: |
207 | a577f110 | Kostas Papadimitriou | sp.call(clean_templates) |
208 | a577f110 | Kostas Papadimitriou | |
209 | a577f110 | Kostas Papadimitriou | |
210 | a577f110 | Kostas Papadimitriou | def build_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"): |
211 | 29c75250 | Kostas Papadimitriou | # skip if no build.xml found (debian build process)
|
212 | 29c75250 | Kostas Papadimitriou | if not os.path.exists(os.path.join(root, "build.xml")): |
213 | 29c75250 | Kostas Papadimitriou | return
|
214 | 29c75250 | Kostas Papadimitriou | |
215 | a577f110 | Kostas Papadimitriou | curdir = os.getcwd() |
216 | a577f110 | Kostas Papadimitriou | os.chdir(root) |
217 | a577f110 | Kostas Papadimitriou | # run ant on root dir
|
218 | a577f110 | Kostas Papadimitriou | rcode = sp.call(["ant"])
|
219 | a577f110 | Kostas Papadimitriou | if rcode == 1: |
220 | a577f110 | Kostas Papadimitriou | raise Exception("GWT build failed") |
221 | a577f110 | Kostas Papadimitriou | os.chdir(curdir) |
222 | a577f110 | Kostas Papadimitriou | |
223 | a577f110 | Kostas Papadimitriou | |
224 | a577f110 | Kostas Papadimitriou | pub_dir = os.path.abspath(os.path.join(root, public_dir)) |
225 | a577f110 | Kostas Papadimitriou | static_dir = os.path.abspath(os.path.join("pithos_web_client", "static", \ |
226 | a577f110 | Kostas Papadimitriou | "pithos_web_client"))
|
227 | a577f110 | Kostas Papadimitriou | templates_dir = os.path.abspath(os.path.join("pithos_web_client", \
|
228 | a577f110 | Kostas Papadimitriou | "templates", "pithos_web_client")) |
229 | a577f110 | Kostas Papadimitriou | |
230 | a577f110 | Kostas Papadimitriou | clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*")) |
231 | a577f110 | Kostas Papadimitriou | clean_templates = ["rm", "-r"] + glob.glob(os.path.join(templates_dir, "*")) |
232 | a577f110 | Kostas Papadimitriou | |
233 | a577f110 | Kostas Papadimitriou | # clean dirs
|
234 | a577f110 | Kostas Papadimitriou | if len(clean_static) > 2: |
235 | a577f110 | Kostas Papadimitriou | sp.call(clean_static) |
236 | a577f110 | Kostas Papadimitriou | if len(clean_static) > 2: |
237 | a577f110 | Kostas Papadimitriou | sp.call(clean_templates) |
238 | a577f110 | Kostas Papadimitriou | |
239 | a577f110 | Kostas Papadimitriou | copy_static = ["cp", "-r"] + glob.glob(os.path.join(pub_dir, "*")) + [static_dir] |
240 | a577f110 | Kostas Papadimitriou | copy_index = ["cp", os.path.join(pub_dir, "index.html"), templates_dir] |
241 | a577f110 | Kostas Papadimitriou | sp.call(copy_static) |
242 | a577f110 | Kostas Papadimitriou | sp.call(copy_index) |
243 | a577f110 | Kostas Papadimitriou | |
244 | a577f110 | Kostas Papadimitriou | index = os.path.join(templates_dir, "index.html")
|
245 | a577f110 | Kostas Papadimitriou | index_data = file(index).read()
|
246 | a577f110 | Kostas Papadimitriou | index_data = index_data.replace('href="', 'href="{{ MEDIA_URL }}pithos_web_client/') |
247 | a577f110 | Kostas Papadimitriou | index_data = index_data.replace('" src="', '" src="{{ MEDIA_URL }}pithos_web_client/') |
248 | a577f110 | Kostas Papadimitriou | index_data = index_data.replace('\' src=\'', '" src="{{ MEDIA_URL }}pithos_web_client/') |
249 | a577f110 | Kostas Papadimitriou | index_data = index_data.replace('url(', 'url({{ MEDIA_URL }}pithos_web_client/') |
250 | a577f110 | Kostas Papadimitriou | |
251 | a577f110 | Kostas Papadimitriou | ifile = file(index, "w+") |
252 | a577f110 | Kostas Papadimitriou | ifile.write(index_data) |
253 | a577f110 | Kostas Papadimitriou | ifile.close() |
254 | a577f110 | Kostas Papadimitriou | |
255 | a577f110 | Kostas Papadimitriou | |
256 | a577f110 | Kostas Papadimitriou | # do we need to run ant ???
|
257 | a577f110 | Kostas Papadimitriou | if any(x in ''.join(sys.argv) for x in ["sdist", "build"]): |
258 | a577f110 | Kostas Papadimitriou | build_gwt() |
259 | a577f110 | Kostas Papadimitriou | |
260 | a577f110 | Kostas Papadimitriou | if any(x in ''.join(sys.argv) for x in ["clean"]): |
261 | a577f110 | Kostas Papadimitriou | clean_gwt() |
262 | a577f110 | Kostas Papadimitriou | |
263 | a577f110 | Kostas Papadimitriou | |
264 | f9fee161 | Antony Chazapis | setup( |
265 | f9fee161 | Antony Chazapis | name='snf-pithos-web-client',
|
266 | f9fee161 | Antony Chazapis | version=VERSION, |
267 | f9fee161 | Antony Chazapis | license='BSD',
|
268 | f9fee161 | Antony Chazapis | url='http://code.grnet.gr/projects/pithos-web-client',
|
269 | f9fee161 | Antony Chazapis | description = SHORT_DESCRIPTION, |
270 | f9fee161 | Antony Chazapis | long_description=README + '\n\n' + CHANGES,
|
271 | f9fee161 | Antony Chazapis | classifiers = CLASSIFIERS, |
272 | f9fee161 | Antony Chazapis | author='GRNET',
|
273 | f9fee161 | Antony Chazapis | author_email='pithos@grnet.gr',
|
274 | f9fee161 | Antony Chazapis | |
275 | f9fee161 | Antony Chazapis | packages=find_packages(), |
276 | f9fee161 | Antony Chazapis | include_package_data=True,
|
277 | f9fee161 | Antony Chazapis | package_data=find_package_data('.'),
|
278 | f9fee161 | Antony Chazapis | zip_safe=False,
|
279 | f9fee161 | Antony Chazapis | |
280 | f9fee161 | Antony Chazapis | install_requires = INSTALL_REQUIRES, |
281 | f9fee161 | Antony Chazapis | |
282 | f9fee161 | Antony Chazapis | dependency_links = ['http://docs.dev.grnet.gr/pypi'],
|
283 | f9fee161 | Antony Chazapis | |
284 | f9fee161 | Antony Chazapis | entry_points={ |
285 | f9fee161 | Antony Chazapis | 'synnefo': [
|
286 | f9fee161 | Antony Chazapis | 'web_apps = pithos_web_client.synnefo_settings:installed_apps',
|
287 | a577f110 | Kostas Papadimitriou | 'urls = pithos_web_client.synnefo_settings:urlpatterns',
|
288 | f9fee161 | Antony Chazapis | 'web_static = pithos_web_client.synnefo_settings:static_files'
|
289 | f9fee161 | Antony Chazapis | ] |
290 | f9fee161 | Antony Chazapis | } |
291 | f9fee161 | Antony Chazapis | ) |