On 11/19/20 6:02 PM, Richard W.M. Jones wrote:
It's not a big deal because I added the Python Requires: line by hand, but I want to make sure I understand why it happens and whether there's an easy fix.
https://koji.fedoraproject.org/koji/taskinfo?taskID=55889416 https://src.fedoraproject.org/rpms/nbdkit/blob/master/f/nbdkit.spec#_475
This subpackage contains a Python file:
$ rpm -qlp ./nbdkit-S3-plugin-1.23.9-1.fc34.x86_64.rpm /usr/lib64/nbdkit/plugins/nbdkit-S3-plugin <--- this one /usr/share/doc/nbdkit-S3-plugin /usr/share/doc/nbdkit-S3-plugin/README /usr/share/licenses/nbdkit-S3-plugin /usr/share/licenses/nbdkit-S3-plugin/LICENSE /usr/share/man/man1/nbdkit-S3-plugin.1.gz
The automatically generated dependencies don't pick up the need for python3-boto3.
$ grep ^import nbdkit-S3-plugin import nbdkit import boto3
$ rpm -qRp ./nbdkit-S3-plugin-1.23.9-1.fc34.x86_64.rpm /usr/sbin/nbdkit nbdkit-python-plugin >= 1.22 rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(PayloadIsZstd) <= 5.4.18-1
(As I said above, I added it explicitly, which is why the RPM built in Koji above _does_ contain the boto3 dependency).
Now admittedly the Python file doesn't end in .py and doesn't have a python shebang at the top. But:
$ file nbdkit-S3-plugin nbdkit-S3-plugin: Python script, ASCII text executable
which seems as if it matches the %__python_magic regexp in /usr/lib/rpm/fileattrs/python.attr. So perhaps it _ought_ to work and something is wrong on the machine I'm using to reproduce this?
Alternatively is there another way to tell the dependency generator to take a special look at this file?
There are three dependency generators for Python and neither of them does what you ask here.
/usr/lib/rpm/fileattrs/python.attr
This file makes sure that files installed into /usr/lib(64)/pythonX.Y require python(abi) = X.Y.
/usr/lib/rpm/fileattrs/pythondist.attr
This file makes sure that Python packages (upstream term) require other Python packages. E.g. that requests requires idna, chardet and urllib3. This is read from upstream meatadata (.dist-info or egg-info directories/files). It has nothing to do with imports. See for example data in /usr/lib/python3.9/site-packages/requests-2.24.0-py3.9.egg-info/requires.txt.
/usr/lib/rpm/fileattrs/pythonname.attr
This file makes sure that packages called python3-requests provide python-requests and python3.9-requests.
There is no generator that parses Python imports (and never has been), sorry.