pybuild-plugin-pyproject can be used along with dh-python to build Python packages using the system described in PEP 517 rather than the old-style setup.py build and setup.py install. This is a requirement for packages that use any of the newer Python build systems (flit, hatchling, poetry-core, etc.), but it can also be used for packages using setuptools.
Since setup.py install is deprecated upstream, we need to switch all packages that use dh-python (or dh-sequence-python3) over to use pybuild-plugin-pyproject as well, unless they override all the debhelper commands that call setup.py. In simple cases, this can be done by adding pybuild-plugin-pyproject to Build-Depends. debdiff should show the same binary package contents, except that /usr/lib/python3/dist-packages/*.egg-info/ directories are replaced by /usr/lib/python3/dist-packages/*.dist-info/ directories with somewhat different files.
However, there are various things that can go wrong with the conversion process:
Some packages have a setup.py but also a pyproject.toml that uses a non-setuptools build backend, in which case switching to pybuild-plugin-pyproject will change the build system. Those cases will require changing Build-Depends from python3-setuptools to something else, depending on the value of build-system in pyproject.toml, and extra attention to make sure that the resulting binary packages still behave in the same way.
Tests may start failing because pre-PEP-420 namespace packages are no longer found while running tests. See zope.deprecation for how to work around this when using zope.testrunner, or zope.security for how to work around this when using pytest.
Temporary files created by tests may leak into binary packages at the top level of dist-packages, which can cause new unintended conflicts between binary packages. Check debdiff output carefully, and use PYBUILD_AFTER_TEST := rm -f {build_dir}/... as needed (e.g. python-lz4).
Similarly, packages that use something like where = ["."] in pyproject.toml can result in new unwanted files being added to the top level of dist-packages. Again, check debdiff output carefully, and either fix pyproject.toml to be more selective or compensate using an execute_after_dh_auto_install rule.
Multi-Arch: same may need to be removed from packages shipping architecture-dependent extensions, since the Tag field in *.dist-info/WHEEL files will be different on different architectures.
Previous problems, now fixed:
Packages that use the headers parameter to setup used to fail (1115299); use Build-Depends: pybuild-plugin-pyproject (>= 6.20251204.1~) in this case.
1121735 requests a Lintian tag for packages using the deprecated system.
