File autokey.spec of Package autokey

#
# spec file for package autokey
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%{?primary_python:%define pythons %primary_python}
%{?sle15_python_module_pythons}
Name:           autokey
Version:        0.96.0_beta7
Release:        0
Summary:        Desktop automation utility
License:        GPL-3.0
Group:          System/X11/Utilities
Url:            https://github.com/autokey/autokey
Source:         https://github.com/autokey/autokey/archive/%{name}-9445809607d7ebf5e85a819aad1b707698349c60.zip
#Source:         https://github.com/autokey/autokey/archive/%{name}-%{version}.tar.gz
BuildRequires:  %{python_module devel >= 3.8}
BuildRequires:  unzip
BuildRequires:  update-desktop-files
BuildRequires:  %{python_module sip-devel >= 4.18.0}
# BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module wheel}
# BuildRequires:  %{python_module dbus-python-devel}
BuildRequires:  %{python_module python-xlib}
BuildRequires:  %{python_module qt5}
# BuildRequires:  %{python_module qscintilla-qt5}
BuildRequires:  %{python_module PyHamcrest}
BuildRequires:  fdupes
# BuildRequires:  %{python_module tools}
# BuildRequires:  ImageMagick
BuildArch:      noarch

%description
AutoKey is a desktop automation utility for Linux and X11. It allows the
automation of virtually any task by responding to typed abbreviations
and hotkeys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering the
full flexibility and power of the Python language.

%package common
Summary:        Desktop automation utility -- Common Files
Group:          System/X11/Utilities
Requires:       %{python_flavor}-simplejson
Requires:       %{python_flavor}-dbus-python
Requires:       %{python_flavor}-python-xlib
Requires:       %{python_flavor}-pyhamcrest
Requires:       wmctrl
Recommends:     %{name}-gtk
Recommends:     %{name}-qt

%description common
AutoKey is a desktop automation utility for Linux and X11. It allows the
automation of virtually any task by responding to typed abbreviations
and hotkeys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering the
full flexibility and power of the Python language.

%package gtk
Summary:        Desktop automation utility -- GTK+ Interface
Group:          System/X11/Utilities
Requires:       %{name}-common = %{version}
Requires:       %{python_flavor}-notify2
Requires:       %{python_flavor}-atspi
Requires:       %{python_flavor}-gobject

%description gtk
AutoKey is a desktop automation utility for Linux and X11. It allows the
automation of virtually any task by responding to typed abbreviations
and hotkeys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering the
full flexibility and power of the Python language.

%package qt
Summary:        Desktop automation utility -- Qt Interface
Group:          System/X11/Utilities
Requires:       %{name}-common = %{version}
Requires:       %{python_flavor}-qscintilla-qt5
Requires:       %{python_flavor}-qt5
Requires:       %{python_flavor}-pyinotify
Requires:       %{python_flavor}-typing

%description qt
AutoKey is a desktop automation utility for Linux and X11. It allows the
automation of virtually any task by responding to typed abbreviations
and hotkeys. It offers a full-featured GUI that makes it highly
accessible for novices, as well as a scripting interface offering the
full flexibility and power of the Python language.

%prep
# %setup -q -n %{name}-0.96.0
%setup -q -n %{name}-9445809607d7ebf5e85a819aad1b707698349c60

# Change default SendMode from "Keyboard" to "Mouse Selection"
# sed -i 's|self.sendMode = SendMode.KEYBOARD|self.sendMode = SendMode.SELECTION|g' lib/autokey/model.py

# iconv -c -t ascii -o README.rst README.rst

# can't find python modul but is installed
sed -i 's|dbus-python||g' setup.py

sed -i 's|#!/usr/bin/env python|#!/usr/bin/python%{python_version}|' lib/autokey/{service,monitor,common,qtapp}.py
#2to3 -w -f all -f idioms -f buffer -f set_literal .

# fix png size
#mogrify -resize 96x96! config/autokey.png

%build
%pyproject_wheel

