setup.py 5.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
# WKRD: Official Python packaging and buildout are not designed to build
#       several binary packages from a single source one. This setup.py
#       contains several hacks to work around this horrible limitation, and
#       make it possible to develop several eggs in the same tree/repository:
#       - in development mode, it behaves somehow like a mono-package
#       - otherwise, sdist/bdist commands produces several packages

description = 'Distributed, redundant and transactional storage for ZODB'

setup_common = dict(
    version = '1.0a1',
    author = 'NEOPPOD',
    author_email = 'neo-dev@erp5.org',
    url = 'http://www.neoppod.org/',
    license = 'GPL 2+',
    install_requires = ['neoppod'],
    namespace_packages = ['neo', 'neo.scripts'],
    zip_safe = True,
)

import os, sys
from distutils.filelist import findall

try:
    setup_only, = [l[5:].strip() for l in open('PKG-INFO') if l[:5] == 'Name:']
except IOError:
    setup_only = None

def setup(name, packages=(), extra_files=(), _done=[], **kw):
    if setup_only and setup_only != name or \
       _done and ('--help' in sys.argv or '--help-commands' in sys.argv):
        return
    from distutils.command.build import build
    from setuptools import find_packages, setup
    from setuptools.command import egg_info, develop
    kw['packages'] = sum((isinstance(p, basestring) and [p] or
        list(p[:1]) + [p[0] + '.' + x for x in find_packages(*p[1:])]
        for p in packages), [])
    # monkey-patch to build package in different folders
    build_initialize_options = build.initialize_options
    def initialize_options(self):
        build_initialize_options(self)
        self.build_base = os.path.join(self.build_base, name)
    # per-package manifest, instead of walking files under revision control
    walk_revctrl = egg_info.walk_revctrl
    # create only 1 egg-link for buildout
    develop_finalize_options = develop.develop.finalize_options
    def finalize_options(self):
        develop_finalize_options(self)
        self.egg_link = os.devnull
    try:
        build.initialize_options = initialize_options
        egg_info.walk_revctrl = lambda *args, **kw: extra_files
        if _done:
            develop.develop.finalize_options = finalize_options
        setup(name = name, **dict(setup_common, **kw))
    finally:
        develop.develop.finalize_options = develop_finalize_options
        build.initialize_options = build_initialize_options
        egg_info.walk_revctrl = walk_revctrl
    _done.append(name)

setup(
    name = 'neoppod',
    description = description + ' - Common part',
    packages = ['neo', ('neo.lib', 'neo/lib')],
Julien Muchembled's avatar
Julien Muchembled committed
67
    # Raah!!! I wish I could write something like:
68 69 70 71 72 73 74 75 76 77 78 79
    #  install_requires = ['python>=2.5|ctypes']
    install_requires = (),
    namespace_packages = ['neo'],
    extra_files = ['TODO'],
)

setup(
    name = 'neoadmin',
    description = description + ' - Admin part',
    packages = ['neo', ('neo.admin', 'neo/admin')],
    py_modules = ['neo.scripts.neoadmin'],
    entry_points = {
Vincent Pelletier's avatar
Vincent Pelletier committed
80 81
        'console_scripts': [
            'neoadmin=neo.scripts.neoadmin:main',
82 83 84 85 86 87 88 89 90 91 92 93 94
        ],
    },
    extra_files = ['neo.conf'],
)

setup(
    name = 'neoclient',
    description = description + ' - Client part',
    packages = ['neo', ('neo.client', 'neo/client')],
    install_requires = ['neoppod', 'ZODB3 >= 3.9'],
    py_modules = ['neo.scripts.neomigrate'],
    entry_points = {
        'console_scripts': [
95
            'neomigrate=neo.scripts.neomigrate:main',
Vincent Pelletier's avatar
Vincent Pelletier committed
96 97
        ],
    },
98
    package_data = {
99
        'neo.client': [
100 101 102
            'component.xml',
        ],
    },
103
    extra_files = ['neo/client/component.xml'], # required for Python < 2.7
Vincent Pelletier's avatar
Vincent Pelletier committed
104 105
)

106 107 108 109
setup(
    name = 'neoctl',
    description = description + ' - Controller part',
    packages = ['neo', ('neo.neoctl', 'neo/neoctl')],
110
    py_modules = ['neo.scripts.neoctl'],
111 112
    entry_points = {
        'console_scripts': [
113
            'neoctl=neo.scripts.neoctl:main',
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        ],
    },
)

setup(
    name = 'neomaster',
    description = description + ' - Master part',
    packages = ['neo', ('neo.master', 'neo/master')],
    py_modules = ['neo.scripts.neomaster'],
    entry_points = {
        'console_scripts': [
            'neomaster=neo.scripts.neomaster:main',
        ],
    },
    extra_files = ['neo.conf'],
)

setup(
    name = 'neostorage',
    description = description + ' - Storage part',
    packages = ['neo', ('neo.storage', 'neo/storage')],
    py_modules = ['neo.scripts.neostorage'],
    entry_points = {
        'console_scripts': [
            'neostorage=neo.scripts.neostorage:main',
        ],
    },
    extras_require = {
        'btree': ['ZODB3'],
        'mysqldb': ['MySQL-python'],
    },
    extra_files = ['neo.conf'],
)

if setup_only in ('neotests', None) and not os.path.exists('mock.py'):
    import cStringIO, md5, urllib, zipfile
    mock_py = zipfile.ZipFile(cStringIO.StringIO(urllib.urlopen(
      'http://downloads.sf.net/sourceforge/python-mock/pythonmock-0.1.0.zip'
      ).read())).read('mock.py')
    if md5.md5(mock_py).hexdigest() != '79f42f390678e5195d9ce4ae43bd18ec':
        raise EnvironmentError("MD5 checksum mismatch downloading 'mock.py'")
    open('mock.py', 'w').write(mock_py)

setup(
    name = 'neotests',
    description = description + ' - Testing part',
    packages = ['neo', ('neo.tests', 'neo/tests')],
    install_requires = [
        'neoadmin',
        'neoclient',
        'neoctl',
        'neomaster',
        'neostorage[btree, mysqldb]',
        'psutil',
        'zope.testing',
    ],
    py_modules = ['mock', 'neo.scripts.runner'],
    entry_points = {
        'console_scripts': [
            'neotestrunner=neo.scripts.runner:main',
        ],
    },
    extra_files = ['TESTS.txt'] + findall('tools'),
)