Skip to content

Commit

Permalink
Add successful test building with Py_LIMITED_API
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul committed Jan 30, 2021
1 parent 700974b commit 19db6d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
19 changes: 19 additions & 0 deletions test/test_limited_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from . import test_projects, utils

basic_project = test_projects.new_c_project(
setup_py_setup_args_add='py_limited_api=True',
)


def test_setup_py(tmp_path):
project_dir = tmp_path / 'project'
basic_project.generate(project_dir)

# build the wheels
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
'CIBW_BUILD': 'cp27-* cp35-*',
})

# check that the expected wheels are produced
expected_wheels = utils.expected_wheels('spam', '0.1.0', limited_api=True)
assert set(actual_wheels) == set(expected_wheels)
8 changes: 6 additions & 2 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp

def expected_wheels(package_name, package_version, manylinux_versions=None,
macosx_deployment_target='10.9', machine_arch=None, *,
exclude_27=IS_WINDOWS_RUNNING_ON_TRAVIS):
exclude_27=IS_WINDOWS_RUNNING_ON_TRAVIS,
limited_api=False):
'''
Returns a list of expected wheels from a run of cibuildwheel.
'''
Expand All @@ -95,7 +96,10 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
else:
manylinux_versions = ['manylinux2014']

python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39']
if limited_api:
python_abi_tags = ['cp35-abi3']
else:
python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39']

if machine_arch in ['x86_64', 'AMD64', 'x86']:
python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73', 'pp37-pypy37_pp73']
Expand Down

0 comments on commit 19db6d4

Please sign in to comment.