コード例 #1
0
def test_pinned_versions(python_version):
    if utils.platform == 'linux':
        pytest.skip(
            'linux doesn\'t pin individual tool versions, it pins manylinux images instead'
        )

    project_dir = os.path.dirname(__file__)

    build_environment = {}

    if python_version == '2.7':
        constraint_filename = 'constraints-python27.txt'
        build_pattern = '[cp]p27-*'
    elif python_version == '3.5':
        constraint_filename = 'constraints-python35.txt'
        build_pattern = '[cp]p35-*'
    else:
        constraint_filename = 'constraints.txt'
        build_pattern = '[cp]p38-*'

    constraint_file = os.path.join(cibuildwheel.util.resources_dir,
                                   constraint_filename)
    constraint_versions = get_versions_from_constraint_file(constraint_file)

    for package in ['pip', 'setuptools', 'wheel', 'virtualenv']:
        env_name = 'EXPECTED_{}_VERSION'.format(package.upper())
        build_environment[env_name] = constraint_versions[package]

    cibw_environment_option = ' '.join(
        ['{}={}'.format(k, v) for k, v in build_environment.items()])

    # build and test the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir,
                                           add_env={
                                               'CIBW_BUILD':
                                               build_pattern,
                                               'CIBW_ENVIRONMENT':
                                               cibw_environment_option,
                                           })

    # also check that we got the right wheels
    if python_version == '2.7':
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-cp27' in w or '-pp27' in w
        ]
    elif python_version == '3.5':
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-cp35' in w or '-pp35' in w
        ]
    elif python_version == '3.8':
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-cp38' in w or '-pp38' in w
        ]
    else:
        raise ValueError('unhandled python version')

    assert set(actual_wheels) == set(expected_wheels)
コード例 #2
0
def test_dependency_constraints_file(tmp_path, python_version):
    if utils.platform == 'linux':
        pytest.skip(
            'linux doesn\'t pin individual tool versions, it pins manylinux images instead'
        )

    project_dir = os.path.dirname(__file__)

    tool_versions = {
        'pip': '20.0.2',
        'setuptools': '44.0.0' if python_version == '2.7' else '46.0.0',
        'wheel': '0.34.2',
        'virtualenv': '20.0.10',
    }

    constraints_file = tmp_path / 'constraints.txt'
    constraints_file.write_text(
        textwrap.dedent('''
            pip=={pip}
            setuptools=={setuptools}
            wheel=={wheel}
            virtualenv=={virtualenv}
        '''.format(**tool_versions)))

    build_environment = {}

    for package_name, version in tool_versions.items():
        env_name = 'EXPECTED_{}_VERSION'.format(package_name.upper())
        build_environment[env_name] = version

    cibw_environment_option = ' '.join(
        ['{}={}'.format(k, v) for k, v in build_environment.items()])

    # build and test the wheels
    actual_wheels = utils.cibuildwheel_run(
        project_dir,
        add_env={
            'CIBW_BUILD':
            '[cp]p27-*' if python_version == '2.7' else '[cp]p3?-*',
            'CIBW_ENVIRONMENT': cibw_environment_option,
            'CIBW_DEPENDENCY_VERSIONS': str(constraints_file),
        })

    # also check that we got the right wheels
    if python_version == '2.7':
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-cp27' in w or '-pp27' in w
        ]
    else:
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-cp27' not in w and '-pp27' not in w
        ]

    assert set(actual_wheels) == set(expected_wheels)
コード例 #3
0
def test_build_identifiers():
    # check that the number of expected wheels matches the number of build
    # identifiers
    # after adding CIBW_MANYLINUX_IMAGE to support manylinux2010, there
    # can be multiple wheels for each wheel, though, so we need to limit
    # the expected wheels
    if platform.machine() in ['x86_64', 'i686']:
        expected_wheels = [
            w for w in utils.expected_wheels('spam', '0.1.0')
            if '-manylinux' not in w or '-manylinux1' in w
        ]
    else:
        expected_wheels = utils.expected_wheels('spam', '0.1.0')
    build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
    assert len(expected_wheels) == len(build_identifiers)
