Exemple #1
0
def test():
    project_dir = os.path.dirname(__file__)

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

    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
    ]
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
Exemple #2
0
def test():
    # build the wheels
    utils.cibuildwheel_run(project_dir)

    # check that the expected wheels are produced
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
Exemple #3
0
def test_overridden_path(tmp_path):
    project_dir = os.path.dirname(__file__)

    # mess up PATH, somehow
    with pytest.raises(subprocess.CalledProcessError):
        utils.cibuildwheel_run(project_dir, output_dir=tmp_path, add_env={
            'CIBW_ENVIRONMENT': '''SOMETHING="$(mkdir new_path && touch new_path/python)" PATH="$(realpath new_path):$PATH"''',
            'CIBW_ENVIRONMENT_WINDOWS': '''SOMETHING="$(mkdir new_path && type nul > new_path/python.exe)" PATH="$CD\\new_path;$PATH"''',
        })
    assert len(os.listdir(str(tmp_path))) == 0
Exemple #4
0
def test_failing_test(tmp_path):
    '''Ensure a failing test causes cibuildwheel to error out and exit'''
    project_dir = os.path.dirname(__file__)

    with pytest.raises(subprocess.CalledProcessError):
        utils.cibuildwheel_run(project_dir, output_dir=tmp_path, add_env={
            'CIBW_TEST_COMMAND': 'false',
            # manylinux1 has a version of bash that's been shown to have
            # problems with this, so let's check that.
            'CIBW_MANYLINUX_I686_IMAGE': 'manylinux1',
            'CIBW_MANYLINUX_X86_64_IMAGE': 'manylinux1',
        })
    assert len(os.listdir(str(tmp_path))) == 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)
def test():
    project_dir = os.path.dirname(__file__)

    # build and test the 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': 'nosetests {project}/test',
    })
    
    # also check that we got the right wheels
    expected_wheels = utils.expected_wheels('spam', '0.1.0')
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
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)
def test():
    project_dir = os.path.dirname(__file__)

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

    # check that we got the right wheels. There should be no 2.7 or 3.4.
    expected_wheels = [
        w for w in utils.expected_wheels('spam', '0.1.0')
        if ('-cp3' in w) and ('-cp34' not in w)
    ]
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
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)
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)
Exemple #11
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
    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')
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
def test():
    project_dir = os.path.dirname(__file__)

    # build the 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')
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
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)
Exemple #14
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
    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
    ]
    actual_wheels = os.listdir('wheelhouse')
    assert set(actual_wheels) == set(expected_wheels)
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)
Exemple #16
0
def test_extras_require():
    project_dir = os.path.dirname(__file__)

    # build and test the wheels
    actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
        'CIBW_TEST_EXTRAS': 'test',
        # 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)
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)
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)
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
Exemple #20
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)
Exemple #21
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)
Exemple #22
0
def test():
    project_dir = os.path.dirname(__file__)
    # this test checks that SSL is working in the build environment using
    # some checks in setup.py.

    utils.cibuildwheel_run(project_dir)