On 04-09-2022 22:52, Miro Hrončok wrote:
On 04. 09. 22 22:08, Sandro wrote:
On 04-09-2022 20:42, Miro Hrončok wrote:
On 04. 09. 22 14:15, Sandro wrote:
Hi,

Hi.

I'm tinkering with a package in review, trying to understand the Python RPM
build process. The package is hatch-fancy-pypi-readme [1].

The package uses hatch for build, but it includes a non-license file,
AUTHORS.md, which I thought would be trivial to patch around, so it's not
included in the RPM.

I don't understand why do you want to do this in the first place. What is the
issue with the file?

Well, fedora-review complains about the file not being included in the package
as %license. There's more details in the package review:

https://bugzilla.redhat.com/show_bug.cgi?id=2123618

An automated tool complains about that file not being marked as %license. I
don't understand why is that a reason to remove it entirely. I've commented on
the bugzilla for other options.

Thank you for your input. Removing the file is just one option, of course, and possibly not the best. Adding it to %doc is what I suggested in the review when fedora-review complaint.

I was in tinkering mood and I actually learned quite a bit along the way. What I didn't expect was tests failing once AUTHORS.md is removed.


I patched the pyproject.toml and added:

[tool.hatch.build]
exclude = ["AUTHORS.md"]

I don't know hatch, so I cannot tell whether this does something useful.
Note that upstream has committed
https://github.com/hynek/hatch-fancy-pypi-readme/commit/3b17e39c which might
solve this (or not, not sure).

I don't know much about Hatch myself, but that's the Hatch way of excluding
files according to their documentation. But since Hatch does not appear to be
used in the RPM build process, this has no effect.

I am pretty sure hatch *is* used during the build. It creates the licenses
directory in
/usr/lib/python3.11/site-packages/hatch_fancy_pypi_readme-22.3.0.dist-info/licenses/

It is indeed as can be seen in the output of 'python3 -m build':

* Installing packages in isolated environment... (hatchling)

Then I realized %pyproject_buildrequires has the option -w enabled, producing a
wheel for metadata extraction. So, I added a patch, putting a MANIFEST.in in
the root dir of the project with one line:

exclude AUTHORS.md

The MANIFEST.in file does not say which files will be installed. It is used by
distutils and/or setuptools to determine which files will be in the source
tarball. I am not entirely sure if hatch reads that file at all.

Clear.

Yet, strangely enough with the described MANIFEST.in in place and running
'python3 -m build --sdist', the resulting tar.gz archive still has the
AUTHORS.md file in it.

That only confirms what I thought: hatch does not even read this file. It is
distutils/setuptools specific.

Understood. Beginners mistake on my part.

Yet the whl archive still contains the file:

hatch_fancy_pypi_readme-22.3.0.dist-info/licenses/AUTHORS.md

and so does the final RPM.

Do I have to resort to manually removing the file in %prep?

If you insist on removing that file, deleting it in %prep sounds like much
easier option than patching pyproject.toml. However, I'd keep it.

Here is where it gets interesting.

I can not do without the file or the tests will fail. See the review bug
mentioned above. Just add a 'rm -f AUTHORS.md' to %prep in the spec file.

But keeping it around, fedora-review (rpmlint) will keep complaining about its
presence as a not included license file since it is installed in the license
dir together with the LICENSE.txt file.

fedora-review is not always right. Please don't try to do ugly things to make
it happier. Anyway, see https://bugzilla.redhat.com/show_bug.cgi?id=2123618#c6

I encountered another issue with %pyproject_buildrequires when passing the -t
option for automatic test requirements.

I wanted to see if I can get rid of the extra BuildRequires in the submitters
spec file [2], so I commented out all but python3-dev and python3-test
BuildRequires and added -t to %pyproject_buildrequires.

That made the build fail with:

No matching package to install: 'python3dist(pytest-icdiff)'

Yet, I don't see any test or other python module importing icdiff. Building
with the original spec file, tests are run and succeed.

Is that a known issue with the -t option? Or am I missing something?

The pytest-icdiff dependency is listed by upstream as their test dependency for
tox (-t stands for tox):

https://github.com/hynek/hatch-fancy-pypi-readme/blob/22.3.0/tox.ini#L49 ->
https://github.com/hynek/hatch-fancy-pypi-readme/blob/22.3.0/pyproject.toml#L50

Thank you for the pointer. I missed looking in the pyproject.toml file. I
searched in the tests dir.

The -t option reads that and generates the BuildRequires. If it is not needed,
I suggest talking to upstream about why is this listed. In the meantime, you
have 2 options to avoid the unwanted dependency:

    - don't use -t and list test dependencies manually instead
    - patch/sed it out from pyproject.toml

It looks like it's not being used (any more). Building the package without -t
and without listing python3dist(pytest-icdiff), which is not even available in
Fedora, succeeds.

The package is for fancier diffs when tests fail. It seems to be what upstream
prefers when they run tests but I agree that it is not important in the RPM
package. Similarly, upstream lists coverage as their test dependency and we
should not depend on that downstream, see
https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters

Adding insult to injury, when I first searched for icdiff in the checkout I was on main branch, where the dependency has since been removed. That's why I couldn't find it and found the error hard to grasp.

Thanks for your help. I'll stop tinkering now. ;)

-- Sandro
_______________________________________________
python-devel mailing list -- python-devel@lists.fedoraproject.org
To unsubscribe send an email to python-devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to