Hi,

recently there have been two independent changes in the Python and
CMake world which conspired to FTBFS a number of packages.

TL;DR: export DEB_PYTHON_INSTALL_LAYOUT=deb_system in d/rules

The first change introduced a Debian-specific 'posix_local'
installation scheme to sysconfig [1]. This change occurred because
distutils is now deprecated, and we wanted to retain a long-standing
distutils.sysconfig behavior: It has diverted user installs to
/usr/local/lib, to prevent locally built packages from messing with
the dpkg-managed /usr/lib directory.

However, the distutils.sysconfig API also had a "is_plat_specific"
switch which caused the API to return /usr/lib/python3/dist-packages
anyway; many build tools such as CMake and meson exploited it to
avoid the diversion, limiting the effect to "pip install" and
friends. The newer sysconfig API is slightly different, with
"schemes" for different sets of installation paths. Most
importantly, it no longer has a simple "is_plat_specific" override.

This brings us to the second change: CMake 3.27 migrated from the
deprecated distutils.sysconfig to sysconfig, which caused it to use
/usr/local/lib paths for Python builds now. This is actually what we
wanted in the first place, because user-built CMake projects should
never have installed to /usr/lib/python3. However, a few Debian
packages have also relied on the old, broken behavior, which is
why about 30 packages have been hit by FTBFS bugs from Lucas' latest
archive rebuild ("dh_install: error: missing files, aborting")

The patched sysconfig and distutils.sysconfig modules in Debian
have a (somewhat poorly documented) override for package
builds: set the DEB_PYTHON_INSTALL_LAYOUT environment variable to
"deb_system". This is used internally by pybuild, which is why
most Python packages never noticed the changes. Maintainers of Python
packages which do not use pybuild need to set this variable
manually.

Alternatively, there is also a CMake plugin for pybuild, which
automatically takes care of everything and even builds the sources
for all available Python versions:

    export PYBUILD_SYSTEM = cmake
    export PYBUILD_CONFIGURE_ARGS = <extra CMake arguments>

    %:
        dh $@ --buildsystem=pybuild


The latter solution is more robust against other potential future
changes in the Python ecosystem, but it is more involved to get to
work with some packages.


Cheers
Timo

N.B. It looks like Meson has been affected in a similar way [2].


[1] https://lists.debian.org/debian-python/2022/03/msg00039.html
[2] https://bugs.debian.org/1041537

--
⢀⣴⠾⠻⢶⣦⠀   ╭────────────────────────────────────────────────────╮
⣾⠁⢠⠒⠀⣿⡁   │ Timo Röhling                                       │
⢿⡄⠘⠷⠚⠋⠀   │ 9B03 EBB9 8300 DF97 C2B1  23BF CC8C 6BDD 1403 F4CA │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯

Attachment: signature.asc
Description: PGP signature

Reply via email to