-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·218 lines (200 loc) · 7.07 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
import os
import sys
import codecs
from setuptools import setup
from setuptools import find_namespace_packages
from setuptools import Extension
PYPY = hasattr(sys, 'pypy_version_info')
entry_points = {
'console_scripts': [
],
'zest.releaser.prereleaser.before': [
# XXX This only works if we do `fullrelease`.
'rm_cflags = nti.externalization._compat:release_remove_cflags',
],
}
TESTS_REQUIRE = [
'nti.testing',
'zope.testrunner',
'manuel',
'pyperf',
]
def _read(fname):
with codecs.open(fname, encoding='utf-8') as f:
return f.read()
# Cython
# Based on code from
# http://cython.readthedocs.io/en/latest/src/reference/compilation.html#distributing-cython-modules
def _dummy_cythonize(extensions, **_kwargs):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in {'.pyx', '.py'}:
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
try:
from Cython.Build import cythonize
except ImportError:
# The .c files had better already exist, as they should in
# an sdist.
cythonize = _dummy_cythonize
ext_modules = []
# Modules we want to compile with Cython. These *should* have a parallel
# .pxd file (with a leading _) defining cython attributes.
# They should also have a cython comment at the top giving options,
# and mention that they are compiled with cython on CPython.
# The bottom of the file must call import_c_accel.
# We use the support from Cython 28 to be able to parallel compile
# and cythonize modules to a different name with a leading _.
# This list is derived from the profile of bm_simple_iface
# https://github.com/OpenNTI/nti.externalization/commit/0bc4733aa8158acd0d23c14de2f9347fb698c040
if not PYPY:
def _source(m, ext):
m = m.replace('.', '/')
return 'src/nti/externalization/' + m + '.' + ext
def _py_source(m):
return _source(m, 'py')
def _pxd(m):
return _source(m, 'pxd')
def _c(m):
return _source(m, 'c')
# Each module should list the python name of the
# modules it cimports from as deps. We'll generate the rest.
# (Not that this actually appears to do anything right now.)
for mod_name, deps in (
('singleton', ()),
('_base_interfaces', ()),
('internalization.legacy_factories', ()),
('internalization.factories', ()),
('internalization.fields', ()),
('internalization.events', ('_interface_cache',)),
('internalization.externals', ()),
('internalization.updater', ()),
('externalization.fields', ('_base_interfaces',)),
('externalization.standard_fields', (
'_base_interfaces',
'_fields',
)),
('externalization.dictionary', ('_base_interfaces',)),
('externalization.externalizer', ('_base_interfaces',)),
('externalization.decorate', ()),
#('externalization', ('_base_interfaces',)),
('_interface_cache', ()),
('datastructures', (
'_base_interfaces',
'_interface_cache',
'externalization',
'internalization')),
):
deps = ([_py_source(mod) for mod in deps]
+ [_pxd(mod) for mod in deps]
+ [_c(mod) for mod in deps])
source = _py_source(mod_name)
# 'foo.bar' -> 'foo._bar'
mod_name_parts = mod_name.rsplit('.', 1)
mod_name_parts[-1] = '_' + mod_name_parts[-1]
mod_name = '.'.join(mod_name_parts)
ext_modules.append(
Extension(
'nti.externalization.' + mod_name,
sources=[source],
depends=deps,
define_macros=[
# ('CYTHON_TRACE', '1')
],
))
try:
ext_modules = cythonize(
ext_modules,
annotate=True,
compiler_directives={
#'linetrace': True,
'infer_types': True,
'language_level': '3',
'always_allow_keywords': False,
'nonecheck': False,
},
)
except ValueError:
# 'invalid literal for int() with base 10: '3str'
# This is seen when an older version of Cython is installed.
# It's a bit of a chicken-and-egg, though, because installing
# from dev-requirements first scans this egg for its requirements
# before doing any updates.
import traceback
traceback.print_exc()
ext_modules = _dummy_cythonize(ext_modules)
setup(
name='nti.externalization',
version='2.4.1.dev0',
author='Jason Madden',
author_email='[email protected]',
description="NTI Externalization",
long_description=(_read('README.rst') + '\n\n' + _read('CHANGES.rst')),
license='Apache',
keywords='externalization',
classifiers=[
'License :: OSI Approved :: Apache Software License',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: OS Independent',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'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',
],
url="https://github.com/OpenNTI/nti.externalization",
zip_safe=True,
packages=find_namespace_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
ext_modules=ext_modules,
install_requires=[
'nti.schema >= 1.17.0',
'PyYAML >= 5.1',
'ZODB >= 5.5.1',
'isodate',
'persistent >= 4.7.0',
'pytz',
'simplejson >= 3.19',
'transaction >= 2.2',
'zope.component >= 4.6.1',
'zope.configuration >= 4.4.0',
'zope.container >= 4.4.0',
'zope.dottedname >= 4.3.0',
'zope.dublincore >= 4.2.0',
'zope.event >= 4.4.0',
'zope.hookable >= 5.0.1',
'zope.interface >= 5.0.1', # getDirectTaggedValue
'zope.intid >= 4.3.0',
'zope.lifecycleevent >= 4.3.0',
'zope.location >= 4.2.0',
'zope.mimetype >= 2.5.0',
'zope.proxy >= 4.3.5',
'zope.schema >= 6.0.0',
'zope.security >= 5.1.1',
'BTrees >= 4.8.0', # Registers BTrees as Mapping automatically.
],
extras_require={
'test': TESTS_REQUIRE,
'docs': [
'Sphinx',
'repoze.sphinx.autointerface',
'sphinx_rtd_theme',
],
'benchmarks': [
'pyperf',
],
},
entry_points=entry_points,
python_requires=">=3.10",
)