Skip to content

Commit 7945d61

Browse files
committed
Remove OpenSSL linkage in the C extension
1 parent c590ca5 commit 7945d61

File tree

2 files changed

+2
-79
lines changed

2 files changed

+2
-79
lines changed

cpyint

lib/cpy_distutils.py

Lines changed: 1 addition & 78 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, 2017, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2018, 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
@@ -295,57 +295,6 @@ def initialize_options(self):
295295
self.extra_link_args = None
296296
self.with_mysql_capi = None
297297

298-
def _get_posix_openssl_libs(self):
299-
openssl_libs = []
300-
try:
301-
openssl_libs_path = os.path.join(self.with_mysql_capi, "lib")
302-
openssl_libs.extend([
303-
os.path.basename(glob(
304-
os.path.join(openssl_libs_path, "libssl.*.*.*"))[0]),
305-
os.path.basename(glob(
306-
os.path.join(openssl_libs_path, "libcrypto.*.*.*"))[0])
307-
])
308-
except IndexError:
309-
log.error("Couldn't find OpenSSL libraries in libmysqlclient")
310-
return openssl_libs
311-
312-
def _copy_vendor_libraries(self):
313-
if not self.with_mysql_capi or self.distribution.data_files:
314-
return
315-
316-
data_files = []
317-
vendor_libs = []
318-
319-
if os.name == "nt":
320-
mysql_capi = os.path.join(self.with_mysql_capi, "bin")
321-
vendor_libs.append((mysql_capi, ["ssleay32.dll", "libeay32.dll"]))
322-
vendor_folder = ""
323-
# Bundle libmysql.dll
324-
src = os.path.join(self.with_mysql_capi, "lib", "libmysql.dll")
325-
dst = os.getcwd()
326-
log.info("copying {0} -> {1}".format(src, dst))
327-
shutil.copy(src, dst)
328-
data_files.append("libmysql.dll")
329-
else:
330-
mysql_capi = os.path.join(self.with_mysql_capi, "lib")
331-
vendor_libs.append((mysql_capi, self._get_posix_openssl_libs()))
332-
vendor_folder = "mysql-vendor"
333-
334-
if vendor_folder:
335-
mkpath(os.path.join(os.getcwd(), vendor_folder))
336-
337-
# Copy vendor libraries to 'mysql-vendor' folder
338-
log.info("Copying vendor libraries")
339-
for src_folder, files in vendor_libs:
340-
for filename in files:
341-
data_files.append(os.path.join(vendor_folder, filename))
342-
src = os.path.join(src_folder, filename)
343-
dst = os.path.join(os.getcwd(), vendor_folder)
344-
log.info("copying {0} -> {1}".format(src, dst))
345-
shutil.copy(src, dst)
346-
# Add data_files to distribution
347-
self.distribution.data_files = [(vendor_folder, data_files)]
348-
349298
def _finalize_connector_c(self, connc_loc):
350299
"""Finalize the --with-connector-c command line argument
351300
"""
@@ -469,8 +418,6 @@ def finalize_options(self):
469418
('extra_link_args', 'extra_link_args'),
470419
('with_mysql_capi', 'with_mysql_capi'))
471420

472-
self._copy_vendor_libraries()
473-
474421
build_ext.finalize_options(self)
475422

476423
print("# Python architecture: {0}".format(py_arch))
@@ -524,8 +471,6 @@ def fix_compiler(self):
524471
# Add extra link args
525472
if self.extra_link_args and ext.name == "_mysql_connector":
526473
extra_link_args = self.extra_link_args.split()
527-
if platform.system() == "Linux":
528-
extra_link_args += ["-Wl,-rpath,$ORIGIN/mysql-vendor"]
529474
ext.extra_link_args.extend(extra_link_args)
530475
# Add system headers
531476
for sysheader in sysheaders:
@@ -558,26 +503,6 @@ def run(self):
558503
self.fix_compiler()
559504
self.real_build_extensions()
560505

561-
if platform.system() == "Darwin":
562-
libssl, libcrypto = self._get_posix_openssl_libs()
563-
cmd_libssl = [
564-
"install_name_tool", "-change", libssl,
565-
"@loader_path/mysql-vendor/{0}".format(libssl),
566-
build_ext.get_ext_fullpath(self, "_mysql_connector")
567-
]
568-
log.info("Executing: {0}".format(" ".join(cmd_libssl)))
569-
proc = Popen(cmd_libssl, stdout=PIPE, universal_newlines=True)
570-
stdout, _ = proc.communicate()
571-
572-
cmd_libcrypto = [
573-
"install_name_tool", "-change", libcrypto,
574-
"@loader_path/mysql-vendor/{0}".format(libcrypto),
575-
build_ext.get_ext_fullpath(self, "_mysql_connector")
576-
]
577-
log.info("Executing: {0}".format(" ".join(cmd_libcrypto)))
578-
proc = Popen(cmd_libcrypto, stdout=PIPE, universal_newlines=True)
579-
stdout, _ = proc.communicate()
580-
581506

582507
class BuildExtStatic(BuildExtDynamic):
583508

@@ -586,8 +511,6 @@ class BuildExtStatic(BuildExtDynamic):
586511
user_options = build_ext.user_options + CEXT_OPTIONS
587512

588513
def finalize_options(self):
589-
self._copy_vendor_libraries()
590-
591514
install_obj = self.distribution.get_command_obj('install')
592515
install_obj.with_mysql_capi = self.with_mysql_capi
593516
install_obj.extra_compile_args = self.extra_compile_args

0 commit comments

Comments
 (0)