Skip to content

Commit 0b16b60

Browse files
committed
Export clean source for cibuildwheel
cibuildwheel copies the repository into its Linux build container. Ignored build outputs such as target/, virtual environments, and dist/ can make that context several gigabytes, slowing builds or exhausting Docker storage. Export tracked and non-ignored untracked files to a temporary source directory before invoking cibuildwheel. This keeps ignored artifacts out of the container context while preserving local changes for --allow-dirty builds. Assisted-by: OpenAI Codex
1 parent 4466ad2 commit 0b16b60

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

scripts/python_build_wheel.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ fi
123123

124124
CARGO_TARGET_DIR="$(mktemp -d /tmp/cargo-target-ldk-node-python-wheels.XXXXXX)"
125125
export CARGO_TARGET_DIR
126+
BUILD_SOURCE_DIR="$(mktemp -d /tmp/ldk-node-python-wheels-source.XXXXXX)"
126127
SOURCE_DATE_EPOCH="$(git show -s --format=%ct HEAD)"
127128
export SOURCE_DATE_EPOCH
128129

@@ -132,16 +133,30 @@ cleanup() {
132133
rm -rf -- "$CARGO_TARGET_DIR"
133134
;;
134135
esac
136+
case "$BUILD_SOURCE_DIR" in
137+
/tmp/ldk-node-python-wheels-source.*)
138+
rm -rf -- "$BUILD_SOURCE_DIR"
139+
;;
140+
esac
135141
}
136142
trap cleanup EXIT
137143

144+
git ls-files --cached --others --exclude-standard -z | while IFS= read -r -d '' source_path; do
145+
if [[ -e "$source_path" || -L "$source_path" ]]; then
146+
printf '%s\0' "$source_path"
147+
fi
148+
done | tar --null --files-from=- -cf - | tar -xf - -C "$BUILD_SOURCE_DIR"
149+
138150
echo "Building Python wheel from commit $(git rev-parse HEAD)"
139151
echo "Build host: $HOST_OS $HOST_ARCH"
140152

141-
uv tool run --python 3.11 --from "cibuildwheel[uv]==$CIBUILDWHEEL_VERSION" cibuildwheel \
142-
bindings/python \
143-
--config-file bindings/python/pyproject.toml \
144-
--output-dir "$OUTPUT_DIR"
153+
(
154+
cd "$BUILD_SOURCE_DIR"
155+
uv tool run --python 3.11 --from "cibuildwheel[uv]==$CIBUILDWHEEL_VERSION" cibuildwheel \
156+
bindings/python \
157+
--config-file bindings/python/pyproject.toml \
158+
--output-dir "$OUTPUT_DIR"
159+
)
145160

146161
built_wheels=("$OUTPUT_DIR"/*.whl)
147162
if [[ ${#built_wheels[@]} -ne $EXPECTED_WHEEL_COUNT ]]; then

0 commit comments

Comments
 (0)