コード例 #4
0
def test():
    # build the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir)

    # check that the expected wheels are produced
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #5
0
def test_cpp17():
    # This test checks that the C++17 standard is supported

    # Python and PyPy 2.7 use the `register` keyword which is forbidden in the C++17 standard
    # The manylinux1 docker image does not have a compiler which supports C++11
    # Python 3.5 and PyPy 3.6 are compiled with MSVC 10, which does not support C++17
    if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE',
                      '') == 'Visual Studio 2015':
        pytest.skip('Visual Studio 2015 does not support C++17')

    add_env = {
        'CIBW_SKIP': 'cp27-win* pp27-win32 cp35-win* pp36-win32',
        'CIBW_ENVIRONMENT': 'STANDARD=17'
    }
    if utils.platform == 'macos':
        add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.13'

    actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
    expected_wheels = [
        w for w in utils.expected_wheels(
            'spam', '0.1.0', macosx_deployment_target='10.13')
        if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w
        and 'cp35-cp35m-win' not in w and 'pp36-pypy36_pp73-win32' not in w
    ]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #6
0
def test():
    project_dir = os.path.dirname(__file__)

    if utils.platform != 'linux':
        pytest.skip('the test is only relevant to the linux build')

    actual_wheels = utils.cibuildwheel_run(
        project_dir,
        add_env={
            'CIBW_MANYLINUX_X86_64_IMAGE':
            'dockcross/manylinux2010-x64',
            'CIBW_MANYLINUX_I686_IMAGE':
            'dockcross/manylinux1-x86',
            'CIBW_BEFORE_BUILD':
            '/opt/python/cp36-cp36m/bin/pip install -U auditwheel',  # Currently necessary on dockcross images to get auditwheel 2.1 supporting AUDITWHEEL_PLAT
            'CIBW_ENVIRONMENT':
            'AUDITWHEEL_PLAT=`if [ $(uname -i) == "x86_64" ]; then echo "manylinux2010_x86_64"; else echo "manylinux1_i686"; fi`',
        })

    # also check that we got the right wheels built
    expected_wheels = [
        w for w in utils.expected_wheels('spam', '0.1.0')
        if '-manylinux2010_i686' not in w
    ]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #7
0
def test_cpp11(tmp_path):
    # This test checks that the C++11 standard is supported

    # VC++ for Python 2.7 does not support modern standards
    add_env = {'CIBW_SKIP': 'cp27-win* pp27-win32', 'CIBW_ENVIRONMENT': 'STANDARD=11'}

    actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
    expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
                       if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w]

    assert set(actual_wheels) == set(expected_wheels)
コード例 #8
0
def test():
    project_dir = os.path.dirname(__file__)

    # build the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
        'CIBW_BUILD': 'cp3?-*',
        'CIBW_SKIP': 'cp37-*',
    })

    # check that we got the right wheels. There should be no 2.7 or 3.7.
    expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
                       if ('-cp3' in w) and ('-cp37' not in w)]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #9
