Skip to content

Commit 51a286e

Browse files
committed
BUG24422244: Add custom SunOS package mechanism
1 parent 14abc19 commit 51a286e

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

lib/cpy_distutils.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -125,7 +125,11 @@ def unix_lib_is64bit(lib_file):
125125
lib_file = mysqlclient_libs[-1]
126126

127127
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,
129133
stdout=PIPE)
130134
stdout = prc.communicate()[0]
131135
stdout = stdout.split(':')[1]
@@ -166,6 +170,9 @@ def get_mysql_config_info(mysql_config):
166170
libs = shlex.split(info['libs'])
167171
info['lib_dir'] = libs[0].replace('-L', '')
168172
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']]
169176
log.debug("# info['libs']: ")
170177
for lib in info['libs']:
171178
log.debug("# {0}".format(lib))
@@ -178,7 +185,17 @@ def get_mysql_config_info(mysql_config):
178185
# Try to figure out the architecture
179186
info['arch'] = None
180187
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)
182199
libs = glob(pathname)
183200
mysqlclient_libs = []
184201
for filepath in libs:
@@ -198,7 +215,12 @@ def get_mysql_config_info(mysql_config):
198215
log.debug("#+ {0}".format(mysqlclient_lib))
199216
log.debug("# tested mysqlclient_lib[-1]: "
200217
"{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,
202224
universal_newlines=True)
203225
stdout, _ = proc.communicate()
204226
stdout = stdout.split(':')[1]
@@ -360,9 +382,9 @@ def _finalize_connector_c(self, connc_loc):
360382
# We try to offer a nice message when the architecture of Python
361383
# is not the same as MySQL Connector/C binaries.
362384
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))
366388
if ARCH_64BIT != connc_64bit:
367389
log.error("Python is {0}, but does not "
368390
"match MySQL C API {1} architecture, "

0 commit comments

Comments
 (0)