]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
build: track the python wheel with a stamp file
authorTobias Oetiker <tobi@oetiker.ch>
Tue, 19 May 2026 16:51:11 +0000 (18:51 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Tue, 19 May 2026 16:51:11 +0000 (18:51 +0200)
The python: target rebuilt the wheel unconditionally on every `make`,
including the implicit `all` that `make install` and `make check` both
depend on. A `sudo make install` therefore re-ran bdist_wheel as root
and left root-owned build/, dist/ and rrdtool.egg-info/ in the source
tree, which the next non-root `make check` could not remove -- the
unconditional `rm -rf` failed with "Permission denied" and broke CI.

Drive the build from a wheel.stamp file that depends on the python
sources, so `all` rebuilds the wheel only when a source actually
changed and re-runs are a no-op -- matching how the perl and ruby
targets already stay idempotent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bindings/Makefile.am

index 549059134e0aec8d8a72a8f93a92b90cb2c7ec7e..6b080d964492a22395b979304545f87628b0ce47 100644 (file)
@@ -61,19 +61,26 @@ ruby:
              ABS_TOP_BUILDDIR=${abs_top_builddir} \
              $(RUBY_MAKE_OPTIONS) RUBYARCHDIR= )
 
-# Build the python module as a wheel. It lands in ${builddir}/python/dist/
-# and is installed from there (via pip) by install-data-local. RRDTOOL_RPATH
-# tells setup.py to embed the install libdir as the extension's RPATH.
-python:
-       -mkdir -p ${builddir}/$@
-       cd ${builddir}/$@ \
-         && ( test -e rrdtoolmodule.c || ln -s ${abs_srcdir}/$@/rrdtoolmodule.c ) \
-         && rm -rf build dist rrdtool.egg-info \
+# Build the python module as a wheel in ${builddir}/python/dist/; it is
+# installed from there (via pip) by install-data-local. The wheel.stamp
+# target gives the build real dependency tracking, so re-running `all`
+# -- which `make install` and `make check` both do -- rebuilds the wheel
+# only when a source actually changed. That also stops a `sudo make
+# install` from leaving root-owned build artifacts that a later non-root
+# `make` cannot remove. RRDTOOL_RPATH tells setup.py to embed the
+# install libdir as the extension's RPATH.
+python: ${builddir}/python/wheel.stamp
+
+${builddir}/python/wheel.stamp: ${abs_srcdir}/python/rrdtoolmodule.c ${abs_srcdir}/python/setup.py
+       -mkdir -p ${builddir}/python
+       cd ${builddir}/python \
+         && ( test -e rrdtoolmodule.c || ln -s ${abs_srcdir}/python/rrdtoolmodule.c ) \
           && env \
                ABS_TOP_SRCDIR=${abs_top_srcdir} \
                ABS_TOP_BUILDDIR=${abs_top_builddir} \
                RRDTOOL_RPATH=$(PYTHON_RPATH_LIBDIR) \
-               $(PYTHON) ${abs_srcdir}/$@/setup.py bdist_wheel
+               $(PYTHON) ${abs_srcdir}/python/setup.py bdist_wheel
+       touch $@
 
 # rules for building the perl module
 perl-piped:
@@ -118,5 +125,5 @@ clean-local:
           && cd ${builddir}/ruby \
           && ( $(MAKE) clean || true ) \
           && rm -f Makefile )
-       -rm -rf ${builddir}/python/build ${builddir}/python/dist ${builddir}/python/rrdtool.egg-info
+       -rm -rf ${builddir}/python/build ${builddir}/python/dist ${builddir}/python/rrdtool.egg-info ${builddir}/python/wheel.stamp
 ##END##