import os
from distutils.core import setup
+RESOURCE_PATHS = ('templates', 'static', 'media', 'locale', 'config')
+
+
def is_package(path):
- return (
- os.path.isdir(path) and
- os.path.isfile(os.path.join(path, '__init__.py'))
- )
+ return os.path.isdir(path) \
+ and os.path.isfile(os.path.join(path, '__init__.py'))
-def find_packages(path, base="" ):
+
+def find_packages(path, base=""):
""" Find all packages in path """
packages = {}
for item in os.listdir(path):
dir = os.path.join(path, item)
- if is_package( dir ):
+ if is_package(dir):
if base:
module_name = "%(base)s.%(item)s" % vars()
else:
packages.update(find_packages(dir, module_name))
return packages
+
def files_from(*paths, **kwargs):
- base = kwargs.pop('base')
+ base = kwargs.pop('base')
+
def generator():
for path in paths:
- path = os.path.join(base, path)
- if not os.path.isdir(path) or is_package(path): continue
-
- for dir, _, files in os.walk(path):
- for file in files:
- yield os.path.relpath(os.path.join(dir, file),base)
-
+ path = os.path.join(base, path)
+ if not os.path.isdir(path) or is_package(path):
+ continue
+
+ for dir, _, files in os.walk(path):
+ for file in files:
+ yield os.path.relpath(os.path.join(dir, file), base)
+
return list(generator())
-RESOURCE_PATHS = ('templates', 'static', 'media', 'locale', 'config')
-def django_setup(project, apps=[], apps_dir='apps', package_dir = {}, packages = [], package_data = {}, **kwargs):
-
+def django_setup(project, apps=[], apps_dir='apps', package_dir={}, packages=[], package_data={}, **kwargs):
+
# directories
- extra_dirs = dict( (app, os.path.join(apps_dir,app)) for app in apps )
+ extra_dirs = dict((app, os.path.join(apps_dir, app)) for app in apps)
extra_dirs[project] = project
package_dir.update(extra_dirs)
-
+
# applications
packages.extend(apps)
- # with all subpackages
+ # with all subpackages
for app in apps:
packages.extend(find_packages(os.path.join(apps_dir, app), base=app))
# and the project
packages.append(project)
-
- # extra data
+
+ # extra data
extra_data = {}
for app in apps:
- extra_data[app] = files_from(*RESOURCE_PATHS, base=os.path.join(apps_dir, app))
+ extra_data[app] = files_from(*RESOURCE_PATHS, base=os.path.join(apps_dir, app))
extra_data[project] = files_from(*RESOURCE_PATHS, base=project)
- package_data.update(extra_data)
-
+ package_data.update(extra_data)
+
return setup(
- package_dir = package_dir,
- packages = packages,
- package_data = package_data, **kwargs)
-
+ package_dir=package_dir,
+ packages=packages,
+ package_data=package_data, **kwargs)
+
+
#
-# The reald stuff :)
+# The real stuff :)
#
django_setup(
name='fnp-redakcja',
author="Fundacja Nowoczesna Polska",
author_email='fundacja@nowoczesnapolska.org.pl',
license="GNU Affero General Public License 3",
- maintainer='Łukasz Rekucki',
+ maintainer='Łukasz Rekucki',
maintainer_email='lrekucki@gmail.com',
url='http://github.com/fnp/redakcja',
- package_dir = {'': 'lib'},
- py_modules = [
+ package_dir={'': 'lib'},
+ py_modules=[
'wlapi',
- 'vstorage',
- ],
+ 'vstorage',
+ ],
scripts=[
- 'scripts/crop.py',
+ 'scripts/crop.py',
'scripts/imgconv.py',
- ],
+ ],
# django applications
- project = 'platforma',
- apps_dir = 'apps',
- apps = [
+ project='platforma',
+ apps_dir='apps',
+ apps=[
'compress',
- 'django_cas',
+ 'django_cas',
'filebrowser',
'toolbar',
- 'wiki',
+ 'wiki',
],
- requires = [
+ requires=[
"librarian (>=1.3)",
- "Django (>=1.1.1,<1.2)",
- ]
- # data_files=[ ('', ['LICENSE', 'NOTICE', 'README.rst', 'AUTHORS.md', 'requirements.txt'])],
-)
+ "Django (>=1.1.1,<1.2)",
+ ])