From f182b5e2f6e492cd13eed98d7f248d4146456d8c Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 16 Sep 2021 14:57:08 -0500 Subject: [PATCH 1/2] Split CC to make sure we get the correct basename of the compiler --- distutils/tests/test_unixccompiler.py | 8 ++++++++ distutils/unixccompiler.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/distutils/tests/test_unixccompiler.py b/distutils/tests/test_unixccompiler.py index ebd7c161e0..fb9ac03224 100644 --- a/distutils/tests/test_unixccompiler.py +++ b/distutils/tests/test_unixccompiler.py @@ -140,6 +140,14 @@ def gcv(v): sysconfig.get_config_var = gcv self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo') + def gcv(v): + if v == 'CC': + return 'gcc -pthread -B /bar' + elif v == 'GNULD': + return 'yes' + sysconfig.get_config_var = gcv + self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo') + # GCC non-GNULD sys.platform = 'bar' def gcv(v): diff --git a/distutils/unixccompiler.py b/distutils/unixccompiler.py index f51977a5ae..c6f1f0d66a 100644 --- a/distutils/unixccompiler.py +++ b/distutils/unixccompiler.py @@ -231,7 +231,7 @@ def runtime_library_dir_option(self, dir): # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. - compiler = os.path.basename(sysconfig.get_config_var("CC")) + compiler = os.path.basename(sysconfig.get_config_var("CC").split(" ")[0]) if sys.platform[:6] == "darwin": from distutils.util import get_macosx_target_ver, split_version macosx_target_ver = get_macosx_target_ver() From c51dc8c8e970c012c7c841f30e576c5a343e02e1 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 21 Sep 2021 12:21:33 -0500 Subject: [PATCH 2/2] Use shlex Co-authored-by: "Jason R. Coombs" --- distutils/unixccompiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distutils/unixccompiler.py b/distutils/unixccompiler.py index c6f1f0d66a..349cc1642b 100644 --- a/distutils/unixccompiler.py +++ b/distutils/unixccompiler.py @@ -13,7 +13,7 @@ * link shared library handled by 'cc -shared' """ -import os, sys, re +import os, sys, re, shlex from distutils import sysconfig from distutils.dep_util import newer @@ -231,7 +231,7 @@ def runtime_library_dir_option(self, dir): # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. - compiler = os.path.basename(sysconfig.get_config_var("CC").split(" ")[0]) + compiler = os.path.basename(shlex.split(sysconfig.get_config_var("CC"))[0]) if sys.platform[:6] == "darwin": from distutils.util import get_macosx_target_ver, split_version macosx_target_ver = get_macosx_target_ver()