Distutils installation script.
authorŁukasz Rekucki <lrekucki@gmail.com>
Sun, 28 Mar 2010 18:28:11 +0000 (20:28 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Sun, 28 Mar 2010 18:28:11 +0000 (20:28 +0200)
15 files changed:
fabfile.py
lib/run_tests.sh [deleted file]
platforma.vhost.template [deleted file]
platforma.wsgi.template [deleted file]
platforma/config/localsettings.sample [new file with mode: 0644]
platforma/config/logging.cfg [new file with mode: 0644]
platforma/config/logging.cfg.dev [new file with mode: 0644]
platforma/config/platforma.vhost.template [new file with mode: 0644]
platforma/config/platforma.wsgi.template [new file with mode: 0644]
platforma/config/requirements.txt [new file with mode: 0644]
platforma/localsettings.sample [deleted file]
platforma/logging.cfg [deleted file]
platforma/logging.cfg.dev [deleted file]
requirements.txt [deleted file]
setup.py [new file with mode: 0644]

index eba8f1f..724fca2 100644 (file)
@@ -10,7 +10,7 @@ import os
 # ==========
 # Globals
 env.project_name = 'platforma'
-env.use_south = False
+env.use_south = True
 
 # Servers
 def staging():
@@ -24,10 +24,10 @@ def staging():
 
 def production():
     """Use production server"""
-    env.hosts = ['wolnelektury.pl:22123']
-    env.user = 'fundacja'
+    env.hosts = ['szo.nowoczesnapolska.org.pl:2225']
+    env.user = 'librarian'
     env.path = '/opt/lektury/platforma'
-    env.python = '/opt/lektury/basevirtualenv/bin/python'
+    env.python = '/srv/library-in-a-box/sandbox/env/redakcja/bin/python'
     env.virtualenv = '/opt/lektury/basevirtualenv/bin/virtualenv'
     env.pip = '/opt/lektury/basevirtualenv/bin/pip'
 
diff --git a/lib/run_tests.sh b/lib/run_tests.sh
deleted file mode 100644 (file)
index 03da16f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-nosetests -v --with-doctest --with-coverage --cover-package=vstorage --detailed-errors
diff --git a/platforma.vhost.template b/platforma.vhost.template
deleted file mode 100644 (file)
index 7d44557..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<VirtualHost *:80>
-    ServerName %(project_name)s.example.com
-    ServerAdmin admin@example.com
-
-    WSGIDaemonProcess %(project_name)s user=%(user)s group=%(user)s processes=2 threads=15 display-name=%%{GROUP} python-path=%(path)s/lib/python2.5/site-packages
-    WSGIProcessGroup %(project_name)s
-
-    WSGIScriptAlias / %(path)s/%(project_name)s.wsgi
-    <Directory %(path)s>
-        Order allow,deny
-        allow from all
-    </Directory>
-
-    Alias /media %(path)s/media
-    <Directory %(path)s/media>
-        Options Indexes
-        Order allow,deny
-        Allow from all
-    </Directory>
-        
-    Alias /admin-media %(path)s/admin-media
-    <Directory %(path)s/admin-media>
-        Options Indexes
-        Order allow,deny
-        Allow from all
-    </Directory>
-
-    Alias /static %(path)s/releases/current/%(project_name)s/static
-    <Directory %(path)s/releases/current/%(project_name)s/static>
-        Options Indexes
-        Order allow,deny
-        Allow from all
-    </Directory>
-
-    LogLevel warn
-    ErrorLog /var/log/apache2/error.log
-    CustomLog /var/log/apache2/access.log combined
-</VirtualHost>
diff --git a/platforma.wsgi.template b/platforma.wsgi.template
deleted file mode 100644 (file)
index 3528fe8..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!%(python)s
-import site
-site.addsitedir('%(path)s/lib/python2.5/site-packages')
-
-import os
-from os.path import abspath, dirname, join
-import sys
-
-# Redirect sys.stdout to sys.stderr for bad libraries like geopy that use
-# print statements for optional import exceptions.
-sys.stdout = sys.stderr
-
-# Add apps and lib directories to PYTHONPATH
-sys.path = [
-       '%(path)s/releases/current',
-       '%(path)s/releases/current/apps',
-       '%(path)s/releases/current/lib',
-] + sys.path
-
-# Run Django
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
-
-from django.core.handlers.wsgi import WSGIHandler
-application = WSGIHandler()
diff --git a/platforma/config/localsettings.sample b/platforma/config/localsettings.sample
new file mode 100644 (file)
index 0000000..c174cf9
--- /dev/null
@@ -0,0 +1,18 @@
+# 
+#  localsettings template for Platforma
+#
+#  Duplicate this file as localsettings.py and change it to your liking.
+#  Settings defined in localsettings.py will override settings from 
+#  settings.py file. localsettings.py should never be commited 
+#  to a version control system. Please make changes to settings.py 
+#  or localsettings.sample instead.
+#
+
+# Path to repository with managed documents
+REPOSITORY_PATH = '/home/user/repository'
+
+# Subdirectory of STATIC_ROOT containing images
+IMAGE_DIR = 'images'
+
+CAS_SERVICE_URL = 'http://stigma.nowoczesnapolska.org.pl/cas/'
+
diff --git a/platforma/config/logging.cfg b/platforma/config/logging.cfg
new file mode 100644 (file)
index 0000000..9bfa56c
--- /dev/null
@@ -0,0 +1,29 @@
+[loggers]
+keys=root,fnp
+
+[handlers]
+keys=console
+
+[formatters]
+keys=default
+
+[logger_root]
+level=DEBUG
+handlers=console
+
+[logger_fnp]
+level=DEBUG
+handlers=console
+qualname=fnp
+propagate=0
+
+[formatter_default]
+format=%(asctime)s %(name)s/%(levelname)s :: %(module)s.%(funcName)s:%(lineno)d :: %(message)s
+datefmt=
+class=logging.Formatter
+
+[handler_console]
+class=StreamHandler
+level=DEBUG
+formatter=default
+args=(sys.stderr, ) 
\ No newline at end of file
diff --git a/platforma/config/logging.cfg.dev b/platforma/config/logging.cfg.dev
new file mode 100644 (file)
index 0000000..9bfa56c
--- /dev/null
@@ -0,0 +1,29 @@
+[loggers]
+keys=root,fnp
+
+[handlers]
+keys=console
+
+[formatters]
+keys=default
+
+[logger_root]
+level=DEBUG
+handlers=console
+
+[logger_fnp]
+level=DEBUG
+handlers=console
+qualname=fnp
+propagate=0
+
+[formatter_default]
+format=%(asctime)s %(name)s/%(levelname)s :: %(module)s.%(funcName)s:%(lineno)d :: %(message)s
+datefmt=
+class=logging.Formatter
+
+[handler_console]
+class=StreamHandler
+level=DEBUG
+formatter=default
+args=(sys.stderr, ) 
\ No newline at end of file
diff --git a/platforma/config/platforma.vhost.template b/platforma/config/platforma.vhost.template
new file mode 100644 (file)
index 0000000..7d44557
--- /dev/null
@@ -0,0 +1,38 @@
+<VirtualHost *:80>
+    ServerName %(project_name)s.example.com
+    ServerAdmin admin@example.com
+
+    WSGIDaemonProcess %(project_name)s user=%(user)s group=%(user)s processes=2 threads=15 display-name=%%{GROUP} python-path=%(path)s/lib/python2.5/site-packages
+    WSGIProcessGroup %(project_name)s
+
+    WSGIScriptAlias / %(path)s/%(project_name)s.wsgi
+    <Directory %(path)s>
+        Order allow,deny
+        allow from all
+    </Directory>
+
+    Alias /media %(path)s/media
+    <Directory %(path)s/media>
+        Options Indexes
+        Order allow,deny
+        Allow from all
+    </Directory>
+        
+    Alias /admin-media %(path)s/admin-media
+    <Directory %(path)s/admin-media>
+        Options Indexes
+        Order allow,deny
+        Allow from all
+    </Directory>
+
+    Alias /static %(path)s/releases/current/%(project_name)s/static
+    <Directory %(path)s/releases/current/%(project_name)s/static>
+        Options Indexes
+        Order allow,deny
+        Allow from all
+    </Directory>
+
+    LogLevel warn
+    ErrorLog /var/log/apache2/error.log
+    CustomLog /var/log/apache2/access.log combined
+</VirtualHost>
diff --git a/platforma/config/platforma.wsgi.template b/platforma/config/platforma.wsgi.template
new file mode 100644 (file)
index 0000000..3528fe8
--- /dev/null
@@ -0,0 +1,24 @@
+#!%(python)s
+import site
+site.addsitedir('%(path)s/lib/python2.5/site-packages')
+
+import os
+from os.path import abspath, dirname, join
+import sys
+
+# Redirect sys.stdout to sys.stderr for bad libraries like geopy that use
+# print statements for optional import exceptions.
+sys.stdout = sys.stderr
+
+# Add apps and lib directories to PYTHONPATH
+sys.path = [
+       '%(path)s/releases/current',
+       '%(path)s/releases/current/apps',
+       '%(path)s/releases/current/lib',
+] + sys.path
+
+# Run Django
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+from django.core.handlers.wsgi import WSGIHandler
+application = WSGIHandler()
diff --git a/platforma/config/requirements.txt b/platforma/config/requirements.txt
new file mode 100644 (file)
index 0000000..0014b59
--- /dev/null
@@ -0,0 +1,20 @@
+## Python libraries
+lxml>=2.2
+mercurial>=1.3.1
+PyYAML>=3.0
+
+## Book conversion library
+git+http://github.com/fnp/librarian.git@master#egg=librarian
+
+## Django 
+Django>=1.1.1,<1.2
+sorl-thumbnail>=3.2
+django-maintanancemode>=0.9
+
+# migrations
+south>=0.6
+
+## Debugging utils, uncomment this if you want tests
+# django-nose>=0.0.3
+# django-debug-toolbar>=0.8
+
diff --git a/platforma/localsettings.sample b/platforma/localsettings.sample
deleted file mode 100644 (file)
index c174cf9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# 
-#  localsettings template for Platforma
-#
-#  Duplicate this file as localsettings.py and change it to your liking.
-#  Settings defined in localsettings.py will override settings from 
-#  settings.py file. localsettings.py should never be commited 
-#  to a version control system. Please make changes to settings.py 
-#  or localsettings.sample instead.
-#
-
-# Path to repository with managed documents
-REPOSITORY_PATH = '/home/user/repository'
-
-# Subdirectory of STATIC_ROOT containing images
-IMAGE_DIR = 'images'
-
-CAS_SERVICE_URL = 'http://stigma.nowoczesnapolska.org.pl/cas/'
-
diff --git a/platforma/logging.cfg b/platforma/logging.cfg
deleted file mode 100644 (file)
index 9bfa56c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-[loggers]
-keys=root,fnp
-
-[handlers]
-keys=console
-
-[formatters]
-keys=default
-
-[logger_root]
-level=DEBUG
-handlers=console
-
-[logger_fnp]
-level=DEBUG
-handlers=console
-qualname=fnp
-propagate=0
-
-[formatter_default]
-format=%(asctime)s %(name)s/%(levelname)s :: %(module)s.%(funcName)s:%(lineno)d :: %(message)s
-datefmt=
-class=logging.Formatter
-
-[handler_console]
-class=StreamHandler
-level=DEBUG
-formatter=default
-args=(sys.stderr, ) 
\ No newline at end of file
diff --git a/platforma/logging.cfg.dev b/platforma/logging.cfg.dev
deleted file mode 100644 (file)
index 9bfa56c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-[loggers]
-keys=root,fnp
-
-[handlers]
-keys=console
-
-[formatters]
-keys=default
-
-[logger_root]
-level=DEBUG
-handlers=console
-
-[logger_fnp]
-level=DEBUG
-handlers=console
-qualname=fnp
-propagate=0
-
-[formatter_default]
-format=%(asctime)s %(name)s/%(levelname)s :: %(module)s.%(funcName)s:%(lineno)d :: %(message)s
-datefmt=
-class=logging.Formatter
-
-[handler_console]
-class=StreamHandler
-level=DEBUG
-formatter=default
-args=(sys.stderr, ) 
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644 (file)
index 0014b59..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-## Python libraries
-lxml>=2.2
-mercurial>=1.3.1
-PyYAML>=3.0
-
-## Book conversion library
-git+http://github.com/fnp/librarian.git@master#egg=librarian
-
-## Django 
-Django>=1.1.1,<1.2
-sorl-thumbnail>=3.2
-django-maintanancemode>=0.9
-
-# migrations
-south>=0.6
-
-## Debugging utils, uncomment this if you want tests
-# django-nose>=0.0.3
-# django-debug-toolbar>=0.8
-
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..fffdad3
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+from distutils.core import setup
+
+def is_package(path):
+    return (
+        os.path.isdir(path) and
+        os.path.isfile(os.path.join(path, '__init__.py'))
+        )
+
+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 base:
+                module_name = "%(base)s.%(item)s" % vars()
+            else:
+                module_name = item
+            packages[module_name] = dir
+            packages.update(find_packages(dir, module_name))
+    return packages
+
+def files_from(*paths, **kwargs):
+    base = kwargs.pop('base')   
+    def generator():
+        for path in paths:
+            path = os.path.join(base, path)
+            print 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):
+    
+    # directories
+    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 
+    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 = {}
+    for app in apps:
+        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)   
+    
+    return setup(
+                package_dir = package_dir, 
+                packages = packages, 
+                package_data = package_data, **kwargs)
+    
+#
+# The reald stuff :)
+#
+django_setup(
+    name='fnp-redakcja',
+    version='1.1',
+    description='IDE for developing books.',
+    author="Fundacja Nowoczesna Polska",
+    author_email='fundacja@nowoczesnapolska.org.pl',
+    license="GNU Affero General Public License 3",
+    maintainer='Łukasz Rekucki',    
+    maintainer_email='lrekucki@gmail.com',
+    url='http://github.com/fnp/redakcja',
+    package_dir = {'': 'lib'},           
+    py_modules = [ 
+        'wlapi',
+        'vstorage',    
+    ],      
+    scripts=[
+        'scripts/crop.py', 
+        'scripts/imgconv.py',
+    ],             
+    # django applications
+    project = 'platforma',
+    apps_dir = 'apps',
+    apps = [
+        'compress',
+        'django_cas',   
+        'filebrowser',
+        'toolbar',
+        'wiki',        
+    ],
+    # data_files=[ ('', ['LICENSE', 'NOTICE', 'README.rst', 'AUTHORS.md', 'requirements.txt'])],
+)