0
def test():
    project_dir = os.path.dirname(__file__)

    # build the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
        # write python version information to a temporary file, this is
        # checked in setup.py
        'CIBW_BEFORE_BUILD': '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonexecutable.txt', 'w').write(sys.executable)"''',
        'CIBW_BEFORE_BUILD_WINDOWS': '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonexecutable.txt', 'w').write(sys.executable)"''',
    })

    # also check that we got the right wheels
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #10
0
def test():
    project_dir = os.path.dirname(__file__)

    # write some information into the CIBW_ENVIRONMENT, for expansion and
    # insertion into the environment by cibuildwheel. This is checked
    # in setup.py
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
        'CIBW_ENVIRONMENT': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path''',
        'CIBW_ENVIRONMENT_WINDOWS': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
    })

    # also check that we got the right wheels built
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #11
0
def test():
    project_dir = os.path.dirname(__file__)

    # build and test the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
        'CIBW_TEST_REQUIRES': 'nose',
        # the 'false ||' bit is to ensure this command runs in a shell on
        # mac/linux.
        'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
        'CIBW_TEST_COMMAND_WINDOWS': 'COLOR 00 || nosetests {project}/test',
    })

    # also check that we got the right wheels
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #12
0
def test_cpp14():
    # This test checks that the C++14 standard is supported

    # VC++ for Python 2.7 does not support modern standards
    # The manylinux1 docker image does not have a compiler which supports C++11
    # Python 3.4 and 3.5 are compiled with MSVC 10, which does not support C++14
    add_env = {'CIBW_SKIP': 'cp27-win* pp27-win32 cp35-win*', 'CIBW_ENVIRONMENT': 'STANDARD=14'}

    actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
    expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
                       if 'cp27-cp27m-win' not in w
                       and 'pp27-pypy_73-win32' not in w
                       and 'cp35-cp35m-win' not in w]

    assert set(actual_wheels) == set(expected_wheels)
コード例 #13
0
def test():
    project_dir = os.path.dirname(__file__)

    if utils.platform != 'linux':
        pytest.skip('the docker test is only relevant to the linux build')

    utils.cibuildwheel_run(project_dir,
                           add_env={
                               'CIBW_MANYLINUX1_X86_64_IMAGE':
                               'dockcross/manylinux-x64',
                               'CIBW_MANYLINUX1_I686_IMAGE':
                               'dockcross/manylinux-x86',
                           })

    # also check that we got the right wheels built
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #14
0
def test_cpp11(tmp_path):
    # This test checks that the C++11 standard is supported

    add_env = {
        'CIBW_SKIP': 'cp27-win* pp27-win32',
        'CIBW_ENVIRONMENT': 'STANDARD=11'
    }
    # VC++ for Python 2.7 does not support modern standards
    if utils.platform == 'macos':
        add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'

    actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
    expected_wheels = [
        w for w in utils.expected_wheels(
            'spam', '0.1.0', macosx_deployment_target='10.9')
        if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w
    ]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #15
0
def test(manylinux_image):
    project_dir = os.path.dirname(__file__)

    if utils.platform != 'linux':
        pytest.skip('the docker test is only relevant to the linux build')
    elif platform.machine not in ['x86_64', 'i686']:
        if manylinux_image in ['manylinux1', 'manylinux2010']:
            pytest.skip(
                "manylinux1 and 2010 doesn't exist for non-x86 architectures")

    # build the wheels
    # CFLAGS environment variable is necessary to fail on 'malloc_info' (on manylinux1) during compilation/linking,
    # rather than when dynamically loading the Python
    add_env = {
        'CIBW_ENVIRONMENT':
        'CFLAGS="$CFLAGS -Werror=implicit-function-declaration"',
        'CIBW_MANYLINUX_X86_64_IMAGE': manylinux_image,
        'CIBW_MANYLINUX_I686_IMAGE': manylinux_image,
        'CIBW_MANYLINUX_PYPY_X86_64_IMAGE': manylinux_image,
        'CIBW_MANYLINUX_AARCH64_IMAGE': manylinux_image,
        'CIBW_MANYLINUX_PPC64LE_IMAGE': manylinux_image,
        'CIBW_MANYLINUX_S390X_IMAGE': manylinux_image,
    }
    if manylinux_image == 'manylinux1':
        # We don't have a manylinux1 image for PyPy
        add_env['CIBW_SKIP'] = 'pp*'
    elif manylinux_image == 'manylinux2014':
        # We don't have a manylinux2014 image for PyPy (yet?)
        add_env[
            'CIBW_SKIP'] = 'cp27* pp*'  # Python 2.7 not available on manylinux2014
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)

    expected_wheels = [
        w for w in utils.expected_wheels(
            'spam', '0.1.0', manylinux_versions=[manylinux_image])
    ]
    if manylinux_image == 'manylinux2014':
        expected_wheels = [w for w in expected_wheels if '-cp27' not in w]
    if manylinux_image in ['manylinux1', 'manylinux2014']:
        expected_wheels = [w for w in expected_wheels if '-pp' not in w]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #16
0
def test():
    project_dir = os.path.dirname(__file__)

    if utils.platform != 'linux':
        pytest.skip('the docker test is only relevant to the linux build')

    # build the wheels
    # CFLAGS environment veriable is ecessary to fail on 'malloc_info' (on manylinux1) during compilation/linking,
    # rather than when dynamically loading the Python
    actual_wheels = utils.cibuildwheel_run(
        project_dir,
        add_env={
            'CIBW_ENVIRONMENT':
            'CFLAGS="$CFLAGS -Werror=implicit-function-declaration"',
        })

    # also check that we got the right wheels
    expected_wheels = [
        w for w in utils.expected_wheels('spam', '0.1.0')
        if not '-manylinux' in w or '-manylinux2010' in w
    ]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #17
0
def test(capfd):
    package_dir = os.path.join(project_dir, 'src', 'spam')
    # build the wheels
    actual_wheels = utils.cibuildwheel_run(
        project_dir,
        package_dir=package_dir,
        add_env={
            'CIBW_BEFORE_BUILD': 'python {project}/bin/before_build.py',
            'CIBW_TEST_COMMAND': 'python {package}/test/run_tests.py',
            # this shouldn't depend on the version of python, so build only
            # CPython 3.6
            'CIBW_BUILD': 'cp36-*',
        })

    # check that the expected wheels are produced
    expected_wheels = [
        w for w in utils.expected_wheels('spam', '0.1.0') if 'cp36' in w
    ]
    assert set(actual_wheels) == set(expected_wheels)

    captured = capfd.readouterr()
    assert "before_build.py executed!" in captured.out
    assert "run_tests.py executed!" in captured.out
コード例 #18
0
def test():
    project_dir = os.path.dirname(__file__)

    # build the wheels
    actual_wheels = utils.cibuildwheel_run(
        project_dir,
        add_env={
            # write python version information to a temporary file, this is
            # checked in setup.py
            'CIBW_BEFORE_TEST':
            '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonprefix.txt', 'w').write(sys.prefix)"''',
            'CIBW_BEFORE_TEST_WINDOWS':
            '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonprefix.txt', 'w').write(sys.prefix)"''',
            'CIBW_TEST_REQUIRES': 'nose',
            # the 'false ||' bit is to ensure this command runs in a shell on
            # mac/linux.
            'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
            'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
        })

    # also check that we got the right wheels
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    assert set(actual_wheels) == set(expected_wheels)
コード例 #19
0
def test():
    project_dir = os.path.dirname(__file__)

    if utils.platform != 'linux':
        pytest.skip('the test is only relevant to the linux build')
    if platform.machine() not in ['x86_64', 'i686']:
        pytest.skip(
            'this test is currently only possible on x86_64/i686 due to availability of alternative images'
        )

    actual_wheels = utils.cibuildwheel_run(project_dir,
                                           add_env={
                                               'CIBW_MANYLINUX_X86_64_IMAGE':
                                               'dockcross/manylinux2010-x64',
                                               'CIBW_MANYLINUX_I686_IMAGE':
                                               'dockcross/manylinux2010-x86',
                                               'CIBW_SKIP': 'pp*',
                                           })

    # also check that we got the right wheels built
    expected_wheels = [
        w for w in utils.expected_wheels('spam', '0.1.0') if '-pp' not in w
    ]
    assert set(actual_wheels) == set(expected_wheels)
コード例 #20
0
def test_build_identifiers():
    # check that the number of expected wheels matches the number of build
    # identifiers
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
    assert len(expected_wheels) == len(build_identifiers)