From: Łukasz Rekucki Date: Sun, 28 Mar 2010 18:28:11 +0000 (+0200) Subject: Distutils installation script. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/f7e3ba3851d4ec6e3decaab0d568e492726224dc?ds=sidebyside;hp=ee01d50d05b7d72dd372e8f3a0c78b9da6c23b38 Distutils installation script. --- diff --git a/fabfile.py b/fabfile.py index eba8f1f8..724fca2a 100644 --- a/fabfile.py +++ b/fabfile.py @@ -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 index 03da16f6..00000000 --- a/lib/run_tests.sh +++ /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 index 7d445573..00000000 --- a/platforma.vhost.template +++ /dev/null @@ -1,38 +0,0 @@ - - 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 - - Order allow,deny - allow from all - - - Alias /media %(path)s/media - - Options Indexes - Order allow,deny - Allow from all - - - Alias /admin-media %(path)s/admin-media - - Options Indexes - Order allow,deny - Allow from all - - - Alias /static %(path)s/releases/current/%(project_name)s/static - - Options Indexes - Order allow,deny - Allow from all - - - LogLevel warn - ErrorLog /var/log/apache2/error.log - CustomLog /var/log/apache2/access.log combined - diff --git a/platforma.wsgi.template b/platforma.wsgi.template deleted file mode 100644 index 3528fe88..00000000 --- a/platforma.wsgi.template +++ /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 index 00000000..c174cf92 --- /dev/null +++ b/platforma/config/localsettings.sample @@ -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 index 00000000..9bfa56c2 --- /dev/null +++ b/platforma/config/logging.cfg @@ -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 index 00000000..9bfa56c2 --- /dev/null +++ b/platforma/config/logging.cfg.dev @@ -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 index 00000000..7d445573 --- /dev/null +++ b/platforma/config/platforma.vhost.template @@ -0,0 +1,38 @@ + + 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 + + Order allow,deny + allow from all + + + Alias /media %(path)s/media + + Options Indexes + Order allow,deny + Allow from all + + + Alias /admin-media %(path)s/admin-media + + Options Indexes + Order allow,deny + Allow from all + + + Alias /static %(path)s/releases/current/%(project_name)s/static + + Options Indexes + Order allow,deny + Allow from all + + + LogLevel warn + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + diff --git a/platforma/config/platforma.wsgi.template b/platforma/config/platforma.wsgi.template new file mode 100644 index 00000000..3528fe88 --- /dev/null +++ b/platforma/config/platforma.wsgi.template @@ -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 index 00000000..0014b59e --- /dev/null +++ b/platforma/config/requirements.txt @@ -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 index c174cf92..00000000 --- a/platforma/localsettings.sample +++ /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 index 9bfa56c2..00000000 --- a/platforma/logging.cfg +++ /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 index 9bfa56c2..00000000 --- a/platforma/logging.cfg.dev +++ /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 index 0014b59e..00000000 --- a/requirements.txt +++ /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 index 00000000..fffdad3c --- /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'])], +)