Bug 2378640 - Zim: Stop using deprecated python setup.py build/install command in the spec
Summary: Zim: Stop using deprecated python setup.py build/install command in the spec
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: Zim
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Otto Liljalaakso
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2387002 2387023
Blocks: 2376118
TreeView+ depends on / blocked
 
Reported: 2025-07-08 15:39 UTC by Miro Hrončok
Modified: 2025-08-09 17:49 UTC (History)
3 users (show)

Fixed In Version: Zim-0.76.3-6.fc43
Clone Of:
Environment:
Last Closed: 2025-08-09 17:49:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources Zim pull-request 7 0 None None None 2025-08-04 22:25:10 UTC

Description Miro Hrončok 2025-07-08 15:39:41 UTC
Dear package maintainer,

this bugzilla is automated becasue the number of impacted packages it too high to go trough manually.


It appears that your package uses the deprecated setup.py build and/or install command in the spec file.

This is essentially the same as using the deprecated %py3_build/%py3_install macros.

See https://fedoraproject.org/wiki/Changes/DeprecateSetuppyMacros for why the macros are deprecated.

Th python setup.py build/install commands have been deprecated commands for 5 years and will likely stop working in Fedora 45.



Please migrate to %pyproject_buildrequires + %pyproject_wheel + %pyproject_install macros instead.

See https://fedoraproject.org/wiki/Changes/DeprecateSetuppyMacros#Migrating_to_%pyproject_macros for migration guide.

See https://github.com/hroncok/pyprojectize/ for a tool that can help you automate the migration.


Thank you. Let me know if you need help.

Comment 1 Otto Liljalaakso 2025-08-04 20:06:33 UTC
The problem here is that upstream does not have pyproject.toml at all. Working on upstream's default branch 'develop', I tried moving things from setup.py there and ended up with the following:

---
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = 'zim'
description = 'Zim desktop wiki'
authors = [
    {name = 'Jaap Karssenberg', email = 'jaap.karssenberg'},
]
license = 'GPL v2+'
dependencies = ['gi', 'xdg']
dynamic = [
    "version",
    "url",
    "scripts",
    "packages",
    "data_files",
]
---

Which probably needs some changes still, but can at least be used to try running `python -m pip install .`. That runs into problems because setup.py is, in the context of the source repo, "self referential" by having this:

---
from zim import __version__, __url__

import msgfmt # also distributed with zim
import makeman # helper script
---

which all comes from the repo itself like this:

---
setup.py
zim/
    __init__.py
    # a lot of stuff here
msgfmt.py
makeman.py
---

The first error was "ModuleNotFoundError: No module named 'zim'". It can be sidestepped by using `python -m pip install --no-build-isolation .`, which then produced "ModuleNotFoundError: No module named 'msgfmt'", which I have not been able to fix yet. Should they be converted into "packages" like zim/ is? Or should the goal here be to find something that does not need `--no-build-isolation` at all?

I will continue to look into this when I have time. But even if I manage to get something working, there is still the question if it will be a good way to do it. If somebody who understand python buildsystems and packaging well can suggest something, I am interested.

