1
1
# MySQL Connector/Python - MySQL driver written in Python.
2
- # Copyright (c) 2014, 2015 , Oracle and/or its affiliates. All rights reserved.
2
+ # Copyright (c) 2014, 2016 , Oracle and/or its affiliates. All rights reserved.
3
3
4
4
# MySQL Connector/Python is licensed under the terms of the GPLv2
5
5
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -125,7 +125,11 @@ def unix_lib_is64bit(lib_file):
125
125
lib_file = mysqlclient_libs [- 1 ]
126
126
127
127
log .debug ("# Using file command to test lib_file {0}" .format (lib_file ))
128
- prc = Popen (['file' , '-L' , lib_file ], stdin = PIPE , stderr = STDOUT ,
128
+ if platform .uname () == 'SunOS' :
129
+ cmd_list = ['file' , '-L' , lib_file ]
130
+ else :
131
+ cmd_list = ['file' , '-L' , lib_file ]
132
+ prc = Popen (cmd_list , stdin = PIPE , stderr = STDOUT ,
129
133
stdout = PIPE )
130
134
stdout = prc .communicate ()[0 ]
131
135
stdout = stdout .split (':' )[1 ]
@@ -166,6 +170,9 @@ def get_mysql_config_info(mysql_config):
166
170
libs = shlex .split (info ['libs' ])
167
171
info ['lib_dir' ] = libs [0 ].replace ('-L' , '' )
168
172
info ['libs' ] = [ lib .replace ('-l' , '' ) for lib in libs [1 :] ]
173
+ if platform .uname ()[0 ] == 'SunOS' :
174
+ info ['lib_dir' ] = info ['lib_dir' ].replace ('-R' , '' )
175
+ info ['libs' ] = [lib .replace ('-R' , '' ) for lib in info ['libs' ]]
169
176
log .debug ("# info['libs']: " )
170
177
for lib in info ['libs' ]:
171
178
log .debug ("# {0}" .format (lib ))
@@ -178,7 +185,17 @@ def get_mysql_config_info(mysql_config):
178
185
# Try to figure out the architecture
179
186
info ['arch' ] = None
180
187
if os .name == 'posix' :
181
- pathname = os .path .join (info ['lib_dir' ], 'lib' + info ['libs' ][0 ]) + '*'
188
+ if platform .uname ()[0 ] == 'SunOS' :
189
+ print ("info['lib_dir']: {0}" .format (info ['lib_dir' ]))
190
+ print ("info['libs'][0]: {0}" .format (info ['libs' ][0 ]))
191
+ pathname = os .path .abspath (os .path .join (info ['lib_dir' ],
192
+ 'lib' ,
193
+ info ['libs' ][0 ])) + '/*'
194
+ else :
195
+ pathname = os .path .join (info ['lib_dir' ],
196
+ 'lib' + info ['libs' ][0 ]) + '*'
197
+ print ("# Looking mysqlclient_lib at path: {0}" .format (pathname ))
198
+ log .debug ("# searching mysqlclient_lib at: %s" , pathname )
182
199
libs = glob (pathname )
183
200
mysqlclient_libs = []
184
201
for filepath in libs :
@@ -198,7 +215,12 @@ def get_mysql_config_info(mysql_config):
198
215
log .debug ("#+ {0}" .format (mysqlclient_lib ))
199
216
log .debug ("# tested mysqlclient_lib[-1]: "
200
217
"{0}" .format (mysqlclient_libs [- 1 ]))
201
- proc = Popen (['file' , '-L' , mysqlclient_libs [- 1 ]], stdout = PIPE ,
218
+ if platform .uname ()[0 ] == 'SunOS' :
219
+ print ("mysqlclient_lib: {0}" .format (mysqlclient_libs [- 1 ]))
220
+ cmd_list = ['file' , mysqlclient_libs [- 1 ]]
221
+ else :
222
+ cmd_list = ['file' , '-L' , mysqlclient_libs [- 1 ]]
223
+ proc = Popen (cmd_list , stdout = PIPE ,
202
224
universal_newlines = True )
203
225
stdout , _ = proc .communicate ()
204
226
stdout = stdout .split (':' )[1 ]
@@ -360,9 +382,9 @@ def _finalize_connector_c(self, connc_loc):
360
382
# We try to offer a nice message when the architecture of Python
361
383
# is not the same as MySQL Connector/C binaries.
362
384
py_arch = '64-bit' if ARCH_64BIT else '32-bit'
363
- log . debug ("# Python architecture: {0}" .format (py_arch ))
364
- log . debug ("# Python ARCH_64BIT: {0}" .format (ARCH_64BIT ))
365
- log . debug ("# self.arch: {0}" .format (self .arch ))
385
+ print ("# Python architecture: {0}" .format (py_arch ))
386
+ print ("# Python ARCH_64BIT: {0}" .format (ARCH_64BIT ))
387
+ print ("# self.arch: {0}" .format (self .arch ))
366
388
if ARCH_64BIT != connc_64bit :
367
389
log .error ("Python is {0}, but does not "
368
390
"match MySQL C API {1} architecture, "
0 commit comments