← All tasks
pythonClickHouse/clickhouse-connect #994Not a task: already works

Don't silently fall back to a pure-Python build when the C extensions fail to compile

envgap__ClickHouse__clickhouse-connect-994

01 / FAILURE SIGNATURE

As reported upstream

entire `setup()` call — an unparsable `_version.py`, a packaging error, an I/O
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
ee03571679d161c6865fb31486a2b013fe718a4d
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

ClickHouse/clickhouse-connect #994 · read the original issue
### Summary

`setup.py` currently falls back to a pure-Python build whenever the C
extensions can't be compiled, and the install still reports success. I'd like
that fallback to be removed: the build should fail loudly instead. The opt-out
already exists — `CLICKHOUSE_CONNECT_SKIP_CYTHON=1` — so users who genuinely
want a pure-Python install can already ask for it explicitly.

### Motivation

A failing extension build almost always means one of two things:

1. an environment where Cython genuinely isn't an option (unusual CPU
   architecture, alternative Python implementation);
2. a misconfigured build environment — no C compiler, missing Python
   development headers.

The second case is by far the more common one, and it's exactly the case the
silent fallback hurts. The install succeeds, and the user ends up running a
significantly slower driver without ever being told. Case (1) is already
covered by the existing `CLICKHOUSE_CONNECT_SKIP_CYTHON` gate.

### The fallback is broader than it looks

The outer handler doesn't just catch compilation problems:

```python
try:
    run_setup()
except (OSError, Exception, SystemExit) as e:
    print(f"Unable to compile C extensions for faster performance due to {e}, will use pure Python")
    run_setup(False)
```

`Exception` plus `SystemExit` covers essentially every failure mode of the
entire `setup()` call — an unparsable `_version.py`, a packaging error, an I/O
error — and reports all of them as "unable to compile C extensions". Unrelated
build bugs get hidden behind a misleading message. (`OSError` is also redundant
here; it's a subclass of `Exception`.)

### Proposal

- Drop the outer `run_setup(False)` fallback entirely.
- Let the `ImportError` / `Exception` handlers around `cythonize()` re-raise
  rather than setting `cythonize = None`, ideally with a hint about the likely
  cause (missing compiler or Python headers).
- Keep `CLICKHOUSE_CONNECT_SKIP_CYTHON=1` as the single, explicit way to get a
  pure-Python build, and document it in the installation docs.

Applying this on all platforms would be ideal; at minimum on Linux, where a
working toolchain is a reasonable expectation for a source build.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]