Skip to content

Commit

Permalink
chore: add warning when running cibuildwheel with python<3.11 (#2050)
Browse files Browse the repository at this point in the history
* chore: add warning when running cibuildwheel with python<3.11

* fix: use `log.warning` to print warnings in `print_preamble`

* Better warning & doc update

* address review comments

* Update README.md

Co-authored-by: Henry Schreiner <[email protected]>

---------

Co-authored-by: Henry Schreiner <[email protected]>
  • Loading branch information
mayeut and henryiii authored Oct 25, 2024
1 parent b986027 commit 7c3b0fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Python wheels are great. Building them across **Mac, Linux, Windows**, on **mult
What does it do?
----------------

While cibuildwheel itself requires a recent Python version to run (we support the last three releases), it can target the following versions to build wheels:

| | macOS Intel | macOS Apple Silicon | Windows 64bit | Windows 32bit | Windows Arm64 | manylinux<br/>musllinux x86_64 | manylinux<br/>musllinux i686 | manylinux<br/>musllinux aarch64 | manylinux<br/>musllinux ppc64le | manylinux<br/>musllinux s390x | musllinux armv7l | Pyodide |
|----------------|----|-----|-----|-----|-----|----|-----|----|-----|-----|---|-----|
| CPython 3.6 || N/A ||| N/A ||||||| N/A |
Expand Down
21 changes: 15 additions & 6 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,13 @@ def print_preamble(platform: str, options: Options, identifiers: Sequence[str])

print()
print(f"Cache folder: {CIBW_CACHE_PATH}")
print()

warnings = detect_warnings(options=options, identifiers=identifiers)
if warnings:
print("\nWarnings:")
for warning in warnings:
print(" " + warning)
for warning in warnings:
log.warning(warning)

print("\nHere we go!\n")
print("Here we go!\n")


def get_build_identifiers(
Expand All @@ -402,6 +401,16 @@ def get_build_identifiers(
def detect_warnings(*, options: Options, identifiers: Iterable[str]) -> list[str]:
warnings = []

python_version_deprecation = ((3, 11), 3)
if sys.version_info[:2] < python_version_deprecation[0]:
python_version = ".".join(map(str, python_version_deprecation[0]))
msg = (
f"cibuildwheel {python_version_deprecation[1]} will require Python {python_version}+, "
"please upgrade the Python version used to run cibuildwheel. "
"This does not affect the versions you can target when building wheels. See: https://cibuildwheel.pypa.io/en/stable/#what-does-it-do"
)
warnings.append(msg)

# warn about deprecated {python} and {pip}
for option_name in ["test_command", "before_build"]:
option_values = [getattr(options.build_options(i), option_name) for i in identifiers]
Expand All @@ -410,7 +419,7 @@ def detect_warnings(*, options: Options, identifiers: Iterable[str]) -> list[str
# Reminder: in an f-string, double braces means literal single brace
msg = (
f"{option_name}: '{{python}}' and '{{pip}}' are no longer needed, "
"and will be removed in a future release. Simply use 'python' or 'pip' instead."
"and will be removed in cibuildwheel 3. Simply use 'python' or 'pip' instead."
)
warnings.append(msg)

Expand Down

0 comments on commit 7c3b0fb

Please sign in to comment.