File mnemosyne.spec of Package Mnemosyne

#
# spec file for package mnemosyne
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define pythons python311
Name:           mnemosyne
Version:        2.11
Release:        0
Summary:        Flash-card learning tool
License:        GPL-2.0-or-later
Group:          Productivity/Other
URL:            http://www.mnemosyne-proj.org/
#Source0:        https://sourceforge.net/projects/%%{name}-proj/files/%%{name}/%%{name}-%%{version}/Mnemosyne-%%{version}.tar.gz
Source0:        https://github.com/mnemosyne-proj/mnemosyne/archive/%{version}/%{name}-%{version}.tar.gz
Source1:        %{name}.png
Source2:        %{name}.desktop
# FIX-OPENSUSE: Insert @PYTHON_BIN_SUFFIX@ to correct later in grep the different python versions and env specifications in path.
Patch1:         %{name}-python.patch
BuildRequires:  dos2unix
BuildRequires:  %{python_module PyQt6}
BuildRequires:  %{python_module base >= 3.5}
BuildRequires:  %{python_module setuptools}
Requires:       %{python_flavor}-CherryPy
Requires:       %{python_flavor}-Pillow
Requires:       %{python_flavor}-PyQt6
Requires:       %{python_flavor}-WebOb >= 1.4
Requires:       %{python_flavor}-argon2-cffi
Requires:       %{python_flavor}-cheroot >= 5.0.0
Requires:       %{python_flavor}-gTTS
Requires:       %{python_flavor}-matplotlib
Requires:       %{python_flavor}-matplotlib-qt5
Requires:       %{python_flavor}-qtwebengine-qt6
Recommends:     %{python_flavor}-google_trans_new >= 1.1.9
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
%endif
%if 0%{?suse_version}
Recommends:     texlive-latex
%endif

%description
Mnemosyne resembles a traditional flash-card program but with an
important twist: it uses a sophisticated algorithm to schedule the best
time for a card to come up for review.

%lang_package

%prep
%setup -q
%patch -P 1 -p1
# rpmlint
find -name "*.py" | xargs -r dos2unix
find -name "README" | xargs -r dos2unix
find -name "README.md" | xargs -r dos2unix
find -name "ChangeLog" | xargs -r dos2unix
chmod -x ChangeLog
chmod -x README
chmod -x README.md
# Replace @PYTHON_BIN_SUFFIX@ from patch1.
find . -type f -exec sed -i -e 's|@PYTHON_BIN_SUFFIX@|%python_bin_suffix|g' {} \;

%build
env CFLAGS="%{optflags}" \
python%python_bin_suffix setup.py build
%make_build -C po update
%make_build -C po

%install
python%python_bin_suffix setup.py install \
        --root=%{buildroot} \
        --prefix="%{_prefix}" \
        --install-lib="%{python_sitelib}"

install -Dm644 %{SOURCE2} %{buildroot}/%{_datadir}/applications/%{name}.desktop
test -d %{buildroot}/%{_datadir}/icons && rm -rf %{buildroot}/%{_datadir}/icons
test -d %{buildroot}/%{_prefix}/pixmaps && rm -rf %{buildroot}/%{_prefix}/pixmaps

%find_lang mnemosyne
%if 0%{?suse_version}
%suse_update_desktop_file -i -n -r %{name} Education Languages
%endif

%files
%license LICENSE
%doc ChangeLog README README.md
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/mnemosyne.png
%{python_sitelib}/%{name}
%{python_sitelib}/Mnemosyne*
%{python_sitelib}/openSM2sync

%files lang -f %{name}.lang

%changelog
openSUSE Build Service is sponsored by