File python-xkbgroup.spec of Package python-xkbgroup

#
# spec file for package python-xkbgroup
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-xkbgroup
Version:        0.2.0
Release:        0
License:        MIT
Summary:        Query and change XKB layout state
Url:            https://github.com/hcpl/xkbgroup
Group:          Development/Languages/Python
Source:         https://files.pythonhosted.org/packages/source/x/xkbgroup/xkbgroup-%{version}.tar.gz
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module setuptools}
BuildRequires:  xvfb-run
BuildRequires:  fdupes
Requires:       xorg-x11-server
BuildArch:      noarch

%python_subpackages

%description
Python library to query and change XKB layout state.

%prep
%setup -q -n xkbgroup-%{version}
sed -i 's/from \.xkb/from xkbgroup.xkb/' xkbgroup/core.py
sed -i 's/from xkb/from xkbgroup.xkb/' xkbgroup/test.py
sed -i 's/nonlocal/global/' xkbgroup/test.py

# https://github.com/hcpl/xkbgroup/issues/13 - issues on 32bit
# with _XData32 and _XRead32 which are unlikely to be commonly used
# xkbgroup/xkb.py is generated using python-ctypeslib with
# h2xml.py -c -o xkb.xml X11/Xlib.h X11/Xlibint.h X11/XKBlib.h
# xml2py.py -k defst -o xkb.py -l X11 xkb.xml
# ctypelib depends on gccxml which is no longer provided on openSUSE
# Regenerating using ctypeslib2 may be an option.
# https://github.com/hcpl/xkbgroup/issues/14
# Remove the problematic entries manually on all platforms
# for consistency in any breakage caused.
sed -Ei '/_X(Data|Read)32/d' xkbgroup/xkb.py

%build
export LANG=en_US.UTF-8
%python_build

%install
export LANG=en_US.UTF-8
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
export LANG=en_US.UTF-8
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitelib}
xvfb-run $python xkbgroup/core.py
# pause between pythons to allow X to stop
sleep 5
xvfb-run %{buildroot}%{_bindir}/xkbgroup get all_data
sleep 5
# Seg faults:
# xvfb-run $python xkbgroup/test.py
}

%files %{python_files}
%doc README.rst
%license LICENSE
%python3_only %{_bindir}/xkbgroup
%{python_sitelib}/*

%changelog
openSUSE Build Service is sponsored by