Check requirements.txt against existing packages

Given pip requirements.txt file, is there a command to check which Python packages there are already packed for Fedora ?

1 Like

FPM is somehow able to detect Fedora packages from Python dependencies.

It doesn’t detect anything, near as I can tell. It just reads in requirements.txt and generates its internal dependency list, then blindly munges that dependency data into Requires: lines.

(There’s even some special-casing in rpm.rb for rubygem dependencies, specifically:)

# Convert 'rubygem-foo' provides values to 'rubygem(foo)'
# since that's what most rpm packagers seem to do.

There’s nothing I can find in the code that verifies the actual existence of those dependencies as available packages, and their names will only be correct if the packager followed the same formula in generating the package name.

All Python packages provide a standardized name. So given a name in the file, you can look up the equivalent Provides with:

$ rpm -E '%{py3_dist a-name-from-the-list}'

and you can see if a package exists by checking:

$ dnf repoquery --provides 'python3dist(a-name-from-the-list)'
# Should return nothing since this is a made up name.

So with a bit of scripting around the requirements list, you should be able to determine whether all the packages are available.