#1149717 pybuild fails to build backports of packages with native versions

#1149717#5
Date:
2026-10-02 16:12:20 UTC
From:
To:
Hi!

I have been having trouble building backports of a package with
setuptools-scm as a build-dep.

lavamind eventually figured a hack out of this, which you can see
here:

https://gitlab.com/anarcat/asncounter/-/commit/5a5cbb3c5c78152af791da09c0230ec6818d16d0

which is essentially to add this to the debian/rules file:

export SETUPTOOLS_SCM_PRETEND_VERSION=$(shell dpkg-parsechangelog -SVersion | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~git.*//' -e 's/~bpo.*//' -e 's/~/.0/' -e 's/+dfsg1//' -e 's/+ds1//' | head -n 1)

... to override the "pretend" version.

Before that, the build would fail with:

packaging.version.InvalidVersion: Invalid version: '0.7.0-bpo13+1'

And, indeed, that is an invalid package version in Python:
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    version.Version("0.7.0-bpo13+1")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
packaging.version.InvalidVersion: Invalid version: '0.7.0-bpo13+1'

Normal Debian versions with dashes are okay, that said:
<Version('0.7.0.post1')>

I'm not sure what should be done to fix this. wRAR on #debian-python
suggested I file this bug report, but also that the `+` could be
replaced with a dash, but that doesn't work either:

packaging.version.InvalidVersion: Invalid version: '0.7.0-bpo13-1'

We *could* replace "bpo" with "pre" which would work and would even
mean something somewhat similar:
<Version('0.7.0rc13.post1')>
True

But really, as far as Python is concerned, I would just strip out any
debian specific stuff and stay with the upstream version, in this case
`0.7.0`.

The full build log is available at:

https://paste.lib3.net/lavamind/2026-09-29-xhBAI9DJyb8DNU2IHfJTDJLAQhw3qk9qzYWn5387UVg/stdin.txt

And can be reproduced by trying to backport the 0.7.0-1 asncounter
package without change.