feat: add CPython 3.10 pre-release support (#675)

* Add CPython 3.10 support

* Fix logger displaying CPython 3.1 instead of 3.10

* Fix tests failing with CPython 3.10

* Use pytest instead of nose

* feat: --pre flag

Apply suggestions from code review

Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>

* fix: update Python update script to process beta versions

* refactor: prerelease-pythons

* Use `strtobool` to parse `CIBW_PRERELEASE_PYTHONS` env var

* Update python version filtering for universal2 & arm64

* Filter out CPython 3.10 and above for `test_manylinuxXXXX_only[manylinux1]` test

* Use CIBW_BUILD filtering rather than CIBW_SKIP for test_docker_images

* Use skip_patterns to filter out pre-releases

* Use `prerelease_pythons` instead of `pre`

* Reword `CIBW_PRERELEASE_PYTHONS` doc per review.

* Use `CIBW_PRERELEASE_PYTHONS: True` for usage example.

* Update `cibuildwheel --help` doc

* docs: add note on spec.filter

* Clean up the BuildSelector __repr__ by refactoring

* fix: remove platform variants for CIBW_PRERELEASE_PYTHONS

* docs: mention the flag

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
Matthieu Darbois
2021-05-28 18:26:55 -04:00
committed by GitHub
co-authored by Henry Schreiner Joe Rickerby
parent f294cab7aa
commit 5b22fc636b
17 changed files with 166 additions and 53 deletions
+3 -1
View File
@@ -53,5 +53,7 @@ def test_build_identifiers(tmp_path):
# 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)
build_identifiers = utils.cibuildwheel_get_build_identifiers(
project_dir, prerelease_pythons=True
)
assert len(expected_wheels) == len(build_identifiers)
+3 -3
View File
@@ -49,11 +49,11 @@ def test(tmp_path):
# 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)" && python -m pip install {project}/dependency""",
"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)" && python -m pip install {project}/dependency""",
"CIBW_TEST_REQUIRES": "nose",
"CIBW_TEST_REQUIRES": "pytest",
# 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",
"CIBW_TEST_COMMAND": "false || pytest {project}/test",
"CIBW_TEST_COMMAND_WINDOWS": "pytest {project}/test",
},
)
+1 -1
View File
@@ -23,7 +23,7 @@ def test(tmp_path):
actual_wheels = utils.cibuildwheel_run(
project_dir,
add_env={
"CIBW_BUILD": "cp3?-*",
"CIBW_BUILD": "cp3*-*",
"CIBW_SKIP": "cp37-*",
},
)
+2 -2
View File
@@ -37,7 +37,7 @@ def test(tmp_path):
add_env={
"CIBW_MANYLINUX_X86_64_IMAGE": "dockcross/manylinux2010-x64",
"CIBW_MANYLINUX_I686_IMAGE": "dockcross/manylinux2010-x86",
"CIBW_SKIP": "pp* cp39-*",
"CIBW_BUILD": "cp3{6,7,8,9}-*",
},
)
@@ -49,6 +49,6 @@ def test(tmp_path):
expected_wheels = [
w
for w in utils.expected_wheels("spam", "0.1.0", manylinux_versions=["manylinux2010"])
if "-pp" not in w and "-cp39-" not in w
if "-cp36-" in w or "-cp37-" in w or "-cp38-" in w or "-cp39-" in w
]
assert set(actual_wheels) == set(expected_wheels)
+4 -3
View File
@@ -68,8 +68,8 @@ def test(manylinux_image, tmp_path):
"CIBW_MANYLINUX_PYPY_I686_IMAGE": manylinux_image,
}
if manylinux_image in {"manylinux1"}:
# We don't have a manylinux1 image for PyPy
add_env["CIBW_SKIP"] = "pp*"
# We don't have a manylinux1 image for PyPy & CPython 3.10 and above
add_env["CIBW_SKIP"] = "pp* cp31*"
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
@@ -82,5 +82,6 @@ def test(manylinux_image, tmp_path):
"spam", "0.1.0", manylinux_versions=platform_tag_map.get(manylinux_image, [manylinux_image])
)
if manylinux_image in {"manylinux1"}:
expected_wheels = [w for w in expected_wheels if "-pp" not in w]
# remove PyPy & CPython 3.10 and above
expected_wheels = [w for w in expected_wheels if "-pp" not in w and "-cp31" not in w]
assert set(actual_wheels) == set(expected_wheels)
+6 -6
View File
@@ -10,7 +10,7 @@ project_with_a_test = test_projects.new_c_project(
setup_cfg_add=textwrap.dedent(
r"""
[options.extras_require]
test = nose
test = pytest
"""
)
)
@@ -77,11 +77,11 @@ def test(tmp_path):
actual_wheels = utils.cibuildwheel_run(
project_dir,
add_env={
"CIBW_TEST_REQUIRES": "nose",
"CIBW_TEST_REQUIRES": "pytest",
# 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",
"CIBW_TEST_COMMAND": "false || pytest {project}/test",
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
},
)
@@ -101,8 +101,8 @@ def test_extras_require(tmp_path):
"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",
"CIBW_TEST_COMMAND": "false || pytest {project}/test",
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
},
)
+10 -5
View File
@@ -24,13 +24,17 @@ else:
raise Exception("Unsupported platform")
def cibuildwheel_get_build_identifiers(project_path, env=None):
def cibuildwheel_get_build_identifiers(project_path, env=None, *, prerelease_pythons=False):
"""
Returns the list of build identifiers that cibuildwheel will try to build
for the current platform.
"""
cmd = [sys.executable, "-m", "cibuildwheel", "--print-build-identifiers", str(project_path)]
if prerelease_pythons:
cmd.append("--prerelease-pythons")
cmd_output = subprocess.run(
[sys.executable, "-m", "cibuildwheel", "--print-build-identifiers", str(project_path)],
cmd,
universal_newlines=True,
env=env,
check=True,
@@ -69,6 +73,7 @@ def cibuildwheel_run(project_path, package_dir=".", env=None, add_env=None, outp
sys.executable,
"-m",
"cibuildwheel",
"--prerelease-pythons",
"--output-dir",
str(output_dir or tmp_output_dir),
str(package_dir),
@@ -118,7 +123,7 @@ def expected_wheels(
else:
manylinux_versions = ["manylinux_2_17", "manylinux2014"]
python_abi_tags = ["cp36-cp36m", "cp37-cp37m", "cp38-cp38", "cp39-cp39"]
python_abi_tags = ["cp36-cp36m", "cp37-cp37m", "cp38-cp38", "cp39-cp39", "cp310-cp310"]
if machine_arch in ["x86_64", "AMD64", "x86", "aarch64"]:
python_abi_tags += ["pp37-pypy37_pp73"]
@@ -129,8 +134,8 @@ def expected_wheels(
python_abi_tags = [t for t in python_abi_tags if not t.startswith("pp")]
if platform == "macos" and machine_arch == "arm64":
# currently, arm64 macs are only supported by cp39
python_abi_tags = ["cp39-cp39"]
# currently, arm64 macs are only supported by cp39 & cp310
python_abi_tags = ["cp39-cp39", "cp310-cp310"]
wheels = []