'dnf python api: how to get rpms from modules to show up in available()?

I'm trying to use the dnf api (docs) from Python (i.e. not from the command line). Ultimately, my application is given a list of rpms, and it is trying to query dnf to recursively find all their dependent rpms. That's all working fine (pkg.requires, ...query().filter(provides=...) etc.)

The problem I'm having is that I can't seem to include rpms from modules in the set of rpms that dnf is working with (the package sack?).

The app does all the usual init, repo selection, fill sack, list available e.g.

dnf.Base.__init__(self)
self.read_all_repos()
repos = self.repos.all()
repos.disable()
repos = self.repos.get_matching('x')     # multiple of these for
repos.enable()                           # base, appstream etc
self.fill_sack(load_system_repo=False, load_available_repos=True)
q = self.sack.query().available()
for pkg in q:
  print('avail - {} - {}'.format(pkg, pkg.repoid))

The list printed includes all the rpms from the enabled repos EXCEPT any in modules, e.g. with the AppStream repo enabled, httpd is not included in the the available() list, httpd being a module within AppStream.

If I enabled the httpd module ...

...
self.fill_sack(load_system_repo=False, load_available_repos=True)
module_base = dnf.module.module_base.ModuleBase(self)
module_base.enable(['httpd:2.4'])
q = self.sack.query().available()
...

... the rpms from it still don't appear in the available() list?

Is there any way to get the module rpms to appear in the available() list, or do I have to handle them completely separately? e.g.

module_packages, nvscap = module_base.get_modules('*')
for mpkg in module_packages:
  for x in mpkg.getArtifacts():
    print('rpm {} in module {}'.format(x,mpkg.getName()))

The documentation is pretty minimal (read all of it, several times!) and requires lots of joining-up-the-dots. I've spent several hours fumbling around in the dark unsuccessfully trying to find a solution to this. Any clues/pointers grateful received! Thanks :-)



Solution 1:[1]

I found the answer. I just had to include module_hotfixes=true in the repo def file (/etc/yum.repos.d/x.repo). So obvious... :-/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 code9016