setup.py 7.17 KB
Newer Older
1
##############################################################################
2
#
3
# Copyright (c) 2002, 2003 Zope Foundation and Contributors.
4 5 6
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Jim Fulton's avatar
Jim Fulton committed
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8 9 10 11 12 13
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
14 15 16 17 18 19 20 21 22
"""Zope Object Database: object database and persistence

The Zope Object Database provides an object-oriented database for
Python that provides a high-degree of transparency. Applications can
take advantage of object database features with few, if any, changes
to application logic.  ZODB includes features such as a plugable storage
interface, rich transaction support, and undo.
"""

Jim Fulton's avatar
Jim Fulton committed
23
VERSION = "4.0.0dev"
24

25 26 27
from ez_setup import use_setuptools
use_setuptools()

Jim Fulton's avatar
Jim Fulton committed
28
from setuptools import setup, find_packages
Jim Fulton's avatar
Jim Fulton committed
29
from setuptools.extension import Extension
Jim Fulton's avatar
Jim Fulton committed
30 31 32
import os
import sys

Jim Fulton's avatar
Jim Fulton committed
33 34
if sys.version_info < (2, 5):
    print "This version of ZODB requires Python 2.5 or higher"
Jim Fulton's avatar
Jim Fulton committed
35 36
    sys.exit(0)

37

38

39 40 41 42 43 44 45
if sys.version_info < (2, 6):
    transaction_version = 'transaction == 1.1.1'
    manuel_version = 'manuel < 1.6dev'
else:
    transaction_version = 'transaction >= 1.1.0'
    manuel_version = 'manuel'

46 47 48 49 50 51 52 53 54 55 56 57 58
# The (non-obvious!) choices for the Trove Development Status line:
# Development Status :: 5 - Production/Stable
# Development Status :: 4 - Beta
# Development Status :: 3 - Alpha

classifiers = """\
Intended Audience :: Developers
License :: OSI Approved :: Zope Public License
Programming Language :: Python
Topic :: Database
Topic :: Software Development :: Libraries :: Python Modules
Operating System :: Microsoft :: Windows
Operating System :: Unix
59
Framework :: ZODB
60
"""
61

62
# Include directories for C extensions
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
# Sniff the location of the headers in 'persistent'.

class ModuleHeaderDir(object):

    def __init__(self, require_spec, where='..'):
        # By default, assume top-level pkg has the same name as the dist.
        # Also assume that headers are located in the package dir, and
        # are meant to be included as follows:
        #    #include "module/header_name.h"
        self._require_spec = require_spec
        self._where = where

    def __str__(self):
        from pkg_resources import require
        from pkg_resources import resource_filename
        require(self._require_spec)
        return os.path.abspath(
                    resource_filename(self._require_spec, self._where))

include = [ModuleHeaderDir('persistent'), 'src']
83 84 85 86 87 88 89 90 91 92 93 94 95 96

# Set up dependencies for the BTrees package
base_btrees_depends = [
    "src/BTrees/BTreeItemsTemplate.c",
    "src/BTrees/BTreeModuleTemplate.c",
    "src/BTrees/BTreeTemplate.c",
    "src/BTrees/BucketTemplate.c",
    "src/BTrees/MergeTemplate.c",
    "src/BTrees/SetOpTemplate.c",
    "src/BTrees/SetTemplate.c",
    "src/BTrees/TreeSetTemplate.c",
    "src/BTrees/sorters.c",
    ]

97
_flavors = {"O": "object", "I": "int", "F": "float", 'L': 'int'}
98 99 100 101

KEY_H = "src/BTrees/%skeymacros.h"
VALUE_H = "src/BTrees/%svaluemacros.h"

102

103 104 105 106 107 108 109 110 111
def BTreeExtension(flavor):
    key = flavor[0]
    value = flavor[1]
    name = "BTrees._%sBTree" % flavor
    sources = ["src/BTrees/_%sBTree.c" % flavor]
    kwargs = {"include_dirs": include}
    if flavor != "fs":
        kwargs["depends"] = (base_btrees_depends + [KEY_H % _flavors[key],
                                                    VALUE_H % _flavors[value]])
112 113
    else:
        kwargs["depends"] = base_btrees_depends
