forked from grantc/python-ingresdbi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
320 lines (279 loc) · 12 KB
/
setup.py
File metadata and controls
320 lines (279 loc) · 12 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env python
"""
Copyright (c) 2005-2008 Ingres Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
from distutils.core import setup, Extension, Command
from distutils.util import get_platform
import os
import sys
import re
from glob import glob
try:
from docutils.core import publish_cmdline
except ImportError:
publish_cmdline = None
"""
History
13-Sep-2004 - Initial creation (crogr01@ca.com)
Targeted at Linux.
13-Sep-2004 - (loera01@ca.com/clach04@ca.com)
preliminary support for win32
20-Sep-2004 - (crogr01@ca.com)
fixed libraries to link against the correct ODBC/CLI library.
24-Sep-2004 - (clach04@ca.com)
Added hack for win32 compiles to deal with lack of
bit varying (SQL_BIT_VARYING) in MS ODBC headers.
Put in correct library name for ODBC (under win32).
20-Oct-2003 - (crogr01@ca.com)
Incremented version to 0.9.1.3
21-Oct-2003 - (crogr01@ca.com)
removed reference to ingres.lib since it is not used.
25-Oct-2003 - (crogr01@ca.com)
Added DBIVERSION macro definition
21-Dec-2004 - (Ralph.Loen@ca.com)
Incremented version to 1.0.4.
10-Jan-2005 - (Ralph.Loen@ca.com)
Incremented version to 1.0.5.
31-Jan-2005 (Ralph.Loen@ca.com)
Incremented version to 1.0.6.
16-Feb-2005 (Ralph.Loen@ca.com)
Incremented version to 1.0.7.
23-Feb-2004 (Ralph.Loen@ca.com)
Incremented version to 1.0.8.
19-May-2005 (Ralph.Loen@ca.com)
Incremented version to 1.0.9.
19-May-2005 (Ralph.Loen@ca.com)
Incremented version to 1.5.0.
24-June-2005 (Ralph.Loen@ca.com)
Incremented version to 1.9.0.
16-Nov-2005 (Ralph.Loen@ca.com)
Incremented version to 1.9.1.
22-Nov-2005 (Ralph.Loen@ca.com)
Incremented version to 1.9.3.
23-Jan-2005 (Chris.Clark@ingres.com)
Simple helper changes:
Allow script to be called directly.
Check II_SYSTEM is set.
Changed few CA references
Still need to change license and url for project.
27-Feb-2005 (Chris.Clark@ingres.com)
Incremented version to 1.9.4.
Removed duplicate version string constants.
Added simple help output if no params given.
Replaced readme.html with a text file and added html generation.
25-May-2006 (Ralph.Loen@ingres.com)
Removed markdown dependencies and went back to a straight README.html
file. Incremented version to 1.9.5.
06-June-2006 (Ralph.Loen@ingres.com)
Incremented version to 1.9.6.
09-Aug-2006 (Ralph.Loen@ingres.com)
Incremented version to 2.0.0.
05-May-2008 (grant.croker@ingres.com)
Incremented version to 2.0.1.
06-May-2008 (grant.croker@ingres.com)
Added Trove tags, the trove classification for distutils is documented in PEP 301
http://www.python.org/dev/peps/pep-0301/
04-Aug-2009 (Chris.Clark@ingres.com)
Updated Trove tags with new maintainer.
Updated so that sdist now includes the headers so that sdist
produced tarballs can be built.
18-Nov-2009 (Chris.Clark@ingres.com)
README.html is now created by docutils.
12-Jan-2010 (Chris.Clark@ingres.com)
Retract fix for Trac bug 224 - rt library is not needed on
any platform. rt lib is missing from Mac OSX which prevents
it from building.
12-Jan-2010 (Chris.Clark@ingres.com)
Fix for Trac Bug #526 Add libframe library.
Python driver needs ODBC (and CLI),
which needs OpenAPI,
which in turn needs libq as that is where existing GCA code is
libq needs libframe, for some reason on some Unix platforms (Solaris)
libframe must be explictly linked in (unlike say Windows and Linux).
However linking in libframe under Linux is not an issue so setting
libframe as a default for all platforms (bar Windows).
22-Jun-2010 (Grant.Croker@ingres.com)
Ticket #623 - Add support for Ingres on Windows 64-bit (AMD64)
22-Jun-2010 (Grant.Croker@ingres.com)
Use Vim modeline to enforce formatting
- 1 tab = 4 spaces (tabstop,ts)
- tabs are expanded to spaces (expandtab)
- line shift 4 spaces (shiftwidth,sw)
- smart tab handling (smarttab)
Known Issues
* there is no support for installing to an alternate directory.
o perhaps there is in distutils, not investigated at this time.
* rpm not available as yet to do this but can be built if required.
* problem with "misc" dir/file under win32 - commented it out!
* need to included header files.
* to force a full refresh, delete the manifest file first.
* win32 only, python 2.3 only) - if distutils fails with:
error: Python was built with version 6 of Visual Studio,
and extensions need to be built with the same version of
the compiler, but it isn't installed.
and you do have version 6 of Visual Studio installed run
"Microsoft Visual C++ 6.0" msdev.exe (the GUI) then quit out and
retry the build. See Python mailing list:
http://mail.python.org/pipermail/python-dev/2003-November/040478.html
...for further information.
* win32 only, python 2.4 need .NET SDK (or msys/mingw32) to build
Consider be using:
setup.py bdist_wininst
setup.py bdist_msi
To create installers for end users.
"""
if len(sys.argv) <= 1:
print("""
Suggested setup.py parameters:
* build
* install
* sdist
* bdist_wininst
""")
# Normal setup.py functions for platform/version packaging
class TestSuite(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print('About to start test suite')
import subprocess
test_scriptname = os.path.join('tests', 'test_ingresdbi_dbapi20.py')
errno = subprocess.call([sys.executable, test_scriptname])
raise SystemExit(errno)
# Take a copy of platform incase sys.platform is insufficient and we need more granularity
platform=sys.platform
"""
setup some variables to for Ingres stuff cannot use plain env vars in python variables.
"""
if os.path.expandvars("$II_SYSTEM") == "$II_SYSTEM":
raise SystemExit("Operating system variable II_SYSTEM must be set.")
assert(os.path.expandvars("$II_SYSTEM") != '$II_SYSTEM')
ii_system=os.path.expandvars("$II_SYSTEM")
ii_system_files=ii_system+"/ingres/files"
ii_system_lib=ii_system+"/ingres/lib"
# version of the driver
# change only this value when incrementing the driver level
dbiversion='2.0.1'
dbiversion_str='"""%s"""' % (dbiversion)
filename_txt = 'README.txt'
dest_html = os.path.splitext(filename_txt)[0] + '.html'
if os.path.exists(dest_html) and os.path.getmtime(dest_html) < os.path.getmtime(filename_txt):
os.unlink(dest_html)
if not os.path.exists(dest_html) and publish_cmdline:
print('creating %s' % dest_html)
publish_cmdline(writer_name='html',
argv=[
'--initial-header-level=2',
'--stylesheet-path=ingres_style.css',
filename_txt,
dest_html,
]
)
# Default build flags, libraries, etc.
defmacros=[("DBIVERSION", dbiversion_str)]
libraries=["frame.1", "iiodbc.1", "m", "c"]
if platform.startswith('linux'):
# workaround libq bug where rt is not linked to libq
# odbc needs libq, ingresdbi needs odbc
libraries += ['rt']
# wintel build flags, hopefully the same for amd64 winxp
if platform=="win32":
# Note! May have more defines than we really need.
defmacros=[("IMPORT_DLL_DATA",None),
("_DLL", None),
("_MT", None),
("DESKTOP", None),
("INGRESII", None),
("i386", 1),
("INCLUDE_ALL_CL_PROTOS", None),
("DEVL", None),
("WIN32", None),
("NT_GENERIC", None),
("SQL_BIT_VARYING", 15),
("DBIVERSION",dbiversion_str)
]
# Check to see if this is 64-bit Windows
platform_arch = get_platform()
if platform_arch == "win-amd64":
defmacros.append(("_AMD64_", None))
else:
defmacros.append(("_X86_", None))
libraries=["odbc32","msvcrt","kernel32"]
"""
The "sources" section below could be replaced with a static MANIFEST.IN
file, but at the moment we are leaving all the build logic in one file,
and the MANIFEST file gets created dynamically, by distutils.
The MANIFEST.in is generated semi-dynamically from this script.
Note that if one changes the contents of setup.py, the MANIFEST file
needs to be deleted. Note
also that MANIFEST is a Jam file as well, so Jam needs to be taught to
ignore the pydbi directory entirely.
"""
if os.path.exists('MANIFEST'):
os.unlink('MANIFEST')
MANIFEST_in=open('MANIFEST.in', 'w')
MANIFEST_in.write('recursive-include hdr *.h\n')
MANIFEST_in.write('include CHANGELOG\n')
MANIFEST_in.write('include LICENSE\n')
MANIFEST_in.write('include ingres_style.css\n')
MANIFEST_in.close()
# rest of the source is handled by distutils.code.Extension
# Extension does not handle include files.
ingresdbi=Extension("ingresdbi",
sources=glob("dbi/*.c"),
include_dirs=[ii_system_files,"hdr/"],
define_macros=defmacros,
library_dirs=[ii_system_lib],
libraries=libraries)
setup(
name="ingresdbi",
version=dbiversion,
url="http://ingres.com",
author="Ralph Loen",
author_email="Ralph.Loen@ingres.com",
maintainer="Chris Clark",
maintainer_email="Chris.Clark@ingres.com",
license="GPL",
description="Ingres DBI 2.0 Python Driver",
long_description="""
ingresdbi is a C based interface to the Ingres_ DBMS server,
Ingres Star, Enterprise Access Gateways and EDBC servers. The
interface is compliant with Python database API version 2.0
[PEP-0249].
ingresdbi is licensed under the `GPL v2`_
.. _Ingres: http://www.ingres.com/
.. _`GPL v2`: http://www.gnu.org/licenses/gpl-2.0.html
.. [PEP-0249] http://www.python.org/peps/pep-0249.html""",
ext_modules = ([ingresdbi]),
classifiers=[
'Classifier: Development Status :: 5 - Production/Stable',
'Classifier: Environment :: Other Environment',
'Classifier: License :: OSI Approved :: GNU General Public License (GPL)',
'Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000',
'Classifier: Operating System :: OS Independent',
'Classifier: Operating System :: POSIX',
'Classifier: Operating System :: POSIX :: Linux',
'Classifier: Operating System :: Unix',
'Classifier: Programming Language :: C',
'Classifier: Programming Language :: Python',
'Classifier: Topic :: Database',
'Classifier: Topic :: Database :: Database Engines/Servers',
],
download_url="http://ingres.com/",
cmdclass = {'test': TestSuite},
),
# -*- coding: ascii -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab