3 # Copyright 2011-2012 GRNET S.A. All rights reserved.
5 # Redistribution and use in source and binary forms, with or
6 # without modification, are permitted provided that the following
9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following
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.
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.
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.
36 import distribute_setup
37 distribute_setup.use_setuptools()
42 from fnmatch import fnmatchcase
43 from distutils.util import convert_path
45 from setuptools import setup, find_packages
48 HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
50 from pithos_webclient.version import __version__
54 README = open(os.path.join(HERE, 'README')).read()
55 CHANGES = open(os.path.join(HERE, 'Changelog')).read()
56 SHORT_DESCRIPTION = 'Package short description'
59 PACKAGES = find_packages(PACKAGES_ROOT)
63 'Development Status :: 3 - Alpha',
64 'Operating System :: OS Independent',
65 'Programming Language :: Python',
67 'License :: OSI Approved :: BSD License',
70 # Package requirements
83 # Provided as an attribute, so you can append to these instead
84 # of replicating them:
85 standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"]
86 standard_exclude_directories = [
87 ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info",
92 # (c) 2005 Ian Bicking and contributors; written for Paste
93 # (http://pythonpaste.org) Licensed under the MIT license:
94 # http://www.opensource.org/licenses/mit-license.php Note: you may want to
95 # copy this into your setup.py file verbatim, as you can't import this from
96 # another package, when you don't know if that package is installed yet.
97 def find_package_data(
100 exclude=standard_exclude,
101 exclude_directories=standard_exclude_directories,
102 only_in_packages=True,
106 Return a dictionary suitable for use in ``package_data``
107 in a distutils ``setup.py`` file.
109 The dictionary looks like::
113 Where ``files`` is a list of all the files in that package that
114 don"t match anything in ``exclude``.
116 If ``only_in_packages`` is true, then top-level directories that
117 are not packages won"t be included (but directories under packages
120 Directories matching any pattern in ``exclude_directories`` will
121 be ignored; by default directories with leading ``.``, ``CVS``,
122 and ``_darcs`` will be ignored.
124 If ``show_ignored`` is true, then all the files that aren"t
125 included in package data are shown on stderr (for debugging
128 Note patterns use wildcards, or can be exact paths (including
129 leading ``./``), and all searching is case-insensitive.
132 stack = [(convert_path(where), "", package, only_in_packages)]
134 where, prefix, package, only_in_packages = stack.pop(0)
135 for name in os.listdir(where):
136 fn = os.path.join(where, name)
137 if os.path.isdir(fn):
139 for pattern in exclude_directories:
140 if (fnmatchcase(name, pattern)
141 or fn.lower() == pattern.lower()):
144 print >> sys.stderr, (
145 "Directory %s ignored by pattern %s"
150 if (os.path.isfile(os.path.join(fn, "__init__.py"))
155 new_package = package + "." + name
156 stack.append((fn, "", new_package, False))
158 stack.append((fn, prefix + name + "/", package,
160 elif package or not only_in_packages:
163 for pattern in exclude:
164 if (fnmatchcase(name, pattern) or
165 fn.lower() == pattern.lower()):
168 print >> sys.stderr, (
169 "File %s ignored by pattern %s"
174 out.setdefault(package, []).append(prefix + name)
179 Gwt clea/build helpers
181 import subprocess as sp
185 def clean_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"):
186 # skip if no build.xml found (debian build process)
187 if not os.path.exists(os.path.join(root, "build.xml")):
192 rcode = sp.call(["ant", "clean"])
194 raise Exception("GWT clean failed")
196 #pub_dir = os.path.abspath(os.path.join(root, public_dir))
197 static_dir = os.path.abspath(os.path.join("pithos_webclient", "static",
199 #templates_dir = os.path.abspath(os.path.join("pithos_webclient",
201 #"pithos_webclient"))
202 clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*"))
205 if len(clean_static) > 2:
206 sp.call(clean_static)
209 def build_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"):
210 # skip if no build.xml found (debian build process)
211 if not os.path.exists(os.path.join(root, "build.xml")):
216 # run ant on root dir
217 rcode = sp.call(["ant"])
219 raise Exception("GWT build failed")
222 pub_dir = os.path.abspath(os.path.join(root, public_dir))
223 static_dir = os.path.abspath(os.path.join("pithos_webclient", "static",
225 templates_dir = os.path.abspath(os.path.join("pithos_webclient",
229 clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*"))
232 if len(clean_static) > 2:
233 sp.call(clean_static)
235 copy_static = ["cp", "-r"] + glob.glob(os.path.join(pub_dir, "*")) + \
237 copy_index = ["cp", os.path.join(pub_dir, "index.html"), templates_dir]
241 index = os.path.join(templates_dir, "index.html")
242 index_data = file(index).read()
243 # fix locations of static files
244 index_data = index_data.replace('href="',
245 'href="{{ MEDIA_URL }}pithos_webclient/')
246 index_data = index_data.replace('" src="',
247 '" src="{{ MEDIA_URL }}pithos_webclient/')
248 index_data = index_data.replace(
250 '\' src=\'{{ MEDIA_URL }}pithos_webclient/')
251 index_data = index_data.replace('url(',
252 'url({{ MEDIA_URL }}pithos_webclient/')
254 ifile = file(index, "w+")
255 ifile.write(index_data)
259 # do we need to run ant ???
260 if any(x in ''.join(sys.argv) for x in ["sdist", "build", "develop",
264 if any(x in ''.join(sys.argv) for x in ["clean"]):
269 name='snf-pithos-webclient',
272 url='http://code.grnet.gr/projects/pithos-web-client',
273 description=SHORT_DESCRIPTION,
274 long_description=README + '\n\n' + CHANGES,
275 classifiers=CLASSIFIERS,
277 author_email='pithos@grnet.gr',
279 packages=find_packages(),
280 include_package_data=True,
281 package_data=find_package_data('.'),
284 install_requires=INSTALL_REQUIRES,
286 dependency_links=['http://docs.dev.grnet.gr/pypi'],
290 'web_apps = pithos_webclient.synnefo_settings:installed_apps',
291 'urls = pithos_webclient.synnefo_settings:urlpatterns',
292 'web_static = pithos_webclient.synnefo_settings:static_files',
293 'web_context_processors = '
294 'pithos_webclient.synnefo_settings:context_processors'