Package: lintian
Version: 2.116.3
Severity: normal
X-Debbugs-Cc: debian-pyt...@lists.debian.org

The current recommended way for packaging python packages (upstream)
is to provide a pyproject.toml file and build with setuptools
(python3-setuptools).  Debian python package building activates this
build method with
  Build-Depends: dh-python, pybuild-plugin-pyproject

There are a number of different ways in which python packages maintain
their version (within the package, not the debian version). One of
these methods is setuptools_scm, https://github.com/pypa/setuptools_scm/

setuptools_scm is activated by including a [tool.setuptools_scm]
section in the package's pyproject.toml file.

setuptools_scm often operates by overwriting any existing version.py
file that might be present in the source tarball, and in some cases
this generates very weird version numbers based on local git tags.

That behaviour can be annoying for debian packaging, but
setuptools_scm has provided a mechanism to make life easier for
package distribution systems. If the environment variable
SETUPTOOLS_SCM_PRETEND_VERSION is set, then setuptools_scm does not
overwrite the existing version file. This mechanism is documented
upstream at https://github.com/pypa/setuptools_scm/

pybuild is smart enough to know about SETUPTOOLS_SCM_PRETEND_VERSION
(see /usr/share/perl5/Debian/Debhelper/Buildsystem/pybuild.pm)
But it only processes this if python3-setuptools-scm has been included
in Build-Depends (more precisely, l.130
  if ((grep /python3-(setuptools-scm|hatch-vcs)/, @deps)

This behaviour is not obvious, so it's a good opportunity for lintian
to help debian python packages, by suggesting to add
  Build-Depends: python3-setuptools-scm 
when needed, if it's not already used.

The condition could be

1) debian/control has Build-Depends: dh-python, pybuild-plugin-pyproject
2) source has pyproject.toml containing [tool.setuptools_scm]
3) debian/control does not have Build-Depends: python3-setuptools-scm
 [3b) and debian/rules does not set SETUPTOOLS_SCM_PRETEND_VERSION manually]
then
  emit warning (or error) suggesting to add
    Build-Depends: python3-setuptools-scm

Reply via email to