Made python2 package optional

This commit is contained in:
Jaroslav Škarvada 2018-05-03 19:04:53 +02:00
parent 2ec89c2f7b
commit 5867985c23
2 changed files with 112 additions and 14 deletions

View File

@ -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

View File

@ -1,3 +1,9 @@
%if 0%{?rhel} == 8
%bcond_with python2
%else
%bcond_without python2
%endif
# Necessary conditionals # Necessary conditionals
%ifarch %{mono_arches} %ifarch %{mono_arches}
%global SHARP 1 %global SHARP 1
@ -49,14 +55,18 @@
Name: graphviz Name: graphviz
Summary: Graph Visualization Tools Summary: Graph Visualization Tools
Version: 2.40.1 Version: 2.40.1
Release: 24%{?dist} Release: 25%{?dist}
License: EPL License: EPL
URL: http://www.graphviz.org/ URL: http://www.graphviz.org/
Source0: http://www.graphviz.org/pub/graphviz/ARCHIVE/%{name}-%{version}.tar.gz Source0: http://www.graphviz.org/pub/graphviz/ARCHIVE/%{name}-%{version}.tar.gz
Patch0: graphviz-2.40.1-visio.patch 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: zlib-devel, libpng-devel, libjpeg-devel, expat-devel, freetype-devel >= 2
BuildRequires: ksh, bison, m4, flex, tk-devel, tcl-devel >= 8.3, swig 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: 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: 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 BuildRequires: gd-devel, perl-devel, swig >= 1.3.33, automake, autoconf, libtool, qpdf
@ -86,7 +96,12 @@ BuildRequires: gts-devel
%if %{LASI} %if %{LASI}
BuildRequires: lasi-devel BuildRequires: lasi-devel
%endif %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 # ISO8859-1 fonts are required by lefty
Requires: urw-base35-fonts, xorg-x11-fonts-ISO8859-1-100dpi Requires: urw-base35-fonts, xorg-x11-fonts-ISO8859-1-100dpi
Requires(post): /sbin/ldconfig Requires(post): /sbin/ldconfig
@ -198,6 +213,7 @@ Requires: php(api) = %{?php_core_api}%{?!php_core_api:UNDEFINED}
PHP extension for graphviz. PHP extension for graphviz.
%endif %endif
%if %{with python2}
%package python2 %package python2
Summary: Python extension for graphviz Summary: Python extension for graphviz
Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version}-%{release}
@ -212,6 +228,7 @@ Obsoletes: python2-%{name} < %{version}-%{release}
%description python2 %description python2
Python extension for graphviz. Python extension for graphviz.
%endif
%package python3 %package python3
Summary: Python 3 extension for graphviz Summary: Python 3 extension for graphviz
@ -258,6 +275,7 @@ Various tcl packages (extensions) for the graphviz tools.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .visio %patch0 -p1 -b .visio
%patch1 -p1 -b .python3
# Attempt to fix rpmlint warnings about executable sources # Attempt to fix rpmlint warnings about executable sources
find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';' 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 \ --without-qt \
%endif %endif
# python3 %if %{with python2}
cp -a tclpkg/gv tclpkg/gv.python3 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}" \ 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}" \ 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_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 popd
%endif
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
make DESTDIR=%{buildroot} \ make DESTDIR=%{buildroot} \
docdir=%{buildroot}%{_docdir}/%{name} \ docdir=%{buildroot}%{_docdir}/%{name} \
pkgconfigdir=%{_libdir}/pkgconfig \ pkgconfigdir=%{_libdir}/pkgconfig \
PYTHON_LIBS="-lpython%{python3_version}m" \
PYTHON_INSTALL_DIR=%{python3_sitearch} \
install install
find %{buildroot} -type f -name "*.la" -exec rm -f {} ';' find %{buildroot} -type f -name "*.la" -exec rm -f {} ';'
chmod -x %{buildroot}%{_datadir}/%{name}/lefty/* chmod -x %{buildroot}%{_datadir}/%{name}/lefty/*
@ -365,12 +389,24 @@ do
done done
popd popd
# python3 %if %{with python2}
pushd tclpkg/gv.python3 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 -pD .libs/libgv_python.so %{buildroot}%{python3_sitearch}/_gv.so
install -p gv.py %{buildroot}%{python3_sitearch}/gv.py install -p gv.py %{buildroot}%{python3_sitearch}/gv.py
popd 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 # Ghost plugins config
touch %{buildroot}%{_libdir}/graphviz/config%{pluginsver} touch %{buildroot}%{_libdir}/graphviz/config%{pluginsver}
@ -520,10 +556,11 @@ php --no-php-ini \
%{_mandir}/man3/gv.3php* %{_mandir}/man3/gv.3php*
%endif %endif
%if %{with python2}
%files python2 %files python2
%{_libdir}/graphviz/python/
%{python2_sitearch}/* %{python2_sitearch}/*
%{_mandir}/man3/gv.3python* %{_mandir}/man3/gv.3python*
%endif
%files python3 %files python3
%{python3_sitearch}/* %{python3_sitearch}/*
@ -554,6 +591,9 @@ php --no-php-ini \
%{_mandir}/man3/*.3tcl* %{_mandir}/man3/*.3tcl*
%changelog %changelog
* Thu May 3 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 2.40.1-25
- Made python2 package optional
* Wed May 2 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 2.40.1-24 * Wed May 2 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 2.40.1-24
- Added support for python3 - Added support for python3