python-build: log configure and make invocations, with build variables (only flavors using the CPython build command) (#3641)

This commit is contained in:
Rohit Mulani authored and GitHub committed 2026-11-19 01:38:15 +03:00
1 parent 2fbba7f390
commit 186b350c85
3 files changed
+69 -3

No files matched your search

+19 -3
View File
@@ -979,6 +979,22 @@ build_package_warn_unsupported() {
} >&3
}
# Write a command to stdout (the build log) together with the build-related
# environment variables that are set, so the line can be copy-pasted and rerun
# by hand from the build directory. Then run the command.
log_and_run() {
local var line=""
for var in CC CFLAGS CPPFLAGS LDFLAGS LIBS PKG_CONFIG_PATH \
MACOSX_DEPLOYMENT_TARGET KERNEL_BITS TCLTK_CFLAGS TCLTK_LIBS; do
if [ -n "${!var}" ]; then
line="${line}${var}=$(printf '%q' "${!var}") "
fi
done
line="${line}$(printf '%q ' "$@")"
echo "python-build: running: ${line% }"
"$@"
}
build_package_standard_build() {
local package_name="$1"
@@ -1055,11 +1071,11 @@ build_package_standard_build() {
if [ -z "$CC" ] && is_mac -ge 1010; then
export CC=clang
fi
${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
log_and_run ${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
"${!PACKAGE_CONFIGURE_OPTS_ARRAY}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} || return 1
) >&4 2>&1
{ "$MAKE" "${!PACKAGE_MAKE_OPTS_ARRAY}" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS}
{ log_and_run "$MAKE" "${!PACKAGE_MAKE_OPTS_ARRAY}" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS}
} >&4 2>&1
}
@@ -1071,7 +1087,7 @@ build_package_standard_install() {
local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]"
local PACKAGE_MAKE_INSTALL_TARGET="${package_var_name}_MAKE_INSTALL_TARGET"
{ "$MAKE" "${!PACKAGE_MAKE_INSTALL_TARGET:-install}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}"
{ log_and_run "$MAKE" "${!PACKAGE_MAKE_INSTALL_TARGET:-install}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}"
} >&4 2>&1
}
+46
View File
@@ -152,6 +152,52 @@ make python_make_install_target make_install_opt1 make_install_opt2 python_make_
OUT
}
@test "configure and make commands are written to the build log with the build variables" {
export TMPDIR="$BATS_TEST_TMPDIR"
export YAML_CFLAGS="yaml_cflag1 yaml_cflag2"
export CONFIGURE_OPTS="configure_opt1"
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
stub uname '-s : echo Linux'
stub brew false
stub_make_install
stub_make_install
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub make
local log
log="$(cat "$BATS_TEST_TMPDIR"/python-build.*.log)"
run grep -F "python-build: running: " <<<"$log"
assert_success
# 2 packages x (configure, make, make install)
[ "${#lines[@]}" -eq 6 ]
# yaml: package flags are shown on its configure line, quoted so it can be pasted back
run grep -F "./configure --prefix=$INSTALL_ROOT configure_opt1" <<<"$log"
assert_success
assert_output_contains "CC=cc "
assert_output_contains "CFLAGS=yaml_cflag1\\ yaml_cflag2 "
assert_output_contains "CPPFLAGS=-I${BATS_TEST_TMPDIR}/install/include "
# Python: no package flags of its own, so no CFLAGS
run grep -F "./configure --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib configure_opt1" <<<"$log"
assert_success
assert_output_contains "CC=cc "
refute grep -qF "CFLAGS=" <<<"$output"
run grep -F " make -j 2" <<<"$log"
assert_success
run grep -F " make install" <<<"$log"
assert_success
}
@test "apply python patch before building" {
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
+4
View File
@@ -140,11 +140,15 @@ exec 4<&1
build_package_standard python
DEF
assert_success
local flags="CPPFLAGS=-I${BATS_TEST_TMPDIR}/install/include LDFLAGS=-L${BATS_TEST_TMPDIR}/install/lib\ -Wl\,-rpath\,${BATS_TEST_TMPDIR}/install/lib LIBS=-L${BATS_TEST_TMPDIR}/install/lib\ -Wl\,-rpath\,${BATS_TEST_TMPDIR}/install/lib MACOSX_DEPLOYMENT_TARGET=10.10"
assert_output <<OUT
python-build: running: CC=clang $flags ./configure --prefix=$INSTALL_ROOT --enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib
./configure --prefix=$INSTALL_ROOT --enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib
CC=clang
CFLAGS=no
python-build: running: $flags make -j 2
make -j 2
python-build: running: $flags make install
make install
OUT