Bug#1011937: python-debian: Please consider moving deb822 to a standalone distro-independent Python package

Stuart Prescott stuart at debian.org
Sat May 28 15:51:10 BST 2022


Hi Stephan,

On Friday, 27 May 2022 20:09:29 AEST Jelmer Vernooij wrote:
> On Fri, May 27, 2022 at 12:01:17PM +0200, Stephan Lachnit wrote:
> > I'm not an expert on python-debian and I don't use other distros than
> > Debian, so I can only forward you some bug reports from

Thanks! I'd spotted one of these in the past but not others.

> > https://github.com/fsfe/reuse-tool/issues/466:

I'd definitely rather make python-debian more portable than have projects 
forking bits of it into local vendored versions. Vendoring code creates 
technical debt and is somewhat antithetical to the idea of making code more 
reusable.

> > - https://github.com/fsfe/reuse-tool/issues/425: `apt_pkg.Error:
> > W:Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such
> > file or directory), E:Unable to determine a suitable packaging system
> > type`

As already noted, python-debian works fine without python-apt installed; the 
unexpected situation here is that python-apt is installed but non-functional 
in some way. I'm not sure whether the bug is really that a non-functional 
python-apt is installed, but if we can work around it, then even better.

I have a feeling that we can change the way we use apt_pkg these days and that 
we can avoid generating that error. I need to talk to the python-apt people 
about that, but also I also need a way of reproducing an environment where a 
non-functional python-apt is installed so that I can test this out. 


From https://salsa.debian.org/python-debian-team/python-debian/-/
merge_requests/85 

> > Since Alpine really doesn't offer anything, a lot of fail because of
> > missing `bin/ar`, which is an excellent test for a non-Debian-standard
> > environment. Not sure how this should be handled best though: maybe
> > something similar to the `have_apt_pkg` variable?

This is only the tests and in particular, it's making the test data -- ArFile 
and DebFile are actually much more portable (except for the zstd compressed 
.debs where there remain portability problems because of the requirement for a 
zstd binary). It's only the tests that need the 'ar' binary and nothing in the 
module code itself. 

There's a few options here: 

* require that ar be installed for the purposes of testing just as we do in 
Debian; this is an explicit dependency in Debian, not something that happens 
to be there because more batteries are included. The binutils package gives us 
ar and is listed in debian/control, it's just that Python hasn't come up with 
a way of expressing such dependencies in setup.py or similar. For alpine, ar 
is in the binutils package and there are a few different versions available 
for windows, such as via a gcc package from choco.

* use something else to make the .deb files for the test suite. I could imagine 
a fallback for missing ar(1) that uses a pure python ar implementation that 
can be installed via pip on these other platforms. The arpy module can't make 
ar files at present which is a shame; the `unix_ar` or `ar` modules look 
promising for that, there might be others.

	https://github.com/getninjas/unix_ar
	https://github.com/vidstige/ar

* skip the tests that need ar; in practice, that's probably all the tests from 
debian/tests/test_debfile.py, and so a module level skip might be appropriate, 
with something like 
```
pytestmark = pytest.mark.skipif(not shutil.which("ar"), reason="...")
```
I'm cautious about automatically skipping tests because that's a route to non-
determinism, accidentally skipping tests, and therefore missing problems. 
However, we do that for python-apt already, so there's precedent already in 
the code; I'd be fine with that as a short term solution in advance of 
something better.

Thanks in advance for your contribution to python-debian :)

cheers
Stuart


-- 
Stuart Prescott    http://www.nanonanonano.net/   stuart at nanonanonano.net
Debian Developer   http://www.debian.org/         stuart at debian.org
GPG fingerprint    90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7



More information about the pkg-python-debian-maint mailing list