File python-xdot.spec of Package python-xdot
#
# spec file for package python-xdot
#
# Copyright (c) 2020 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/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-xdot
Version: 1.2
Release: 0
Summary: Interactive viewer for Graphviz dot files
License: LGPL-2.1-or-later
Group: Development/Languages/Python
URL: https://github.com/jrfonseca/xdot.py
Source: https://github.com/jrfonseca/xdot.py/archive/%{version}.tar.gz#/xdot-%{version}.tar.gz
Patch0: https://patch-diff.githubusercontent.com/raw/jrfonseca/xdot.py/pull/85.patch#/pr_85.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: graphviz
Requires: python-gobject
Requires: python-numpy
Requires: python-pycairo
Requires: typelib-1_0-Gtk-3_0
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module gobject}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module pycairo}
BuildRequires: graphviz
BuildRequires: typelib-1_0-Gtk-3_0
BuildRequires: xvfb-run
# /SECTION
%python_subpackages
%description
xdot.py is an interactive viewer for graphs written in Graphviz's dot language.
It uses internally the graphviz's xdot output format as an intermediate format,
and PyGTK and Cairo for rendering.
%prep
%setup -q -n xdot.py-%{version}
%patch0 -p1
# drop shebang
sed -i -e '/^#!\//, 1d' xdot/__main__.py
# This is needed for the $(find) in the test logic to work
rm tests/.gitignore
# Restrict test runner to single process to avoid hangs
sed -i 's/multiprocessing.cpu_count()/1/' test.py
%build
%python_build
%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/xdot
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%post
%python_install_alternative xdot
%postun
%python_uninstall_alternative xdot
%check
cd tests
# The following $(find) gets all of the test cases, however they take a long time and some hang
# $(find . -name '*.dot' -o -name '*.gv')
# So a subset are being run until the problems are isolated and fixed
# Actually the runner seems to hang after *.gv are run on the VM
%python_expand xvfb-run $python ../test.py chars.dot
#*.dot
#graphs/Times.gv graphs/records.gv graphs/labelroot-nbl.gv graphs/weight.gv
%files %{python_files}
%license LICENSE.txt
%doc README.md
%python_alternative %{_bindir}/xdot
%{python_sitelib}/xdot
%{python_sitelib}/xdot-%{version}-py*.egg-info
%changelog