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