forked from zopefoundation/BTrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
218 lines (194 loc) · 6.5 KB
/
setup.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
##############################################################################
#
# Copyright (c) 2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# 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.
#
##############################################################################
import os
import sys
from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError
from setuptools import Extension
from setuptools import find_packages
from setuptools import setup
from setuptools.command.build_ext import build_ext
version = '6.2.dev0'
def _read(fname):
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, fname)) as f:
return f.read()
README = _read("README.rst") + '\n\n' + _read('CHANGES.rst')
class optional_build_ext(build_ext):
"""This class subclasses build_ext and allows
the building of C extensions to fail.
"""
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError as e:
self._unavailable(e)
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError, OSError) as e:
self._unavailable(e)
def _unavailable(self, e):
print('*' * 80)
print("""WARNING:
An optional code optimization (C extension) could not be compiled.
Optimizations for this package will not be available!""")
print()
print(e)
print('*' * 80)
if 'bdist_wheel' in sys.argv and not os.environ.get("PURE_PYTHON"):
# pip uses bdist_wheel by default, and hides the error output.
# Let this error percolate up so the user can see it.
# pip will then go ahead and run 'setup.py install' directly.
raise
# 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",
]
FLAVORS = {
"O": "object",
"F": "float",
"I": "int", # Signed 32-bit
"L": "int", # Signed 64-bit
"U": "int", # Unsigned 32-bit
"Q": "int" # Unsigned 64-bit (from the printf "q" modifier for quad_t)
}
# XXX should 'fs' be in ZODB instead?
FAMILIES = (
# Signed 32-bit keys
"IO", # object value
"II", # self value
"IF", # float value
"IU", # opposite sign value
# Unsigned 32-bit keys
"UO", # object value
"UU", # self value
"UF", # float value
"UI", # opposite sign value
# Signed 64-bit keys
"LO", # object value
"LL", # self value
"LF", # float value
"LQ", # opposite sign value
# Unsigned 64-bit keys
"QO", # object value
"QQ", # self value
"QF", # float value
"QL", # opposite sign value
# Object keys
"OO", # object
"OI", # 32-bit signed
"OU", # 32-bit unsigned
"OL", # 64-bit signed
"OQ", # 64-bit unsigned
"fs",
)
KEY_H = "src/BTrees/%skeymacros.h"
VALUE_H = "src/BTrees/%svaluemacros.h"
def BTreeExtension(family):
key = family[0]
value = family[1]
name = "BTrees._%sBTree" % family
sources = ["src/BTrees/_%sBTree.c" % family]
kwargs = {"include_dirs": [os.path.join('include', 'persistent')]}
if family != "fs":
kwargs["depends"] = (base_btrees_depends + [KEY_H % FLAVORS[key],
VALUE_H % FLAVORS[value]])
else:
kwargs["depends"] = base_btrees_depends
if key != "O":
kwargs["define_macros"] = [('EXCLUDE_INTSET_SUPPORT', None)]
return Extension(name, sources, **kwargs)
ext_modules = [BTreeExtension(family) for family in FAMILIES]
REQUIRES = [
# 4.1.0 is the first version that PURE_PYTHON can run
# ZODB tests
'persistent >= 4.1.0',
# 5.0.0 added zope.interface.common.collections
'zope.interface >= 5.0.0',
]
TESTS_REQUIRE = [
# Our tests check for the new repr strings
# generated in persistent 4.4.
'persistent >= 4.4.3',
'transaction',
'zope.testrunner',
]
setup(
name='BTrees',
version=version,
description='Scalable persistent object containers',
long_description=README,
classifiers=[
"Development Status :: 6 - Mature",
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Framework :: ZODB",
"Topic :: Database",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
],
author="Zope Foundation",
author_email="[email protected]",
url="https://github.com/zopefoundation/BTrees",
project_urls={
'Documentation': 'https://btrees.readthedocs.io',
'Issue Tracker': 'https://github.com/zopefoundation/BTrees/issues',
'Sources': 'https://github.com/zopefoundation/BTrees',
},
license="ZPL 2.1",
platforms=["any"],
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
ext_modules=ext_modules,
extras_require={
'test': TESTS_REQUIRE,
'ZODB': [
'ZODB',
],
'docs': [
'Sphinx',
'repoze.sphinx.autointerface',
'sphinx_rtd_theme',
],
},
python_requires='>=3.8',
install_requires=REQUIRES,
cmdclass={
'build_ext': optional_build_ext,
},
entry_points="""\
"""
)