Skip to content

Tests fail on Python 3.8.10 where MACOSX_DEPLOYMENT_TARGET=11 #100

Closed
@jaraco

Description

@jaraco

I'm running macOS 12.1. On this mac, the tests all pass except for on Python 3.8, the tests fail thus:

py38 installed: attrs==21.4.0,iniconfig==1.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.6,pytest==6.2.5,toml==0.10.2
py38 run-test-pre: PYTHONHASHSEED='2088384509'
py38 run-test: commands[0] | pytest
============================= test session starts ==============================
platform darwin -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
cachedir: .tox/py38/.pytest_cache
rootdir: /Users/jaraco/code/public/pypa/distutils, configfile: pytest.ini
collected 296 items

distutils/versionpredicate.py ..                                         [  0%]
distutils/command/sdist.py .                                             [  1%]
distutils/tests/test_archive_util.py ....................                [  7%]
distutils/tests/test_bdist.py ...                                        [  8%]
distutils/tests/test_bdist_dumb.py ..                                    [  9%]
distutils/tests/test_bdist_msi.py s.                                     [ 10%]
distutils/tests/test_bdist_rpm.py ss.                                    [ 11%]
distutils/tests/test_bdist_wininst.py s.                                 [ 11%]
distutils/tests/test_build.py ..                                         [ 12%]
distutils/tests/test_build_clib.py ......                                [ 14%]
distutils/tests/test_build_ext.py s..FFF........s..FFF.........          [ 24%]
distutils/tests/test_build_py.py .......                                 [ 26%]
distutils/tests/test_build_scripts.py ....                               [ 28%]
distutils/tests/test_check.py .s.ss.                                     [ 30%]
distutils/tests/test_clean.py ..                                         [ 30%]
distutils/tests/test_cmd.py ........                                     [ 33%]
distutils/tests/test_config.py ....                                      [ 34%]
distutils/tests/test_config_cmd.py .....                                 [ 36%]
distutils/tests/test_core.py ........                                    [ 39%]
distutils/tests/test_cygwinccompiler.py ...                              [ 40%]
distutils/tests/test_dep_util.py ....                                    [ 41%]
distutils/tests/test_dir_util.py ........                                [ 44%]
distutils/tests/test_dist.py ........s......................             [ 54%]
distutils/tests/test_extension.py ...                                    [ 55%]
distutils/tests/test_file_util.py ......                                 [ 57%]
distutils/tests/test_filelist.py ..............                          [ 62%]
distutils/tests/test_install.py .....s..                                 [ 65%]
distutils/tests/test_install_data.py ..                                  [ 65%]
distutils/tests/test_install_headers.py ..                               [ 66%]
distutils/tests/test_install_lib.py ......                               [ 68%]
distutils/tests/test_install_scripts.py ...                              [ 69%]
distutils/tests/test_log.py ..                                           [ 70%]
distutils/tests/test_msvc9compiler.py ssss.                              [ 71%]
distutils/tests/test_msvccompiler.py ssss...                             [ 74%]
distutils/tests/test_register.py .....s..s.                              [ 77%]
distutils/tests/test_sdist.py ......s.........                           [ 83%]
distutils/tests/test_spawn.py ....                                       [ 84%]
distutils/tests/test_sysconfig.py ...........s.s..                       [ 89%]
distutils/tests/test_text_file.py ..                                     [ 90%]
distutils/tests/test_unixccompiler.py .....                              [ 92%]
distutils/tests/test_upload.py .......                                   [ 94%]
distutils/tests/test_util.py ...........                                 [ 98%]
distutils/tests/test_version.py ....                                     [ 99%]
distutils/tests/test_versionpredicate.py .                               [100%]

=================================== FAILURES ===================================
_______________ BuildExtTestCase.test_deployment_target_default ________________

self = <distutils.tests.test_build_ext.BuildExtTestCase testMethod=test_deployment_target_default>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_default(self):
        # Issue 9516: Test that, in the absence of the environment variable,
        # an extension module is compiled with the same deployment target as
        #  the interpreter.
>       self._try_compile_deployment_target('==', None)

distutils/tests/test_build_ext.py:442: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <distutils.tests.test_build_ext.BuildExtTestCase testMethod=test_deployment_target_default>
operator = '==', target = (11,)

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
______________ BuildExtTestCase.test_deployment_target_higher_ok _______________

self = <distutils.tests.test_build_ext.BuildExtTestCase testMethod=test_deployment_target_higher_ok>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_higher_ok(self):
        # Issue 9516: Test that an extension module can be compiled with a
        # deployment target higher than that of the interpreter: the ext
        # module may depend on some newer OS feature.
        deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        if deptarget:
            # increment the minor version number (i.e. 10.6 -> 10.7)
            deptarget = [int(x) for x in deptarget.split('.')]
            deptarget[-1] += 1
            deptarget = '.'.join(str(i) for i in deptarget)
>           self._try_compile_deployment_target('<', deptarget)

distutils/tests/test_build_ext.py:462: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <distutils.tests.test_build_ext.BuildExtTestCase testMethod=test_deployment_target_higher_ok>
operator = '<', target = (11,)

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
_______________ BuildExtTestCase.test_deployment_target_too_low ________________

