This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Michael.Felt
Recipients Michael.Felt, dstufft, eric.araujo
Date 2018-10-04.20:22:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538684546.1.0.545547206417.issue34897@psf.upfronthosting.co.za>
In-reply-to
Content
while researching issue11191 I cam across 6 additional errors.

There is a test in Lib/test/support/__init__.py

def missing_compiler_executable(cmd_names=[]):
    """Check if the compiler components used to build the interpreter exist.

    Check for the existence of the compiler executables whose names are listed
    in 'cmd_names' or all the compiler executables when 'cmd_names' is empty
    and return the first missing executable or None when none is found
    missing.

    """
    from distutils import ccompiler, sysconfig, spawn
    compiler = ccompiler.new_compiler()
    sysconfig.customize_compiler(compiler)
    for name in compiler.executables:
        if cmd_names and name not in cmd_names:
            continue
        cmd = getattr(compiler, name)
        if cmd_names:
            assert cmd is not None, \
                    "the '%s' executable is not configured" % name
        elif cmd is None:
            continue
        if spawn.find_executable(cmd[0]) is None:
            return cmd[0]

The "elif cmd is None:" is not successful because cmd maybe '' (null string)

Initially I thought to change to
"elif cmd is None or (not cmd):" but I hope I found a better resolution!

In: Lib/distutils/sysconfig.py the final bits of customize_compiler is:

        compiler.set_executables(
            preprocessor=cpp,
            compiler=cc_cmd,
            compiler_so=cc_cmd + ' ' + ccshared,
            compiler_cxx=cxx,
            linker_so=ldshared,
            linker_exe=cc,
            archiver=archiver)

the value for cxx come from os.environ, if set, otherwise it comes from get_sys_vars()

        (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
                            'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')

If, during the build, CXX was not set - this sets cxx to the null string ('').

So the fix is to assign cxx = None when len(cxx) == 0

        if 'CXX' in os.environ:
            cxx = os.environ['CXX']
        if not len(cxx):
            cxx = None

While this only seems to happen for cxx - maybe this should be extended to all the variables in (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags)?

So, ultimately - I choose to go with changing : compiler.set_executables()

diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index b71d1d39bc..2e08c4abd2 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -148,7 +148,7 @@ class CCompiler:
             if key not in self.executables:
                 raise ValueError("unknown executable '%s' for class %s" %
                       (key, self.__class__.__name__))
-            self.set_executable(key, kwargs[key])
+            self.set_executable(key, kwargs[key] if len(kwargs[key]) else None)

     def set_executable(self, key, value):
         if isinstance(value, str):



Was:
======================================================================
ERROR: test_run (distutils.tests.test_build_clib.BuildCLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_build_clib.py", line 121, in test_run
    ccmd = missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range

======================================================================
ERROR: test_build_ext (distutils.tests.test_build_ext.BuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_build_ext.py", line 62, in test_build_ext
    cmd = support.missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range

======================================================================
ERROR: test_get_outputs (distutils.tests.test_build_ext.BuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_build_ext.py", line 308, in test_get_outputs
    cmd = support.missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range

======================================================================
ERROR: test_build_ext (distutils.tests.test_build_ext.ParallelBuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_build_ext.py", line 62, in test_build_ext
    cmd = support.missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range

======================================================================
ERROR: test_get_outputs (distutils.tests.test_build_ext.ParallelBuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_build_ext.py", line 308, in test_get_outputs
    cmd = support.missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range

======================================================================
ERROR: test_record_extensions (distutils.tests.test_install.InstallTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/prj/python/git/python3-3.8/Lib/distutils/tests/test_install.py", line 200, in test_record_extensions
    cmd = test_support.missing_compiler_executable()
  File "/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py", line 2730, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
IndexError: list index out of range
History
Date User Action Args
2018-10-04 20:22:26Michael.Feltsetrecipients: + Michael.Felt, eric.araujo, dstufft
2018-10-04 20:22:26Michael.Feltsetmessageid: <1538684546.1.0.545547206417.issue34897@psf.upfronthosting.co.za>
2018-10-04 20:22:26Michael.Feltlinkissue34897 messages
2018-10-04 20:22:25Michael.Feltcreate