forked from sqlalchemy/sqlalchemy
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
243 lines (206 loc) · 7.39 KB
/
Copy pathsetup.py
File metadata and controls
243 lines (206 loc) · 7.39 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
fromdistutils.command.build_extimportbuild_ext
fromdistutils.errorsimportCCompilerError
fromdistutils.errorsimportDistutilsExecError
fromdistutils.errorsimportDistutilsPlatformError
importos
importplatform
importre
importsys
fromsetuptoolsimportDistributionas_Distribution
fromsetuptoolsimportExtension
fromsetuptoolsimportfind_packages
fromsetuptoolsimportsetup
fromsetuptools.command.testimporttestasTestCommand
cmdclass= {}
ifsys.version_info< (2, 7):
raiseException("SQLAlchemy requires Python 2.7 or higher.")
cpython=platform.python_implementation() =="CPython"
ext_errors= (CCompilerError, DistutilsExecError, DistutilsPlatformError)
ifsys.platform=="win32":
# Work around issue https://github.com/pypa/setuptools/issues/1902
ext_errors+= (IOError, TypeError)
extra_compile_args= []
elifsys.platform=="linux":
# warn for undefined symbols in .c files
extra_compile_args= ["-Wundef"]
else:
extra_compile_args= []
ext_modules= [
Extension(
"sqlalchemy.cprocessors",
sources=["lib/sqlalchemy/cextension/processors.c"],
extra_compile_args=extra_compile_args,
),
Extension(
"sqlalchemy.cresultproxy",
sources=["lib/sqlalchemy/cextension/resultproxy.c"],
extra_compile_args=extra_compile_args,
),
Extension(
"sqlalchemy.cimmutabledict",
sources=["lib/sqlalchemy/cextension/immutabledict.c"],
extra_compile_args=extra_compile_args,
),
Extension(
"sqlalchemy.cutils",
sources=["lib/sqlalchemy/cextension/utils.c"],
extra_compile_args=extra_compile_args,
),
]
classBuildFailed(Exception):
def__init__(self):
self.cause=sys.exc_info()[1] # work around py 2/3 different syntax
classve_build_ext(build_ext):
# This class allows C extension building to fail.
defrun(self):
try:
build_ext.run(self)
exceptDistutilsPlatformError:
raiseBuildFailed()
defbuild_extension(self, ext):
try:
build_ext.build_extension(self, ext)
exceptext_errors:
raiseBuildFailed()
exceptValueError:
# this can happen on Windows 64 bit, see Python issue 7511
if"'path'"instr(sys.exc_info()[1]): # works with both py 2/3
raiseBuildFailed()
raise
cmdclass["build_ext"] =ve_build_ext
classDistribution(_Distribution):
defhas_ext_modules(self):
# We want to always claim that we have ext_modules. This will be fine
# if we don't actually have them (such as on PyPy) because nothing
# will get built, however we don't want to provide an overally broad
# Wheel package when building a wheel without C support. This will
# ensure that Wheel knows to treat us as if the build output is
# platform specific.
returnTrue
classUseTox(TestCommand):
RED=31
RESET_SEQ="\033[0m"
BOLD_SEQ="\033[1m"
COLOR_SEQ="\033[1;%dm"
defrun_tests(self):
sys.stderr.write(
"%s%spython setup.py test is deprecated by pypa. Please invoke "
"'tox' with no arguments for a basic test run.\n%s"
% (self.COLOR_SEQ%self.RED, self.BOLD_SEQ, self.RESET_SEQ)
)
sys.exit(1)
cmdclass["test"] =UseTox
defstatus_msgs(*msgs):
print("*"*75)
formsginmsgs:
print(msg)
print("*"*75)
withopen(
os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py")
) asv_file:
VERSION= (
re.compile(r""".*__version__ = ["'](.*?)['"]""", re.S)
.match(v_file.read())
.group(1)
)
withopen(os.path.join(os.path.dirname(__file__), "README.rst")) asr_file:
readme=r_file.read()
defrun_setup(with_cext):
kwargs= {}
ifwith_cext:
kwargs["ext_modules"] =ext_modules
else:
ifos.environ.get("REQUIRE_SQLALCHEMY_CEXT"):
raiseAssertionError(
"Can't build on this platform with "
"REQUIRE_SQLALCHEMY_CEXT set."
)
kwargs["ext_modules"] = []
setup(
name="SQLAlchemy",
version=VERSION,
description="Database Abstraction Library",
author="Mike Bayer",
author_email="mike_mp@zzzcomputing.com",
url="http://www.sqlalchemy.org",
project_urls={
"Documentation": "https://docs.sqlalchemy.org",
"Issue Tracker": "https://github.com/sqlalchemy/sqlalchemy/",
},
packages=find_packages("lib"),
package_dir={"": "lib"},
license="MIT",
cmdclass=cmdclass,
long_description=readme,
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database :: Front-Ends",
"Operating System :: OS Independent",
],
distclass=Distribution,
extras_require={
"mysql": ["mysqlclient"],
"pymysql": ["pymysql"],
"postgresql": ["psycopg2"],
"postgresql_psycopg2binary": ["psycopg2-binary"],
"postgresql_pg8000": ["pg8000"],
"postgresql_psycopg2cffi": ["psycopg2cffi"],
"oracle": ["cx_oracle"],
"mssql_pyodbc": ["pyodbc"],
"mssql_pymssql": ["pymssql"],
"mssql": ["pyodbc"],
},
**kwargs
)
ifnotcpython:
run_setup(False)
status_msgs(
"WARNING: C extensions are not supported on "
+"this Python platform, speedups are not enabled.",
"Plain-Python build succeeded.",
)
elifos.environ.get("DISABLE_SQLALCHEMY_CEXT"):
run_setup(False)
status_msgs(
"DISABLE_SQLALCHEMY_CEXT is set; "
+"not attempting to build C extensions.",
"Plain-Python build succeeded.",
)
else:
try:
run_setup(True)
exceptBuildFailedasexc:
ifos.environ.get("REQUIRE_SQLALCHEMY_CEXT"):
status_msgs(
"NOTE: C extension build is required because "
"REQUIRE_SQLALCHEMY_CEXT is set, and the build has failed; "
"will not degrade to non-C extensions"
)
raise
status_msgs(
exc.cause,
"WARNING: The C extension could not be compiled, "
+"speedups are not enabled.",
"Failure information, if any, is above.",
"Retrying the build without the C extension now.",
)
run_setup(False)
status_msgs(
"WARNING: The C extension could not be compiled, "
+"speedups are not enabled.",
"Plain-Python build succeeded.",
)