Make builds incremental by preserving source/build dirs (#45)

This commit is contained in:
Adeeb Shihadeh
2026-03-04 09:17:55 -08:00
committed by GitHub
parent 2e9aed768a
commit 331d94a683
37 changed files with 221 additions and 367 deletions

View File

@@ -4,25 +4,18 @@ set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$DIR"
VERSION="3.12.8"
VERSION="v3.12.8"
INSTALL_DIR="$DIR/python3_dev/install"
# Idempotent: skip if already present
if [ -f "$INSTALL_DIR/include/Python.h" ]; then
echo "python3-dev headers already present, skipping."
exit 0
# Clone/update source
if [ ! -d "python3-src/.git" ]; then
rm -rf python3-src
git clone --depth 1 https://github.com/python/cpython.git python3-src
fi
git -C python3-src fetch --depth 1 origin "$VERSION"
git -C python3-src checkout --force FETCH_HEAD
TARBALL="Python-${VERSION}.tgz"
URL="https://www.python.org/ftp/python/${VERSION}/${TARBALL}"
echo "Downloading CPython ${VERSION} source ..."
curl -fSL -o "$TARBALL" "$URL"
echo "Extracting ..."
tar xzf "$TARBALL"
cd "Python-${VERSION}"
cd python3-src
# Run configure to generate pyconfig.h for this platform
echo "Running configure to generate pyconfig.h ..."
@@ -34,11 +27,8 @@ cd "$DIR"
rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/include"
cp -r "Python-${VERSION}/Include/"* "$INSTALL_DIR/include/"
cp "Python-${VERSION}/pyconfig.h" "$INSTALL_DIR/include/"
# Clean up
rm -rf "Python-${VERSION}" "$TARBALL"
cp -r python3-src/Include/* "$INSTALL_DIR/include/"
cp python3-src/pyconfig.h "$INSTALL_DIR/include/"
echo "Installed python3-dev headers to $INSTALL_DIR"
du -sh "$INSTALL_DIR"