diff --git a/graphviz-2.40.1-python3.patch b/graphviz-2.40.1-python3.patch new file mode 100644 index 0000000..6e6c172 --- /dev/null +++ b/graphviz-2.40.1-python3.patch @@ -0,0 +1,58 @@ +diff --git a/config/config_python.py b/config/config_python.py +index b747045..2b1ac8d 100644 +--- a/config/config_python.py ++++ b/config/config_python.py +@@ -1,12 +1,13 @@ ++from __future__ import print_function ++ + import sys + from distutils import sysconfig + + if sys.argv[1] == "archlib": +- print sysconfig.get_python_lib(1,1) ++ print(sysconfig.get_python_lib(1,1)) + elif sys.argv[1] == "lib": +- print sysconfig.get_python_lib(0,1) ++ print(sysconfig.get_python_lib(0,1)) + elif sys.argv[1] == "archsitelib": +- print sysconfig.get_python_lib(1,0) ++ print(sysconfig.get_python_lib(1,0)) + elif sys.argv[1] == "sitelib": +- print sysconfig.get_python_lib(0,0) +- ++ print(sysconfig.get_python_lib(0,0)) +diff --git a/configure.ac b/configure.ac +index 51166c3..4d8c9a0 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1142,7 +1142,7 @@ else + if test `$SWIG -help 2>&1 | $EGREP -c '\-python *- Generate'` = 0; then + use_python="No (swig does not support -python option)" + else +- AC_CHECK_PROG(PYTHON,python,python) ++ AC_CHECK_PROGS(PYTHON,[python3 python]) + if test "x$PYTHON" = "x"; then + use_python="No (python not available)" + else +@@ -1167,8 +1167,11 @@ else + if test "x$PYTHON" = "x"; then + use_python="No (python is too old)" + else +- PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"` ++ PYTHON_PREFIX=`$PYTHON -c "import sys; print(sys.prefix)"` + PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION_SHORT ++ if test $PYTHON_VERSION_MAJOR -gt 2; then ++ PYTHON_INCLUDES="${PYTHON_INCLUDES}m" ++ fi + # PYTHON_LIBS="-lpython$PYTHON_VERSION_SHORT" + PYTHON_LIBS="-undefined dynamic_lookup" + PYTHON_INSTALL_DIR="`$PYTHON $srcdir/config/config_python.py archsitelib`" +@@ -1548,7 +1551,7 @@ else + if test "x$PYTHON34" = "x"; then + use_python34="No (python34 is too old)" + else +- PYTHON34_PREFIX=`$PYTHON3 -c "import sys; print sys.prefix"` ++ PYTHON34_PREFIX=`$PYTHON3 -c "import sys; print(sys.prefix)"` + # PYTHON34_INCLUDES=-I$PYTHON34_PREFIX/include/python$PYTHON34_VERSION_SHORT + # FIXME - whats the stupid "m" for? + PYTHON34_INCLUDES=-I/usr/include/python3.4m diff --git a/graphviz.spec b/graphviz.spec index c67e7c4..32a4250 100644 --- a/graphviz.spec +++ b/graphviz.spec @@ -1,3 +1,9 @@ +%if 0%{?rhel} == 8 +%bcond_with python2 +%else +%bcond_without python2 +%endif + # Necessary conditionals %ifarch %{mono_arches} %global SHARP 1 @@ -49,14 +55,18 @@ Name: graphviz Summary: Graph Visualization Tools Version: 2.40.1 -Release: 24%{?dist} +Release: 25%{?dist} License: EPL URL: http://www.graphviz.org/ Source0: http://www.graphviz.org/pub/graphviz/ARCHIVE/%{name}-%{version}.tar.gz Patch0: graphviz-2.40.1-visio.patch +Patch1: graphviz-2.40.1-python3.patch BuildRequires: zlib-devel, libpng-devel, libjpeg-devel, expat-devel, freetype-devel >= 2 BuildRequires: ksh, bison, m4, flex, tk-devel, tcl-devel >= 8.3, swig -BuildRequires: fontconfig-devel, libtool-ltdl-devel, ruby-devel, ruby, guile-devel, python2-devel +BuildRequires: fontconfig-devel, libtool-ltdl-devel, ruby-devel, ruby, guile-devel +%if %{with python2} +BuildRequires: python2-devel +%endif BuildRequires: python3-devel, libXaw-devel, libSM-devel, libXext-devel, java-devel BuildRequires: cairo-devel >= 1.1.10, pango-devel, gmp-devel, lua-devel, gtk2-devel BuildRequires: gd-devel, perl-devel, swig >= 1.3.33, automake, autoconf, libtool, qpdf @@ -86,7 +96,12 @@ BuildRequires: gts-devel %if %{LASI} BuildRequires: lasi-devel %endif -BuildRequires: urw-base35-fonts, perl-ExtUtils-Embed, perl-generators, libgs-devel, librsvg2-devel +BuildRequires: urw-base35-fonts, perl-ExtUtils-Embed, perl-generators, librsvg2-devel +%if 0%{?rhel} == 8 +BuildRequires: ghostscript-devel +%else +BuildRequires: libgs-devel +%endif # ISO8859-1 fonts are required by lefty Requires: urw-base35-fonts, xorg-x11-fonts-ISO8859-1-100dpi Requires(post): /sbin/ldconfig @@ -198,6 +213,7 @@ Requires: php(api) = %{?php_core_api}%{?!php_core_api:UNDEFINED} PHP extension for graphviz. %endif +%if %{with python2} %package python2 Summary: Python extension for graphviz Requires: %{name} = %{version}-%{release} @@ -212,6 +228,7 @@ Obsoletes: python2-%{name} < %{version}-%{release} %description python2 Python extension for graphviz. +%endif %package python3 Summary: Python 3 extension for graphviz @@ -258,6 +275,7 @@ Various tcl packages (extensions) for the graphviz tools. %prep %setup -q %patch0 -p1 -b .visio +%patch1 -p1 -b .python3 # Attempt to fix rpmlint warnings about executable sources find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';' @@ -301,25 +319,31 @@ export CPPFLAGS=-I`ruby -e "puts File.join(RbConfig::CONFIG['includedir'], RbCon --without-qt \ %endif -# python3 -cp -a tclpkg/gv tclpkg/gv.python3 +%if %{with python2} +cp -a tclpkg/gv tclpkg/gv.python2 +%endif -make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" \ - CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" - -# python3 -pushd tclpkg/gv.python3 make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" \ CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" \ PYTHON_INCLUDES=-I/usr/include/python%{python3_version}m PYTHON_LIBS="-lpython%{python3_version}m" \ - PYTHON_INSTALL_DIR=%{python3_sitearch} libgv_python.la + PYTHON_INSTALL_DIR=%{python3_sitearch} PYTHON=%{__python3} + +%if %{with python2} +pushd tclpkg/gv.python2 +make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" \ + CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fno-strict-overflow %{?FFSTORE}" \ + PYTHON_INCLUDES=-I/usr/include/python%{python2_version} PYTHON_LIBS="-lpython%{python2_version}" \ + PYTHON_INSTALL_DIR=%{python2_sitearch} libgv_python.la popd +%endif %install rm -rf %{buildroot} make DESTDIR=%{buildroot} \ docdir=%{buildroot}%{_docdir}/%{name} \ pkgconfigdir=%{_libdir}/pkgconfig \ + PYTHON_LIBS="-lpython%{python3_version}m" \ + PYTHON_INSTALL_DIR=%{python3_sitearch} \ install find %{buildroot} -type f -name "*.la" -exec rm -f {} ';' chmod -x %{buildroot}%{_datadir}/%{name}/lefty/* @@ -365,12 +389,24 @@ do done popd -# python3 -pushd tclpkg/gv.python3 +%if %{with python2} +pushd tclpkg/gv.python2 +install -pD .libs/libgv_python.so %{buildroot}%{python2_sitearch}/_gv.so +install -p gv.py %{buildroot}%{python2_sitearch}/gv.py +popd +%endif + +# python 3 +pushd tclpkg/gv install -pD .libs/libgv_python.so %{buildroot}%{python3_sitearch}/_gv.so install -p gv.py %{buildroot}%{python3_sitearch}/gv.py popd +# remove the python module from the %%_libdir/graphviz/python, it's +# already installed in the python sitearch +rm -f %{buildroot}%{_libdir}/graphviz/python/* +rmdir %{buildroot}%{_libdir}/graphviz/python + # Ghost plugins config touch %{buildroot}%{_libdir}/graphviz/config%{pluginsver} @@ -520,10 +556,11 @@ php --no-php-ini \ %{_mandir}/man3/gv.3php* %endif +%if %{with python2} %files python2 -%{_libdir}/graphviz/python/ %{python2_sitearch}/* %{_mandir}/man3/gv.3python* +%endif %files python3 %{python3_sitearch}/* @@ -554,6 +591,9 @@ php --no-php-ini \ %{_mandir}/man3/*.3tcl* %changelog +* Thu May 3 2018 Jaroslav Škarvada - 2.40.1-25 +- Made python2 package optional + * Wed May 2 2018 Jaroslav Škarvada - 2.40.1-24 - Added support for python3