diff --git a/rdkit.spec b/rdkit.spec index 9f39be6..c794daa 100644 --- a/rdkit.spec +++ b/rdkit.spec @@ -1,5 +1,6 @@ %global with_docs 0 %global with_tests 1 +%global with_py3 1 %if 0%{?rhel} && 0%{?rhel} <= 6 %{!?__python2: %global __python2 /usr/bin/python2} @@ -35,7 +36,7 @@ BuildRequires: chrpath BuildRequires: swig BuildRequires: java-devel BuildRequires: junit -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} BuildRequires: python3-devel BuildRequires: boost-python3-devel %endif @@ -72,7 +73,7 @@ BuildRequires: pycairo BuildRequires: xorg-x11-fonts-Type1 BuildRequires: python-pandas BuildRequires: python-pillow -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} BuildRequires: python3-cairocffi BuildRequires: python3-pandas BuildRequires: python3-pillow @@ -118,7 +119,7 @@ Requires: xorg-x11-fonts-Type1 %description -n python2-rdkit Python 2 bindings for RDKit libraries -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} %package -n python3-rdkit Summary: Python 3 bindings for RDKit libraries %{?python_provide:%python_provide python3-rdkit} @@ -165,15 +166,17 @@ rm -rf rdkit/sping cp -pr license.txt ReleaseNotes.* ../ popd +%if 0%{?with_py3} cp -a python2 python3 find python3 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python3}|' -find python2 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python2}|' # fix tests scripts for python3 runtime find python3 -name 'test_list.py' | xargs sed -i 's/"python"/"python3"/g' find python3 -name 'test_list.py' | xargs sed -i "s/'python'/'python3'/g" sed -i.orig 's/python/python3/g' python3/Projects/DbCLI/TestDbCLI.py +%endif +find python2 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python2}|' %build # fix rpmlint "unused-direct-shlib-dependency" @@ -205,8 +208,7 @@ pushd Code/PgSQL/rdkit chrpath -d librdkit.so popd -%if 0%{?fedora} -%if 0%{with_docs} +%if 0%{?fedora} && 0%{with_docs} # Documentation (does not currently build on EPEL) export RDBASE=%{_builddir}/%{rootdir}/python2 pushd rdkit @@ -219,10 +221,9 @@ pushd Docs/Book make latexpdf popd %endif -%endif popd -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} # Python 3 build pushd python3 %cmake -D RDK_INSTALL_INTREE=OFF \ @@ -257,7 +258,7 @@ install -D rdkit--3.5.sql %{buildroot}%{_datadir}/pgsql/extension/rdkit--3.5.sql popd popd -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} # install Python 3 bindings pushd python3 make install DESTDIR=%{buildroot} @@ -274,7 +275,7 @@ touch -r $FMCS.py $FMCS.new && mv $FMCS.new $FMCS.py rm $FMCS -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} FMCS=%{buildroot}%{python3_sitearch}/rdkit/Chem/fmcs/fmcs sed '1{\@^#!%{__python3}@d}' $FMCS.py > $FMCS.new && touch -r $FMCS.py $FMCS.new && @@ -292,7 +293,7 @@ export PYTHONPATH=$RDBASE ARGS="-V -E PgSQL" make test popd -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} pushd python3 export RDBASE=%{_builddir}/%{rootdir}/python3 export LD_LIBRARY_PATH=$RDBASE/lib @@ -318,16 +319,14 @@ popd %{_libdir}/cmake/*.cmake %files doc -%if 0%{?fedora} -%if 0%{?with_docs} +%if 0%{?fedora} && 0%{?with_docs} %doc python2/Docs/Book/_build/latex/RDKit.pdf %endif -%endif %files -n python2-rdkit %{python2_sitearch}/rdkit -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?with_py3} %files -n python3-rdkit %{python3_sitearch}/rdkit %endif