%install
%pyproject_install
%python_expand %suse_update_desktop_file %{name}-qt DesktopSettings
%python_expand %suse_update_desktop_file %{name}-gtk DesktopSettings
%python_expand chmod +x %{buildroot}%{python_sitelib}/%{name}/{service,monitor,common,qtapp}.py
# chmod +x %{buildroot}%{python_sitelib}/%{name}/qtui/{recorddialog,folderpage,dialogs,detectdialog,abbrsettings,hotkeysettings,centralwidget,phrasepage,enginesettings,settingswidget,specialhotkeysettings,windowfiltersettings,generalsettings,scriptpage}.py
%python_expand %fdupes %{buildroot}%{python_sitelib}/%{name}

%post common
# enable xauth in pam
/usr/bin/sed -i 's|^#.*session.*optional.*pam_xauth.so|session  optional       pam_xauth.so|' /etc/pam.d/sudo ||:

%post
#{python_install_alternative %{name}-gtk %{name}-qt %{name}-run %{name}-shell}

%postun
#{python_uninstall_alternative %{name}-gtk %{name}-qt %{name}-run %{name}-shell}

%files common
%doc ACKNOWLEDGMENTS README.rst CHANGELOG.rst 
%license LICENSE
%dir %{python_sitelib}/%{name}
%{python_sitelib}/%{name}/*.py*
%exclude %{python_sitelib}/%{name}/gtkapp.py*
%exclude %{python_sitelib}/%{name}/qtapp.py*
%{python_sitelib}/%{name}-*.dist-info
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/scalable
%dir %{_datadir}/icons/hicolor/scalable/apps
%dir %{_datadir}/icons/hicolor/96x96
%dir %{_datadir}/icons/hicolor/96x96/apps
%{_datadir}/icons/hicolor/scalable/apps/%{name}-status*.svg
%{_datadir}/icons/hicolor/96x96/apps/%{name}.png
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
# Do not include theme specific icons
%exclude %{_datadir}/icons/ubuntu-mono-dark/apps/*
%exclude %{_datadir}/icons/ubuntu-mono-light/apps/*
%exclude %{_datadir}/icons/Humanity/scalable/apps/*.svg
%{_bindir}/%{name}-run
%{_mandir}/man1/%{name}-run.1*
%{_bindir}/%{name}-shell
%dir %{python_sitelib}/%{name}/__pycache__
%{python_sitelib}/%{name}/__pycache__/*

%dir %{python_sitelib}/%{name}/iomediator
%{python_sitelib}/%{name}/iomediator/*
%dir %{python_sitelib}/%{name}/iomediator/__pycache__
%{python_sitelib}/%{name}/iomediator/__pycache__/*

%dir %{python_sitelib}/%{name}/configmanager
%{python_sitelib}/%{name}/configmanager/*
%dir %{python_sitelib}/%{name}/configmanager/__pycache__
%{python_sitelib}/%{name}/configmanager/__pycache__/*

%dir %{python_sitelib}/%{name}/model
%{python_sitelib}/%{name}/model/*
%dir %{python_sitelib}/%{name}/model/__pycache__
%{python_sitelib}/%{name}/model/__pycache__/*

%dir %{python_sitelib}/%{name}/scripting
%{python_sitelib}/%{name}/scripting/*
%dir %{python_sitelib}/%{name}/scripting/__pycache__
%{python_sitelib}/%{name}/scripting/__pycache__/*

%exclude %{python_sitelib}/%{name}/__pycache__/gtkapp.cpython-*.pyc
%exclude %{python_sitelib}/%{name}/__pycache__/qtapp.cpython-*.pyc

%files gtk
%{_bindir}/%{name}-gtk
%{python_sitelib}/%{name}/gtkapp.py*
%{python_sitelib}/%{name}/gtkui/
%{python_sitelib}/%{name}/__pycache__/gtkapp.cpython-*.pyc
%{_datadir}/applications/%{name}-gtk.desktop
%{_mandir}/man1/%{name}-gtk.1*

%files qt
%{_bindir}/%{name}-qt
%{python_sitelib}/%{name}/qtapp.py*
%{python_sitelib}/%{name}/qtui/
%{python_sitelib}/%{name}/__pycache__/qtapp.cpython-*.pyc
%{_datadir}/applications/%{name}-qt.desktop
%{_mandir}/man1/%{name}-qt.1*

%changelog
openSUSE Build Service is sponsored by