Comment 2 Miro Hrončok 2025-08-04 21:59:23 UTC
(In reply to Otto Liljalaakso from comment #1)
> The problem here is that upstream does not have pyproject.toml at all.

That should not be the requirement at all. The %pyproject RPM macros use setuptools as the default build backend when there is no specific backend specified in pyproject.toml.

I have this work in progress specfile diff:

--- a/Zim.spec
+++ b/Zim.spec
@@ -16,7 +16,6 @@ BuildArch:      noarch
 BuildRequires:  desktop-file-utils
 BuildRequires:  python3-devel
 BuildRequires:  python3-gobject
-BuildRequires:  python3-setuptools
 BuildRequires:  gtk3, python3-pyxdg
 # for tests
 BuildRequires:  /usr/bin/xvfb-run
@@ -38,22 +37,25 @@ fkini
 %prep
 %autosetup -p1 -n zim-%{version}
 
+%generate_buildrequires
+%pyproject_buildrequires
+
 %build
-./setup.py build
+%pyproject_wheel
 
 %install
-rm -rf %{buildroot}
-./setup.py install --root=%{buildroot} --skip-build
+%pyproject_install
+%pyproject_save_files -l zim
 
 %find_lang zim
+cat zim.lang >> %{pyproject_files}
 
 desktop-file-validate %{buildroot}%{_datadir}/applications/org.zim_wiki.Zim.desktop
 
 %check
 LANG=en_US.UTF-8 xvfb-run ./test.py
 
-%files -f zim.lang
-%license LICENSE
+%files -f %{pyproject_files}
 %doc *.md contrib/
 %{_mandir}/man[13]/*.[13]*
 %{_bindir}/*
@@ -64,8 +66,6 @@ LANG=en_US.UTF-8 xvfb-run ./test.py
 %{_datadir}/icons/hicolor/*/mimetypes/*
 # No package in Fedora provides such directories
 %{_datadir}/icons/ubuntu-mono-*/
-%{python3_sitelib}/zim-*.egg-info
-%{python3_sitelib}/zim/
 %{_datadir}/metainfo/*
 
 %changelog



However, for reasons yet to be determined, the build fails with:

RPM build errors:
    File not found: /builddir/build/BUILD/Zim-0.76.3-build/BUILDROOT/usr/share/icons/hicolor/*/apps/*
    File not found: /builddir/build/BUILD/Zim-0.76.3-build/BUILDROOT/usr/share/icons/hicolor/*/mimetypes/*

As if the fix_dist() function in setup.py was called too late :/

Comment 3 Miro Hrončok 2025-08-04 22:25:10 UTC
I have a dirty solution: https://src.fedoraproject.org/rpms/Zim/pull-request/7

Comment 4 Miro Hrončok 2025-08-05 11:34:38 UTC
https://github.com/zim-desktop-wiki/zim-desktop-wiki/pull/2859 is a nicer upstream fix.

Comment 5 Otto Liljalaakso 2025-08-05 20:22:39 UTC
I merged the Fedora PR, updated to use tat upstream fix. Howver, despite PR scratch build passing, the real build now ran into icons issue during %check.
The build: https://koji.fedoraproject.org/koji/taskinfo?taskID=135743865
And the error from the logs below. I try to look into this later.

+ xvfb-run ./test.py
WARNING: foo
Traceback (most recent call last):
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/zim/gui/__init__.py", line 45, in load_zim_stock_icons
    pixbuf = icon_theme.load_icon(name, 24, 0)
gi.repository.GLib.GError: gtk-icon-theme-error-quark: Icon 'zim-add-bookmark' not present in theme Adwaita (0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/./test.py", line 207, in <module>
    main()
    ~~~~^^
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/./test.py", line 111, in main
    suite = tests.load_tests(loader, None, None)
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/tests/__init__.py", line 107, in load_tests
    test = loader.loadTestsFromName(name)
  File "/usr/lib64/python3.14/unittest/loader.py", line 137, in loadTestsFromName
    module = __import__(module_name)
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/tests/errors.py", line 13, in <module>
    from zim.gui.widgets import ErrorDialog
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/zim/gui/__init__.py", line 59, in <module>
    load_zim_stock_icons()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/zim/gui/__init__.py", line 48, in load_zim_stock_icons
    pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)
gi.repository.GLib.GError: gdk-pixbuf-error-quark: Failed to load image “/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/data/pixmaps/add-bookmark.png”: Could not spawn `env -i "bwrap" "--unshare-all" "--die-with-parent" "--chdir" "/" "--ro-bind" "/usr" "/usr" "--dev" "/dev" "--ro-bind-try" "/etc/ld.so.cache" "/etc/ld.so.cache" "--tmpfs" "/tmp-home" "--setenv" "HOME" "/tmp-home" "--tmpfs" "/tmp-run" "--setenv" "XDG_RUNTIME_DIR" "/tmp-run" "--symlink" "/usr/lib" "/lib" "--symlink" "/usr/lib64" "/lib64" "--seccomp" "14" "/usr/libexec/glycin-loaders/2+/glycin-image-rs"`: No such file or directory (os error 2) (0)

Comment 6 Miro Hrončok 2025-08-05 20:40:35 UTC
gi.repository.GLib.GError: gdk-pixbuf-error-quark: Failed to load image “/builddir/build/BUILD/Zim-0.76.3-build/zim-0.76.3/data/pixmaps/add-bookmark.png”: Could not spawn `env -i "bwrap" "--unshare-all" "--die-with-parent" "--chdir" "/" "--ro-bind" "/usr" "/usr" "--dev" "/dev" "--ro-bind-try" "/etc/ld.so.cache" "/etc/ld.so.cache" "--tmpfs" "/tmp-home" "--setenv" "HOME" "/tmp-home" "--tmpfs" "/tmp-run" "--setenv" "XDG_RUNTIME_DIR" "/tmp-run" "--symlink" "/usr/lib" "/lib" "--symlink" "/usr/lib64" "/lib64" "--seccomp" "14" "/usr/libexec/glycin-loaders/2+/glycin-image-rs"`: No such file or directory (os error 2) (0)

This is weird. Perhaps try building it again? I noticed the real build failed on ppc64le and the CI build passed on aarch64.

Comment 7 Otto Liljalaakso 2025-08-06 18:55:35 UTC
Tried to rebuild twice and got the same error both times. Also 'fedpkg mockbuild' fails in the same error. So the problem is reproducible.

I went through the error in detail, looking for non-existent files or directories. It turns out that 'bwrap' binary is not available in the build env. And indeed, 'BuildRequires: bubblewrap' solves this problem. So your PR was and is OK, and something else just happened break meanwhile. The Fedora package that provides 'GdkPixbuf.Pixbuf.new_from_file(path)' should Require bubblewrap, it seems. I will look into that later.

I will keep this bug open until we have a successful build, even though I think here is nothing to do here anymore.

Comment 8 Otto Liljalaakso 2025-08-07 18:54:11 UTC
This is bug 2387002. Let's wait until it is resolved. If you need a working build fast, we can add 'Required: bubblewrap' and 'BuildRequires: bubblewrap' as a temporary solution.

Comment 9 Fedora Update System 2025-08-09 17:45:05 UTC
FEDORA-2025-933196073a (Zim-0.76.3-6.fc43) has been submitted as an update to Fedora 43.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-933196073a

Comment 10 Fedora Update System 2025-08-09 17:49:20 UTC
FEDORA-2025-933196073a (Zim-0.76.3-6.fc43) has been pushed to the Fedora 43 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.