self = <distutils.tests.test_build_ext.BuildExtTestCase testMethod=test_deployment_target_too_low>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_too_low(self):
        # Issue 9516: Test that an extension module is not allowed to be
        # compiled with a deployment target less than that of the interpreter.
>       self.assertRaises(DistutilsPlatformError,
            self._try_compile_deployment_target, '>', '10.1')

distutils/tests/test_build_ext.py:448: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
___________ ParallelBuildExtTestCase.test_deployment_target_default ____________

self = <distutils.tests.test_build_ext.ParallelBuildExtTestCase testMethod=test_deployment_target_default>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_default(self):
        # Issue 9516: Test that, in the absence of the environment variable,
        # an extension module is compiled with the same deployment target as
        #  the interpreter.
>       self._try_compile_deployment_target('==', None)

distutils/tests/test_build_ext.py:442: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <distutils.tests.test_build_ext.ParallelBuildExtTestCase testMethod=test_deployment_target_default>
operator = '==', target = (11,)

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
__________ ParallelBuildExtTestCase.test_deployment_target_higher_ok ___________

self = <distutils.tests.test_build_ext.ParallelBuildExtTestCase testMethod=test_deployment_target_higher_ok>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_higher_ok(self):
        # Issue 9516: Test that an extension module can be compiled with a
        # deployment target higher than that of the interpreter: the ext
        # module may depend on some newer OS feature.
        deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        if deptarget:
            # increment the minor version number (i.e. 10.6 -> 10.7)
            deptarget = [int(x) for x in deptarget.split('.')]
            deptarget[-1] += 1
            deptarget = '.'.join(str(i) for i in deptarget)
>           self._try_compile_deployment_target('<', deptarget)

distutils/tests/test_build_ext.py:462: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <distutils.tests.test_build_ext.ParallelBuildExtTestCase testMethod=test_deployment_target_higher_ok>
operator = '<', target = (11,)

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
___________ ParallelBuildExtTestCase.test_deployment_target_too_low ____________

self = <distutils.tests.test_build_ext.ParallelBuildExtTestCase testMethod=test_deployment_target_too_low>

    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
    def test_deployment_target_too_low(self):
        # Issue 9516: Test that an extension module is not allowed to be
        # compiled with a deployment target less than that of the interpreter.
>       self.assertRaises(DistutilsPlatformError,
            self._try_compile_deployment_target, '>', '10.1')

distutils/tests/test_build_ext.py:448: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def _try_compile_deployment_target(self, operator, target):
        orig_environ = os.environ
        os.environ = orig_environ.copy()
        self.addCleanup(setattr, os, 'environ', orig_environ)
    
        if target is None:
            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
                del os.environ['MACOSX_DEPLOYMENT_TARGET']
        else:
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    
        deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
    
        with open(deptarget_c, 'w') as fp:
            fp.write(textwrap.dedent('''\
                #include <AvailabilityMacros.h>
    
                int dummy;
    
                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif
    
            ''' % operator))
    
        # get the deployment target that the interpreter was built with
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        target = tuple(map(int, target.split('.')[0:2]))
        # format the target value as defined in the Apple
        # Availability Macros.  We can't use the macro names since
        # at least one value we test with will not exist yet.
>       if target[1] < 10:
E       IndexError: tuple index out of range

distutils/tests/test_build_ext.py:496: IndexError
=========================== short test summary info ============================
FAILED distutils/tests/test_build_ext.py::BuildExtTestCase::test_deployment_target_default
FAILED distutils/tests/test_build_ext.py::BuildExtTestCase::test_deployment_target_higher_ok
FAILED distutils/tests/test_build_ext.py::BuildExtTestCase::test_deployment_target_too_low
FAILED distutils/tests/test_build_ext.py::ParallelBuildExtTestCase::test_deployment_target_default
FAILED distutils/tests/test_build_ext.py::ParallelBuildExtTestCase::test_deployment_target_higher_ok
FAILED distutils/tests/test_build_ext.py::ParallelBuildExtTestCase::test_deployment_target_too_low
================== 6 failed, 266 passed, 24 skipped in 3.67s ===================
ERROR: InvocationError for command /Users/jaraco/code/public/pypa/distutils/.tox/py38/bin/pytest (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py38: commands failed

Inspecting the environment, I see that Python 3.8 seems to have a unique value for MACOSX_DEPLOYMENT_TARGET:

distutils main $ py -3.10 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"
10.9
distutils main $ py -3.9 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"
10.9
distutils main $ py -3.8 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"
11
distutils main $ py -3.7 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"
10.9
distutils main $ py -3.6 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"
10.9

I'm not sure what that's about, but it seems to be the cause of the test failures.

Activity

lazka

lazka commented on Dec 30, 2021

@lazka
Contributor

https://bugs.python.org/issue42504 ? Though the error is different, so maybe not exactly.

There also is python/cpython#22855

jaraco

jaraco commented on Dec 30, 2021

@jaraco
MemberAuthor

I've refreshed the cpython branch to pull in stdlib changes since the last sync (e34d6d8 -> da64642). I should be able to cherry-pick relevant changes from there.

changed the title Tests fail on Python 3.8 only on my mac Tests fail on Python 3.8.10 where MACOSX_DEPLOYMENT_TARGET=11 on Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Tests fail on Python 3.8.10 where MACOSX_DEPLOYMENT_TARGET=11 · Issue #100 · pypa/distutils