114 115 116 117 118
    if key != "O":
        kwargs["define_macros"] = [('EXCLUDE_INTSET_SUPPORT', None)]
    return Extension(name, sources, **kwargs)

exts = [BTreeExtension(flavor)
119 120 121
        for flavor in ("OO", "IO", "OI", "II", "IF",
                       "fs", "LO", "OL", "LL", "LF",
                       )]
122

Jim Fulton's avatar
Jim Fulton committed
123 124 125 126 127
def _modname(path, base, name=''):
    if path == base:
        return name
    dirname, basename = os.path.split(path)
    return _modname(dirname, base, basename + '.' + name)
128

129
def alltests():
Jim Fulton's avatar
Jim Fulton committed
130 131 132 133 134 135 136
    import logging
    import pkg_resources
    import unittest
    import ZEO.ClientStorage

    class NullHandler(logging.Handler):
        level = 50
Jim Fulton's avatar
Jim Fulton committed
137

Jim Fulton's avatar
Jim Fulton committed
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
        def emit(self, record):
            pass

    logging.getLogger().addHandler(NullHandler())

    suite = unittest.TestSuite()
    base = pkg_resources.working_set.find(
        pkg_resources.Requirement.parse('ZODB3')).location
    for dirpath, dirnames, filenames in os.walk(base):
        if os.path.basename(dirpath) == 'tests':
            for filename in filenames:
                if filename != 'testZEO.py': continue
                if filename.endswith('.py') and filename.startswith('test'):
                    mod = __import__(
                        _modname(dirpath, base, os.path.splitext(filename)[0]),
                        {}, {}, ['*'])
                    suite.addTest(mod.test_suite())
        elif 'tests.py' in filenames:
            continue
            mod = __import__(_modname(dirpath, base, 'tests'), {}, {}, ['*'])
            suite.addTest(mod.test_suite())
    return suite
160

161
doclines = __doc__.split("\n")
162

163
def read_file(*path):
164
    base_dir = os.path.dirname(__file__)
165 166
    file_path = (base_dir, ) + tuple(path)
    return file(os.path.join(*file_path)).read()
167

168 169 170 171 172 173 174 175
long_description = str(
    ("\n".join(doclines[2:]) + "\n\n" +
     ".. contents::\n\n" +
     read_file("README.txt")  + "\n\n" +
     read_file("src", "CHANGES.txt")
    ).decode('latin-1').replace(u'L\xf6wis', '|Lowis|')
    )+ '''\n\n.. |Lowis| unicode:: L \\xf6 wis\n'''

176
setup(name="ZODB3",
177
      version=VERSION,
178
      setup_requires=['persistent'],
Jim Fulton's avatar
Jim Fulton committed
179
      maintainer="Zope Foundation and Contributors",
180
      maintainer_email="zodb-dev@zope.org",
Jim Fulton's avatar
Jim Fulton committed
181
      packages = find_packages('src'),
182 183 184 185 186 187
      package_dir = {'': 'src'},
      ext_modules = exts,
      license = "ZPL 2.1",
      platforms = ["any"],
      description = doclines[0],
      classifiers = filter(None, classifiers.split("\n")),
188
      long_description = long_description,
189
      test_suite="__main__.alltests", # to support "setup.py test"
190 191
      tests_require = ['zope.testing', manuel_version],
      extras_require = dict(test=['zope.testing', manuel_version]),
192 193 194 195
      # XXX: We don't really want to install these headers;  we would
      #      prefer just including them so that folks can build from an sdist.
      headers = ['include/persistent/cPersistence.h',
                 'include/persistent/ring.h'],
196
      install_requires = [
197
        transaction_version,
198
        'persistent',
199 200 201
        'zc.lockfile',
        'ZConfig',
        'zdaemon',
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
        'zope.interface',
        ],
      zip_safe = False,
      entry_points = """
      [console_scripts]
      fsdump = ZODB.FileStorage.fsdump:main
      fsoids = ZODB.scripts.fsoids:main
      fsrefs = ZODB.scripts.fsrefs:main
      fstail = ZODB.scripts.fstail:Main
      repozo = ZODB.scripts.repozo:main
      zeopack = ZEO.scripts.zeopack:main
      runzeo = ZEO.runzeo:main
      zeopasswd = ZEO.zeopasswd:main
      zeoctl = ZEO.zeoctl:main
      """,
      include_package_data = True,
      )