fix: raise clear errors when no wheel is produced (#2909)
This commit is contained in:
@@ -109,3 +109,19 @@ class AuditCommandFailedError(FatalError):
|
|||||||
def __init__(self, message: str) -> None:
|
def __init__(self, message: str) -> None:
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
self.return_code = 9
|
self.return_code = 9
|
||||||
|
|
||||||
|
|
||||||
|
class BuildProducedNoWheelError(FatalError):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
message = textwrap.dedent(
|
||||||
|
"""
|
||||||
|
Build failed because the build frontend completed successfully but
|
||||||
|
did not produce a wheel.
|
||||||
|
|
||||||
|
This usually indicates a problem with your project configuration or
|
||||||
|
build backend. Check your project configuration, or run cibuildwheel
|
||||||
|
with CIBW_BUILD_VERBOSITY=1 to view build logs.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
super().__init__(message)
|
||||||
|
self.return_code = 10
|
||||||
|
|||||||
@@ -410,10 +410,14 @@ def setup_android_env(
|
|||||||
# * a key=value string, without quotes
|
# * a key=value string, without quotes
|
||||||
for i, token in enumerate(shlex.split(env_output)):
|
for i, token in enumerate(shlex.split(env_output)):
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
assert token == "export", token
|
if token != "export":
|
||||||
|
msg = f"Unexpected output from android.py env: expected 'export', got {token!r}"
|
||||||
|
raise errors.FatalError(msg)
|
||||||
else:
|
else:
|
||||||
key, sep, value = token.partition("=")
|
key, sep, value = token.partition("=")
|
||||||
assert sep == "=", token
|
if sep != "=":
|
||||||
|
msg = f"Unexpected output from android.py env: expected 'key=value', got {token!r}"
|
||||||
|
raise errors.FatalError(msg)
|
||||||
android_env[key] = value
|
android_env[key] = value
|
||||||
|
|
||||||
# localized_vars cleared the CFLAGS and CXXFLAGS in the sysconfigdata, but most
|
# localized_vars cleared the CFLAGS and CXXFLAGS in the sysconfigdata, but most
|
||||||
|
|||||||
@@ -95,6 +95,14 @@ def all_python_configurations() -> list[PythonConfiguration]:
|
|||||||
matching = [
|
matching = [
|
||||||
config for config in macos_python_configs if config["identifier"] == macos_identifier
|
config for config in macos_python_configs if config["identifier"] == macos_identifier
|
||||||
]
|
]
|
||||||
|
if not matching:
|
||||||
|
msg = (
|
||||||
|
f"Internal error: no macOS configuration found matching "
|
||||||
|
f"{macos_identifier!r}, needed to build the iOS configuration "
|
||||||
|
f"{config_dict['identifier']!r}. The bundled build-platforms.toml "
|
||||||
|
f"resources are inconsistent."
|
||||||
|
)
|
||||||
|
raise errors.FatalError(msg)
|
||||||
return matching[0]
|
return matching[0]
|
||||||
|
|
||||||
# Load the platform configuration
|
# Load the platform configuration
|
||||||
@@ -560,7 +568,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
case _:
|
case _:
|
||||||
assert_never(build_frontend)
|
assert_never(build_frontend)
|
||||||
|
|
||||||
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
try:
|
||||||
|
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
||||||
|
except StopIteration:
|
||||||
|
raise errors.BuildProducedNoWheelError() from None
|
||||||
|
|
||||||
if built_wheel.name.endswith("none-any.whl"):
|
if built_wheel.name.endswith("none-any.whl"):
|
||||||
raise errors.NonPlatformWheelError()
|
raise errors.NonPlatformWheelError()
|
||||||
|
|||||||
@@ -346,7 +346,10 @@ def build_in_container(
|
|||||||
case _:
|
case _:
|
||||||
assert_never(build_frontend)
|
assert_never(build_frontend)
|
||||||
|
|
||||||
built_wheel = container.glob(built_wheel_dir, "*.whl")[0]
|
try:
|
||||||
|
built_wheel = container.glob(built_wheel_dir, "*.whl")[0]
|
||||||
|
except IndexError:
|
||||||
|
raise errors.BuildProducedNoWheelError() from None
|
||||||
|
|
||||||
repaired_wheel_dir = temp_dir / "repaired_wheel"
|
repaired_wheel_dir = temp_dir / "repaired_wheel"
|
||||||
container.call(["rm", "-rf", repaired_wheel_dir])
|
container.call(["rm", "-rf", repaired_wheel_dir])
|
||||||
|
|||||||
@@ -566,7 +566,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
case _:
|
case _:
|
||||||
assert_never(build_frontend)
|
assert_never(build_frontend)
|
||||||
|
|
||||||
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
try:
|
||||||
|
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
||||||
|
except StopIteration:
|
||||||
|
raise errors.BuildProducedNoWheelError() from None
|
||||||
|
|
||||||
repaired_wheel_dir.mkdir()
|
repaired_wheel_dir.mkdir()
|
||||||
|
|
||||||
|
|||||||
@@ -451,7 +451,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
*extra_flags,
|
*extra_flags,
|
||||||
env=env,
|
env=env,
|
||||||
)
|
)
|
||||||
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
try:
|
||||||
|
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
||||||
|
except StopIteration:
|
||||||
|
raise errors.BuildProducedNoWheelError() from None
|
||||||
|
|
||||||
if built_wheel.name.endswith("none-any.whl"):
|
if built_wheel.name.endswith("none-any.whl"):
|
||||||
raise errors.NonPlatformWheelError()
|
raise errors.NonPlatformWheelError()
|
||||||
@@ -471,7 +474,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
else:
|
else:
|
||||||
shutil.move(str(built_wheel), repaired_wheel_dir)
|
shutil.move(str(built_wheel), repaired_wheel_dir)
|
||||||
|
|
||||||
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
|
try:
|
||||||
|
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
|
||||||
|
except StopIteration:
|
||||||
|
raise errors.RepairStepProducedNoWheelError() from None
|
||||||
|
|
||||||
if repaired_wheel.name in {wheel.name for wheel in built_wheels}:
|
if repaired_wheel.name in {wheel.name for wheel in built_wheels}:
|
||||||
raise errors.AlreadyBuiltWheelError(repaired_wheel.name)
|
raise errors.AlreadyBuiltWheelError(repaired_wheel.name)
|
||||||
|
|||||||
@@ -522,7 +522,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
case _:
|
case _:
|
||||||
assert_never(build_frontend)
|
assert_never(build_frontend)
|
||||||
|
|
||||||
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
try:
|
||||||
|
built_wheel = next(built_wheel_dir.glob("*.whl"))
|
||||||
|
except StopIteration:
|
||||||
|
raise errors.BuildProducedNoWheelError() from None
|
||||||
|
|
||||||
# repair the wheel
|
# repair the wheel
|
||||||
repaired_wheel_dir.mkdir()
|
repaired_wheel_dir.mkdir()
|
||||||
|
|||||||
Reference in New Issue
Block a user