From f7e3ba3851d4ec6e3decaab0d568e492726224dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Sun, 28 Mar 2010 20:28:11 +0200 Subject: [PATCH] Distutils installation script. --- fabfile.py | 8 +- lib/run_tests.sh | 2 - platforma/{ => config}/localsettings.sample | 0 platforma/{ => config}/logging.cfg | 0 platforma/{ => config}/logging.cfg.dev | 0 .../config/platforma.vhost.template | 0 .../config/platforma.wsgi.template | 0 .../config/requirements.txt | 0 setup.py | 104 ++++++++++++++++++ 9 files changed, 108 insertions(+), 6 deletions(-) delete mode 100644 lib/run_tests.sh rename platforma/{ => config}/localsettings.sample (100%) rename platforma/{ => config}/logging.cfg (100%) rename platforma/{ => config}/logging.cfg.dev (100%) rename platforma.vhost.template => platforma/config/platforma.vhost.template (100%) rename platforma.wsgi.template => platforma/config/platforma.wsgi.template (100%) rename requirements.txt => platforma/config/requirements.txt (100%) create mode 100644 setup.py 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/localsettings.sample b/platforma/config/localsettings.sample similarity index 100% rename from platforma/localsettings.sample rename to platforma/config/localsettings.sample diff --git a/platforma/logging.cfg b/platforma/config/logging.cfg similarity index 100% rename from platforma/logging.cfg rename to platforma/config/logging.cfg diff --git a/platforma/logging.cfg.dev b/platforma/config/logging.cfg.dev similarity index 100% rename from platforma/logging.cfg.dev rename to platforma/config/logging.cfg.dev diff --git a/platforma.vhost.template b/platforma/config/platforma.vhost.template similarity index 100% rename from platforma.vhost.template rename to platforma/config/platforma.vhost.template diff --git a/platforma.wsgi.template b/platforma/config/platforma.wsgi.template similarity index 100% rename from platforma.wsgi.template rename to platforma/config/platforma.wsgi.template diff --git a/requirements.txt b/platforma/config/requirements.txt similarity index 100% rename from requirements.txt rename to platforma/config/requirements.txt 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'])], +) -- 2.20.1