#590088 apt: source package handling is slow and cumbersome

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Colin Watson
Date:
2015-08-18 12:09:05 UTC
Severity:
wishlist
#590088#5
Date:
2010-06-10 14:19:34 UTC
From:
To:
I have an application (lp:xdeb) that needs to get source package records
in order to manipulate them in various ways.  Unfortunately:

  >>> import apt
  >>> import apt_pkg
  >>> import timeit
  >>> sr = apt_pkg.SourceRecords()
  >>> timer = timeit.Timer('sr.lookup("man-db")', 'from __main__ import sr')
  >>> timer.timeit(1000)
  28.415705919265747

This interface is really slow, because it has to reparse the text of the
Sources files over and over again.  There doesn't appear to be a better
way to do this within python-apt.  The cache only covers binary package
records, and the Python bindings for SourceRecords only expose lookup()
and restart() but not e.g. step(), so there isn't even any way to build
a cache outside python-apt.

I ended up using 'apt-get --print-uris update' to get a list of Sources
file names and feeding them through python-debian's parser, but this is
of course pretty awful, not to mention rather slow in itself - I end up
with a long delay on startup while the cache builds.  (On reflection, I
could probably use apt_pkg.TagFile, which has a step() method that might
be faster.)

Ideally, though, I'd like source package records to be more like
first-class citizens in apt/python-apt rather than feeling a bit like
afterthoughts, and to have their own cache and wrapper objects so that
e.g. apt.SourceCache()[src] can return an apt.Package.Source object,
which might have methods like fetch_source() and
install_build_dependencies() as well as offering attribute access.
Would this be at all feasible?

Thanks,

#590088#10
Date:
2010-07-23 14:43:15 UTC
From:
To:
clone 585432 -1
reassign -1 apt
retitle -1 apt: source package handling is slow and cumbersome
block 585432 by -1
thanks

Cloned to APT.

#590088#27
Date:
2011-04-12 10:11:26 UTC
From:
To:
I have an idea which rewrites source packages into binary ones, and
build-dependencies to standard dependencies.

Let's imagine we have the source package foobar:
    Package: foobar
    Architecture: any
    Build-Depends: foo [i386], bar [amd64]

There are three solutions I can imagine:

[SOL-A]  foobar:src:i386 depends on foo
         foobar:src:amd64 depends on bar
[SOL-B]  foobar:src depends on foo:i386 | bar:amd64
[SOL-C]  foobar:src depends on foo[i386] | bar[amd64]

SOL-A should work right out of the box with all features APT supports,
SOL-B doesn't really work, and SOL-C would require lots of work. We
would strip out any information about architectures not listed in
APT::Architectures, though.