FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
dmPython/setup.py at main · DamengDB/dmPython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DamengDB
/
dmPython
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
7
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
dmPython
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
338 lines (296 loc) · 12.9 KB
Breadcrumbs
dmPython
/
setup.py
Copy path
File metadata and controls
338 lines (296 loc) · 12.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
"""Distutils script for dmPython.
python setup.py build install
"""
import
sys
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
import
distutils
.
command
try
:
import
distutils
.
command
.
bdist_msi
except
ImportError
:
distutils
.
command
.
bdist_msi
=
None
try
:
import
distutils
.
command
.
bdist_wininst
except
ImportError
:
distutils
.
command
.
bdist_wininst
=
None
import
distutils
.
command
.
bdist_rpm
import
distutils
.
command
.
build
import
distutils
.
core
import
distutils
.
dist
import
distutils
.
util
import
os
import
re
import
struct
import
sysconfig
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
from
distutils
.
errors
import
DistutilsSetupError
as
SetupError
else
:
from
setuptools
.
errors
import
SetupError
# if setuptools is detected, use it to add support for eggs
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
try
:
from
setuptools
import
setup
,
Extension
except
:
from
distutils
.
core
import
setup
from
distutils
.
extension
import
Extension
else
:
from
setuptools
import
setup
,
Extension
# define build constants
BUILD_VERSION
=
"2.5.38"
dm_version
=
os
.
environ
.
get
(
"DM_VER"
)
if
dm_version
is
not
None
:
DAMENG_VERSION
=
dm_version
else
:
DAMENG_VERSION
=
"8.1"
# method for checking a potential Dameng home
def
CheckDmHome
(
directoryToCheck
):
global
dmHome
,
dmLibDir
if
sys
.
platform
in
(
"win32"
,
"cygwin"
):
if
sys
.
version_info
[:
2
]
>
(
3
,
7
):
str_pthtemp
=
str
(
sysconfig
.
get_paths
()[
"purelib"
])
+
'
\\
dmPython.pth'
file
=
open
(
str_pthtemp
,
'w'
)
write_pthstr
=
'import dpi'
file
.
write
(
write_pthstr
)
file
.
close
()
if
struct
.
calcsize
(
"P"
)
==
4
:
subDirs
=
[
"bin"
,
"debug"
,
"release"
,
"dpi"
]
else
:
subDirs
=
[
"bin"
,
"x64/debug"
,
"x64/release"
,
"dpi"
]
filesToCheck
=
[
"dmdpi.dll"
]
elif
sys
.
platform
==
"darwin"
:
subDirs
=
[
"bin"
]
filesToCheck
=
[
"libdmdpi"
]
else
:
subDirs
=
[
"bin"
,
"build/linux/linux_build/debug"
,
"build/linux/linux_build/release"
,
"dpi"
]
filesToCheck
=
[
"libdmdpi.so"
]
for
baseFileName
in
filesToCheck
:
fileName
=
os
.
path
.
join
(
directoryToCheck
,
baseFileName
)
if
os
.
path
.
exists
(
fileName
):
if
os
.
path
.
basename
(
directoryToCheck
).
lower
()
==
"bin"
:
dmHome
=
os
.
path
.
dirname
(
directoryToCheck
)
else
:
dmHome
=
directoryToCheck
dmLibDir
=
directoryToCheck
if
sys
.
platform
in
(
"win32"
,
"cygwin"
):
if
sys
.
version_info
[:
2
]
>
(
3
,
7
):
str_pytemp
=
str
(
sysconfig
.
get_paths
()[
"purelib"
])
+
'
\\
dpi.py'
file
=
open
(
str_pytemp
,
'w'
)
write_pystr
=
'import os
\n
os.add_dll_directory(r
\'
'
+
dmLibDir
+
'
\'
)'
file
.
write
(
write_pystr
)
file
.
close
()
return
True
for
subDir
in
subDirs
:
fileName
=
os
.
path
.
join
(
directoryToCheck
,
subDir
,
baseFileName
)
if
os
.
path
.
exists
(
fileName
):
dmHome
=
directoryToCheck
dmLibDir
=
os
.
path
.
join
(
directoryToCheck
,
subDir
)
if
sys
.
platform
in
(
"win32"
,
"cygwin"
):
if
sys
.
version_info
[:
2
]
>
(
3
,
7
):
str_pytemp
=
str
(
sysconfig
.
get_paths
()[
"purelib"
])
+
'
\\
dpi.py'
file
=
open
(
str_pytemp
,
'w'
)
write_pystr
=
'import os
\n
os.add_dll_directory(r
\'
'
+
dmLibDir
+
'
\'
)'
file
.
write
(
write_pystr
)
file
.
close
()
return
True
for
subDir
in
subDirs
:
dirName
=
os
.
path
.
dirname
(
directoryToCheck
)
fileName
=
os
.
path
.
join
(
dirName
,
subDir
,
baseFileName
)
if
os
.
path
.
exists
(
fileName
):
dmHome
=
dirName
dmLibDir
=
os
.
path
.
join
(
dirName
,
subDir
)
if
sys
.
platform
in
(
"win32"
,
"cygwin"
):
if
sys
.
version_info
[:
2
]
>
(
3
,
7
):
str_pytemp
=
str
(
sysconfig
.
get_paths
()[
"purelib"
])
+
'
\\
dpi.py'
file
=
open
(
str_pytemp
,
'w'
)
write_pystr
=
'import os
\n
os.add_dll_directory(r
\'
'
+
dmLibDir
+
'
\'
)'
file
.
write
(
write_pystr
)
file
.
close
()
return
True
dmHome
=
dmLibDir
=
None
return
False
# try to determine the Dameng home
userDmHome
=
os
.
environ
.
get
(
"DM_HOME"
)
if
userDmHome
is
not
None
:
if
not
CheckDmHome
(
userDmHome
):
messageFormat
=
"Dameng home (%s) does not refer to an "
\
"DM%s installation or dmdpi library missing."
raise
SetupError
(
messageFormat
%
(
userDmHome
,
DAMENG_VERSION
))
else
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
if
CheckDmHome
(
path
):
break
if
dmHome
is
None
:
raise
SetupError
(
"cannot locate an Dameng software "
\
"installation"
)
# define some variables
if
sys
.
platform
==
"win32"
:
libDirs
=
[
dmLibDir
,
os
.
path
.
join
(
dmHome
,
"include"
)]
possibleIncludeDirs
=
[
"python/dmPython_C/dmPython"
,
"include"
,
"dpi/src/include"
,
"drivers/python/dmPython"
,
"dpi/include"
]
includeDirs
=
[]
for
dir1
in
possibleIncludeDirs
:
path
=
os
.
path
.
normpath
(
os
.
path
.
join
(
dmHome
,
dir1
))
if
os
.
path
.
isdir
(
path
):
includeDirs
.
append
(
path
)
if
not
includeDirs
:
message
=
"cannot locate Dameng include files in %s"
%
dmHome
raise
SetupError
(
message
)
libs
=
[
"dmdpi"
]
else
:
libDirs
=
[
dmLibDir
]
libs
=
[
"dmdpi"
]
possibleIncludeDirs
=
[
"python/dmPython_C/dmPython"
,
"include"
,
"dpi/src/include"
,
"drivers/python/dmPython"
,
"dpi/include"
]
includeDirs
=
[]
for
dir
in
possibleIncludeDirs
:
path
=
os
.
path
.
join
(
dmHome
,
dir
)
if
os
.
path
.
isdir
(
path
):
includeDirs
.
append
(
path
)
if
not
includeDirs
:
raise
SetupError
(
"cannot locate Dameng include files"
)
# setup extra link and compile args
extraCompileArgs
=
[
"-DBUILD_VERSION=%s"
%
BUILD_VERSION
]
extraLinkArgs
=
[]
# extension Macros definition if on 64bit platform,add DM64,othersise use default [defineMacros].
defineMacros
=
[]
if
struct
.
calcsize
(
"P"
)
==
4
:
defineMacros
=
[]
else
:
defineMacros
=
[(
'DM64'
,
None
),]
if
sys
.
platform
==
"win32"
:
defineMacros
.
append
((
'WIN32'
,
None
))
defineMacros
.
append
((
'_CRT_SECURE_NO_WARNINGS'
,
None
))
#extension Macro TRACE if a dmPython_trace.log needed in current directory.
#defineMacros.append(('TRACE', None))
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
# tweak distribution full name to include the Dameng version
class
Distribution
(
distutils
.
dist
.
Distribution
):
def
get_fullname_with_dameng_version
(
self
):
name
=
self
.
metadata
.
get_fullname
()
return
"%s-%s"
%
(
name
,
DAMENG_VERSION
)
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
# tweak the RPM build command to include the Python and Dameng version
class
bdist_rpm
(
distutils
.
command
.
bdist_rpm
.
bdist_rpm
):
def
run
(
self
):
distutils
.
command
.
bdist_rpm
.
bdist_rpm
.
run
(
self
)
specFile
=
os
.
path
.
join
(
self
.
rpm_base
,
"SPECS"
,
"%s.spec"
%
self
.
distribution
.
get_name
())
queryFormat
=
"%{name}-%{version}-%{release}.%{arch}.rpm"
command
=
"rpm -q --qf '%s' --specfile %s"
%
(
queryFormat
,
specFile
)
origFileName
=
os
.
popen
(
command
).
read
()
names
=
origFileName
.
split
(
"rpm"
)
for
origFileName
in
names
:
if
len
(
origFileName
)
>
0
:
origFileName
+=
"rpm"
parts
=
origFileName
.
split
(
"-"
)
parts
.
insert
(
2
,
DAMENG_VERSION
)
parts
.
insert
(
3
,
"py%s%s"
%
sys
.
version_info
[:
2
])
newFileName
=
"-"
.
join
(
parts
)
self
.
move_file
(
os
.
path
.
join
(
"dist"
,
origFileName
),
os
.
path
.
join
(
"dist"
,
newFileName
))
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
# tweak the build directories to include the Dameng version
class
build
(
distutils
.
command
.
build
.
build
):
def
finalize_options
(
self
):
import
distutils
.
util
import
os
import
sys
platSpecifier
=
".%s-%s"
%
\
(
distutils
.
util
.
get_platform
(),
sys
.
version
[
0
:
3
])
if
self
.
build_platlib
is
None
:
self
.
build_platlib
=
os
.
path
.
join
(
self
.
build_base
,
"lib%s"
%
platSpecifier
)
if
self
.
build_temp
is
None
:
self
.
build_temp
=
os
.
path
.
join
(
self
.
build_base
,
"temp%s"
%
platSpecifier
)
distutils
.
command
.
build
.
build
.
finalize_options
(
self
)
class
test
(
distutils
.
core
.
Command
):
description
=
"run the test suite for the extension"
user_options
=
[]
def
finalize_options
(
self
):
pass
def
initialize_options
(
self
):
pass
def
run
(
self
):
self
.
run_command
(
"build"
)
buildCommand
=
self
.
distribution
.
get_command_obj
(
"build"
)
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
"test"
))
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
buildCommand
.
build_lib
))
if
sys
.
version_info
[
0
]
<
3
:
execfile
(
os
.
path
.
join
(
"test"
,
"test.py"
))
else
:
fileName
=
os
.
path
.
join
(
"test"
,
"test3k.py"
)
exec
(
open
(
fileName
).
read
())
commandClasses
=
dict
(
build
=
build
,
bdist_rpm
=
bdist_rpm
,
test
=
test
)
# tweak the Windows installer names to include the Dameng version
if
distutils
.
command
.
bdist_msi
is
not
None
:
class
bdist_msi
(
distutils
.
command
.
bdist_msi
.
bdist_msi
):
def
run
(
self
):
origMethod
=
self
.
distribution
.
get_fullname
self
.
distribution
.
get_fullname
=
\
self
.
distribution
.
get_fullname_with_dameng_version
distutils
.
command
.
bdist_msi
.
bdist_msi
.
run
(
self
)
self
.
distribution
.
get_fullname
=
origMethod
commandClasses
[
"bdist_msi"
]
=
bdist_msi
if
distutils
.
command
.
bdist_wininst
is
not
None
:
class
bdist_wininst
(
distutils
.
command
.
bdist_wininst
.
bdist_wininst
):
def
run
(
self
):
origMethod
=
self
.
distribution
.
get_fullname
self
.
distribution
.
get_fullname
=
\
self
.
distribution
.
get_fullname_with_dameng_version
distutils
.
command
.
bdist_wininst
.
bdist_wininst
.
run
(
self
)
self
.
distribution
.
get_fullname
=
origMethod
commandClasses
[
"bdist_wininst"
]
=
bdist_wininst
# define classifiers for the package index
classifiers
=
[
"Development Status :: 6 - Mature"
,
"Intended Audience :: Developers"
,
"Natural Language :: English"
,
"Operating System :: OS Independent"
,
"Programming Language :: C"
,
"Programming Language :: Python"
,
"Programming Language :: Python :: 2"
,
"Programming Language :: Python :: 3"
,
"Topic :: Database"
]
# setup the extension
extension
=
Extension
(
name
=
"dmPython"
,
include_dirs
=
includeDirs
,
libraries
=
libs
,
library_dirs
=
libDirs
,
extra_compile_args
=
extraCompileArgs
,
extra_link_args
=
extraLinkArgs
,
sources
=
[
'py_Dameng.c'
,
'row.c'
,
'Cursor.c'
,
'Connection.c'
,
'Environment.c'
,
'Error.c'
,
'Buffer.c'
,
'exLob.c'
,
'exObject.c'
,
'tObject.c'
,
'var.c'
,
'vCursor.c'
,
'vDateTime.c'
,
'vInterval.c'
,
'vLob.c'
,
'vNumber.c'
,
'vObject.c'
,
'vString.c'
,
'vlong.c'
,
'exBfile.c'
,
'vBfile.c'
,
'trc.c'
],
depends
=
[],
define_macros
=
defineMacros
)
if
sys
.
version_info
[:
2
]
<
(
3
,
12
):
# perform the setup
setup
(
name
=
"dmPython"
,
version
=
BUILD_VERSION
,
distclass
=
Distribution
,
description
=
"Python interface to Dameng"
,
cmdclass
=
commandClasses
,
long_description
=
\
"Python interface to Dameng conforming to the Python DB API 2.0 "
"specification.
\n
"
"See http://www.python.org/topics/database/DatabaseAPI-2.0.html."
,
ext_modules
=
[
extension
],
keywords
=
"Dameng"
,
license
=
"Python Software Foundation License"
,
classifiers
=
classifiers
,
data_files
=
[(
""
, [
"dmPython.pyi"
])])
else
:
setup
(
name
=
"dmPython"
,
version
=
BUILD_VERSION
,
description
=
"Python interface to Dameng"
,
long_description
=
\
"Python interface to Dameng conforming to the Python DB API 2.0 "
"specification.
\n
"
"See http://www.python.org/topics/database/DatabaseAPI-2.0.html."
,
ext_modules
=
[
extension
],
keywords
=
"Dameng"
,
license
=
"Python Software Foundation License"
,
classifiers
=
classifiers
,
data_files
=
[(
"Lib
\\
site-packages"
, [
"dmPython.pyi"
])])
Back
|
FazBrowse Home
|
New Git URL