From: Valters Jansons <valter.jansons@gmail.com>
To: location@lists.ipfire.org
Subject: [PATCH] debian: Build each Python version independently
Date: Fri, 30 Oct 2026 03:52:17 +0900 [thread overview]
Message-ID: <20261029185217.112691-1-valter.jansons@gmail.com> (raw)
The pybuild build system wants to build the Python module for each
Python version. We must ensure that Autoconf is triggered in a
different build directory each time. Otherwise, the builder will think
the source is already built and re-use the binary.
This is critical for when structs change in Python. Especially, if
someone were to build with three or more minor versions, as the ABI is
no longer guaranteed.
Lua and Perl testing remains configured against the default Python
version build.
Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
---
For testing this locally, check if `py3versions -i` reports multiple
Python versions as installed. Either /usr/share/python3/debian_defaults
may need modifying, or a PYBUILD_INTERPRETERS="python3.14 python3.15"
envvar should be set. The observed location.so should be different
between the Python versions.
CPython 3.15.2 headers have broken C extension builds when -Werror=undef
is set, as pyport.h references an undefined _Py_STDC_VERSION macro.
See https://github.com/python/cpython/issues/160719
Could pass `DEB_CFLAGS_MAINT_APPEND = -Wno-error=undef` to make Sid
build as of now. In any case, testing (forky) has 3.15.0 which is ok.
debian/rules | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/debian/rules b/debian/rules
index 12cb34f..c17b8e6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -21,24 +21,31 @@ ifneq (,$(filter nodoc,$(DEB_BUILD_PROFILES) $(DEB_BUILD_OPTIONS)))
CONFIGURE_MAN_PAGES = --disable-man-pages
endif
+# The pybuild build system wants to build the Python module for each Python version.
+# We must ensure that Autoconf is triggered in a different build directory each time.
+# Otherwise, the builder will think the source is already built and re-use the binary.
+AUTOTOOLS_ARGS = --buildsystem=autoconf --builddir=.pybuild/autotools-{version}
+# However, Lua tests will not run against all the build trees - only the default version.
+DEFAULT_BUILDDIR = .pybuild/autotools-$(shell py3versions -dv)
+
export PYBUILD_SYSTEM=custom
-export PYBUILD_CLEAN_ARGS=dh_auto_clean
+export PYBUILD_CLEAN_ARGS=true
export PYBUILD_CONFIGURE_ARGS=intltoolize --force --automake; \
- PYTHON={interpreter} dh_auto_configure -- \
+ PYTHON={interpreter} dh_auto_configure $(AUTOTOOLS_ARGS) -- \
$(CONFIGURE_MAN_PAGES) --disable-perl --with-systemd
-export PYBUILD_BUILD_ARGS=dh_auto_build
-export PYBUILD_INSTALL_ARGS=dh_auto_install --destdir={destdir}; \
+export PYBUILD_BUILD_ARGS=dh_auto_build $(AUTOTOOLS_ARGS)
+export PYBUILD_INSTALL_ARGS=dh_auto_install $(AUTOTOOLS_ARGS) --destdir={destdir}; \
mkdir -p {destdir}/usr/lib/python{version}/dist-packages; \
mv {destdir}/usr/lib/python3/dist-packages/_location.so {destdir}/usr/lib/python{version}/dist-packages/_location.so; \
rm -f {destdir}/usr/lib/python3/dist-packages/_location.la {destdir}/usr/lib/*/libloc.la
-export PYBUILD_TEST_ARGS=dh_auto_test
+export PYBUILD_TEST_ARGS=dh_auto_test $(AUTOTOOLS_ARGS)
%:
dh $@ --buildsystem=pybuild
execute_after_dh_auto_configure:
dh_auto_configure $(PERL_MM) -- INC=-I$(CURDIR)/src LIBS= \
- 'LDFROM=$$(OBJECT) -L$(CURDIR)/src/.libs -lloc'
+ 'LDFROM=$$(OBJECT) -L$(CURDIR)/$(DEFAULT_BUILDDIR)/src/.libs -lloc'
# The module does not link against Lua, which the program that loads it provides,
# so that it does not pull in Lua 5.1 when it is being loaded by LuaJIT
@@ -46,8 +53,8 @@ execute_after_dh_auto_build:
set -e; for version in $(LUA_EXTRA_VERSIONS); do \
mkdir -p debian/lua$$version; \
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC \
- -include config.h -Isrc $$($(PKG_CONFIG) --cflags lua$$version) \
- -o debian/lua$$version/location.so src/lua/*.c -Lsrc/.libs -lloc; \
+ -include $(DEFAULT_BUILDDIR)/config.h -Isrc $$($(PKG_CONFIG) --cflags lua$$version) \
+ -o debian/lua$$version/location.so src/lua/*.c -L$(DEFAULT_BUILDDIR)/src/.libs -lloc; \
done
dh_auto_build $(PERL_MM)
@@ -66,16 +73,16 @@ execute_after_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
set -e; for version in $(LUA_EXTRA_VERSIONS); do \
- LD_LIBRARY_PATH=$(CURDIR)/src/.libs \
+ LD_LIBRARY_PATH=$(CURDIR)/$(DEFAULT_BUILDDIR)/src/.libs \
LUA_CPATH="$(CURDIR)/debian/lua$$version/?.so;;" \
TEST_DATABASE=$(CURDIR)/data/database.db \
TEST_SIGNING_KEY=$(CURDIR)/data/signing-key.pem \
- lua$$version tests/lua/main.lua; \
+ lua$$version $(DEFAULT_BUILDDIR)/tests/lua/main.lua; \
done
- $(MAKE) testdata.db
- LD_LIBRARY_PATH=$(CURDIR)/src/.libs \
- database=$(CURDIR)/testdata.db \
+ $(MAKE) -C $(DEFAULT_BUILDDIR) testdata.db
+ LD_LIBRARY_PATH=$(CURDIR)/$(DEFAULT_BUILDDIR)/src/.libs \
+ database=$(CURDIR)/$(DEFAULT_BUILDDIR)/testdata.db \
keyfile=$(CURDIR)/examples/public-key.pem \
dh_auto_test $(PERL_MM)
endif
--
2.56.0
reply other threads:[~2026-10-29 18:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029185217.112691-1-valter.jansons@gmail.com \
--to=valter.jansons@gmail.com \
--cc=location@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox