Skip to content

Commit 6ec3408

Browse files
tomcodgentkfoss
tomcodgen
andauthored
[CG-11271] feat: Build QOL improvement (#804)
# Motivation "The Python binaries uv installs were built using clang so they have CC=clang in their sysconfig. Thus, when using a uv-managed python when clang isn't available, pip also fails to build." [astral-sh/uv#8036 (comment)](astral-sh/uv#8036 (comment)) This results in distutils trying to use clang for hatch-cython build step as well, failing to properly use CC (which would resolve into clang/gcc/whatever sys has as default). # Testing Manually tested on latest Debian stable. --------- Co-authored-by: tomcodgen <[email protected]>
1 parent 4305776 commit 6ec3408

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ uv sync --dev
3939
> [!TIP]
4040
>
4141
> - If sync fails with `missing field 'version'`, you may need to delete lockfile and rerun `rm uv.lock && uv sync --dev`.
42-
> - If sync fails with failed compilation, you may need to install clang and rerun `uv sync --dev`.
42+
> - If sync fails with failed compilation, you may need to install dependencies (see [install-deps.sh](scripts/install-deps.sh)) and rerun `uv sync --dev`.
4343
4444
### Running Tests
4545

hatch.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version-file = "src/codegen/sdk/__init__.py"
66
allow-direct-references = true
77
[envs.hatch-build]
88
installer = "uv"
9+
910
[[envs.hatch-build.matrix]]
1011
tool = ["uv", "pip"]
1112

@@ -36,6 +37,14 @@ compile_args = [
3637
"darwin",
3738
], arch = "arm64", arg = "-mcpu=apple-m1" },
3839
]
40+
env = [
41+
{ env = "CC", arg = "cc", platforms = [
42+
"linux",
43+
] },
44+
{ env = "CC", arg = "clang", platforms = [
45+
"darwin",
46+
] },
47+
]
3948
cythonize_kwargs = { annotate = true, nthreads = 16, exclude_failures = false, cache = true }
4049
compiled_sdist = true
4150
compile_py = false

scripts/install-deps.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ if command -v sudo &> /dev/null; then
55
fi
66

77
if command -v apt &> /dev/null; then
8+
if ! (command -v clang &> /dev/null || command -v gcc &> /dev/null); then
9+
echo "Neither clang nor gcc found. Installing gcc..."
10+
$SUDO apt update && $SUDO apt install -y gcc build-essential python3-dev
11+
fi
12+
813
$SUDO apt update && $SUDO apt install -y jq \
14+
build-essential \
15+
python3-dev \
916
libpixman-1-dev \
1017
libcairo2-dev \
1118
libpango1.0-dev \

0 commit comments

Comments
 (0)