Blob Blame History Raw
# recommonmark is currently incompatible with commonmark
# as included in Fedora
# https://github.com/rtfd/recommonmark/issues/24
%global with_docs 0
%global with_tests 1
%global with_py3 1

%global year        2017
%global month       03
%global extraver    1
%global pkgname     Release_%{year}_%{month}_%{extraver}
%global rootdir     rdkit-%{pkgname}

Name:           rdkit
Version:        %{year}.%{month}.%{extraver}
Release:        1%{?dist}
Summary:        Chemical informatics and machine learning toolkit
License:        BSD
URL:            http://www.rdkit.org/
Source0:        https://github.com/rdkit/rdkit/archive/%{pkgname}.tar.gz

BuildRequires:  cmake
BuildRequires:  flex
BuildRequires:  bison
BuildRequires:  python2-devel
BuildRequires:  boost-devel
BuildRequires:  postgresql-devel
BuildRequires:  %{_bindir}/pg_config
BuildRequires:  numpy
BuildRequires:  inchi-devel
BuildRequires:  cairo-devel
BuildRequires:  eigen3-devel
BuildRequires:  chrpath
BuildRequires:  swig
BuildRequires:  java-devel
BuildRequires:  junit
%if 0%{?fedora} && 0%{?with_py3}
BuildRequires:  python3-devel
BuildRequires:  boost-python3-devel
%endif

%if 0%{?with_docs}
# Docs build deps
BuildRequires: python-sphinx
BuildRequires: python2-recommonmark
BuildRequires: epydoc
BuildRequires: doxygen
BuildRequires: pandoc

%if 0%{?fedora}
BuildRequires: texlive-collection-latexrecommended
BuildRequires: texlive-collection-fontsrecommended
BuildRequires: tex(titlesec.sty)
BuildRequires: tex(framed.sty)
BuildRequires: tex(threeparttable.sty)
BuildRequires: tex(wrapfig.sty)
BuildRequires: tex(upquote.sty)
BuildRequires: tex(multirow.sty)
BuildRequires: tex(capt-of.sty)
BuildRequires: tex(eqparbox.sty)
%endif
%endif

# Needed for tests
%if 0%{?with_tests}
BuildRequires:  pycairo
BuildRequires:  xorg-x11-fonts-Type1
BuildRequires:  python-pandas
BuildRequires:  python-pillow
%if 0%{?fedora} && 0%{?with_py3}
BuildRequires:  python3-cairocffi
BuildRequires:  python3-pandas
BuildRequires:  python3-pillow
%endif
%endif

Patch1:         rdkit-2015.03-use_cairo_backend_on_tests.patch
Patch2:         rdkit-2014.09-do_not_install_sping.patch
Patch4:         rdkit-2014.09-fix_cmake_files_path.patch
Patch7:         rdkit-2015.03-dont_install_contrib.patch

%description
Chemical informatics and machine learning toolkit

%package devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       boost-devel%{?_isa}

%description devel
The %{name}-devel package contains libraries, build data, and header
files for developing applications that use %{name}.


%package doc
Summary:        Documentation for %{name}
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}

%description doc
Documentation files for %{name}.


%package -n python2-rdkit
Summary:        Python 2 bindings for RDKit libraries
%{?python_provide:%python_provide python2-rdkit}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       numpy
Requires:       pycairo
Requires:       python-pillow
Requires:       xorg-x11-fonts-Type1

%description -n python2-rdkit
Python 2 bindings for RDKit libraries

%if 0%{?fedora} && 0%{?with_py3}
%package -n python3-rdkit
Summary:        Python 3 bindings for RDKit libraries
%{?python_provide:%python_provide python3-rdkit}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       python3-numpy
Requires:       python3-cairocffi
Requires:       python3-pillow
Requires:       xorg-x11-fonts-Type1

%description -n python3-rdkit
Python 3 bindings for RDKit libraries
%endif

%package postgresql
Summary:        RDKit cartridge for PostgreSQL
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       postgresql-server(:MODULE_COMPAT_%{postgresql_major})

%description postgresql
PostgreSQL module for RDKit, which implements *mol* datatype to
describe molecules and *fp* datatype for fingerprints, basic comparison
operations, similarity operation (tanimoto, dice) and  index support
(using GiST indexing framework).

To complete installation of the cartridge in PostgreSQL, please follow
the steps detailed in:

%{_docdir}/%{name}-postgresql/README

# Prepare for a double build according to
# https://fedoraproject.org/wiki/Packaging:Python_Appendix#Using_separate_build_directories
%prep
%setup -c -q -n %{rootdir}
mv %{rootdir} python2
pushd python2
%patch1 -p1
%patch2 -p1
%patch4 -p1
%patch7 -p1

rm -rf rdkit/sping

# Copy docs to top dir
cp -pr license.txt ReleaseNotes.* ../
popd

%if 0%{?with_py3}
cp -a python2 python3
find python3 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python3}|'

# 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"
export CXXFLAGS="%{optflags} -Wl,--as-needed"

# Python 2 build
pushd python2
%cmake  -D RDK_INSTALL_INTREE=OFF \
        -D CMAKE_BUILD_TYPE=RelWithDebInfo \
        -D RDK_BUILD_INCHI_SUPPORT:BOOL=ON \
        -D RDK_BUILD_THREADSAFE_SSS:BOOL=ON \
        -D RDK_BUILD_CAIRO_SUPPORT:BOOL=ON \
        -D RDK_BUILD_PGSQL:BOOL=ON \
        -D RDK_PGSQL_STATIC:BOOL=OFF \
        -D RDK_INSTALL_STATIC_LIBS:BOOL=OFF \
        -D RDK_USE_FLEXBISON:BOOL=ON \
        -D RDK_TEST_MULTITHREADED:BOOL=ON \
        -D PYTHON_EXECUTABLE:FILEPATH=%{__python2} \
%ifnarch %{ix86} x86_64
        -D RDK_OPTIMIZE_NATIVE:BOOL=OFF \
%endif
        .
#        -D RDK_BUILD_SWIG_WRAPPERS:BOOL=ON \

make %{?_smp_mflags}

# PostgreSQL cartridge
pushd Code/PgSQL/rdkit
chrpath -d librdkit.so
popd

%if 0%{with_docs}
# Documentation (does not currently build on EPEL)
export RDBASE=%{_builddir}/%{rootdir}/python2
pushd rdkit
epydoc --config epydoc.config
popd
pushd Code
doxygen doxygen/doxygen.config
popd
pushd Docs/Book
make latexpdf
popd
%endif
popd

%if 0%{?fedora} && 0%{?with_py3}
# Python 3 build
pushd python3
%cmake  -D RDK_INSTALL_INTREE=OFF \
        -D CMAKE_BUILD_TYPE=RelWithDebInfo \
        -D RDK_BUILD_INCHI_SUPPORT:BOOL=ON \
        -D RDK_BUILD_THREADSAFE_SSS:BOOL=ON \
        -D RDK_BUILD_CAIRO_SUPPORT:BOOL=ON \
        -D RDK_BUILD_PGSQL:BOOL=ON \
        -D RDK_PGSQL_STATIC:BOOL=OFF \
        -D RDK_INSTALL_STATIC_LIBS:BOOL=OFF \
        -D RDK_USE_FLEXBISON:BOOL=ON \
        -D RDK_TEST_MULTITHREADED:BOOL=ON \
        -D PYTHON_EXECUTABLE:FILEPATH=%{__python3} \
%ifnarch %{ix86} x86_64
        -D RDK_OPTIMIZE_NATIVE:BOOL=OFF \
%endif
        .
#        -D RDK_BUILD_SWIG_WRAPPERS:BOOL=ON \

make %{?_smp_mflags}
%endif

%install
# install Python 2 bindings
pushd python2
make install DESTDIR=%{buildroot}
pushd Code/PgSQL/rdkit
# TODO: upstream installation should be fixed
install -D librdkit.so %{buildroot}%{_libdir}/pgsql/rdkit.so
install -D rdkit.control %{buildroot}%{_datadir}/pgsql/extension/rdkit.control
install -D rdkit--3.5.sql %{buildroot}%{_datadir}/pgsql/extension/rdkit--3.5.sql
popd
popd

%if 0%{?fedora} && 0%{?with_py3}
# install Python 3 bindings
pushd python3
make install DESTDIR=%{buildroot}
popd
%endif

# remove installed doc files
rm -r %{buildroot}/%{_datadir}/RDKit

# Fix rpmlint warnings
FMCS=%{buildroot}%{python2_sitearch}/rdkit/Chem/fmcs/fmcs
sed '1{\@^#!%{__python2}@d}' $FMCS.py > $FMCS.new &&
touch -r $FMCS.py $FMCS.new &&
mv $FMCS.new $FMCS.py
rm $FMCS

%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 &&
mv $FMCS.new $FMCS.py
rm $FMCS
%endif

%check
%if 0%{?with_tests}
# exclude PostgreSQL tests as they require a running DB instance
pushd python2
export RDBASE=%{_builddir}/%{rootdir}/python2
export LD_LIBRARY_PATH=$RDBASE/lib
export PYTHONPATH=$RDBASE
ARGS="-V -E PgSQL" make test
popd

%if 0%{?fedora} && 0%{?with_py3}
pushd python3
export RDBASE=%{_builddir}/%{rootdir}/python3
export LD_LIBRARY_PATH=$RDBASE/lib
export PYTHONPATH=$RDBASE
ARGS="-V -E PgSQL" make test
popd
%endif
%endif

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%license license.txt
%doc ReleaseNotes.*
%{_libdir}/lib*.so.*

%files devel
%{_includedir}/rdkit
%{_libdir}/lib*.so
%{_libdir}/cmake/*.cmake

%files doc
%if 0%{?with_docs}
%doc python2/Docs/Book/_build/latex/RDKit.pdf
%endif

%files -n python2-rdkit
%{python2_sitearch}/rdkit

%if 0%{?fedora} && 0%{?with_py3}
%files -n python3-rdkit
%{python3_sitearch}/rdkit
%endif

%files postgresql
%doc python2/Code/PgSQL/rdkit/README
%{_libdir}/pgsql/rdkit.so
%{_datadir}/pgsql/extension/rdkit--*.sql
%{_datadir}/pgsql/extension/rdkit.control

%changelog
* Mon Apr 03 2017 Gianluca Sforna <giallu@gmail.com> - 2017.3.1-1
- new upstream release

* Thu Feb 23 2017 Gianluca Sforna <giallu@gmail.com> - 2016.09.4-1
- new upstream release

* Tue Feb 07 2017 Kalev Lember <klember@redhat.com> - 2016.09.3-2
- Rebuilt for Boost 1.63

* Fri Dec 30 2016 Gianluca Sforna <giallu@gmail.com> - 2016.09.3-1
- new upstream release

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 2016.09.2-4
- Rebuild for Python 3.6

* Sat Nov 26 2016 Gianluca Sforna <giallu@gmail.com> - 2016.09.2-3
- BR eigen3-devel to activate build of more descriptors

* Wed Nov 23 2016 Gianluca Sforna <giallu@gmail.com> - 2016.09.2-1
- new upstream release
- clean up spec (no more EL6 builds)

* Mon Nov 21 2016 Dan Horák <dan[at]danny.cz> - 2016.09.1-2
- fix non-x86 builds universally

* Fri Nov 11 2016 Gianluca Sforna <giallu@gmail.com> - 2016.09.1-1
- new upstream release
- fix ppc/ppc64 build
- drop upstreamed patches

* Wed Nov  2 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.5-1
- new upstream release
- fix moldraw headers installation with upstream patch
- drop upstreamed patches

* Mon Oct 10 2016 Pavel Raiskup <praiskup@redhat.com> - 2016.03.2-8
- rebuild for postgresql 9.6.0, add guard for incompatible PG plugin
  installation

* Sun Sep 18 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-7
- fix aarch64 build

* Fri Aug 19 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-6
- fix unused-direct-shlib-dependency rpmlint warning

* Wed Aug 17 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-5
- fix wrong-script-interpreter rpmlint error

* Thu Aug 11 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-4
- skip PgSQL tests not working in the build environment
- fix PgSQL cartridge installation

* Fri Aug  5 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-3
- fix arm build
- use CMAKE to build PgSQL cartridge

* Tue Aug  2 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-2
- fix build on rawhide

* Thu Jul 21 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.2-1
- new upstream release
- fix documentation build on Fedora 24
- add patch for broken cartridge build

* Mon Apr 18 2016 Gianluca Sforna <giallu@gmail.com> - 2016.03.1-1
- new upstream release

* Fri Dec  4 2015 Gianluca Sforna <giallu@gmail.com> - 2015.09.2-2
- Fix tests for python 3 wrappers

* Wed Nov 18 2015 Gianluca Sforna <giallu@gmail.com> - 2015.09.2-1
- new upstream release

* Sun Nov  8 2015 Gianluca Sforna <giallu@gmail.com> - 2015.09.1-1
- new upstream release

* Sat Sep 19 2015 Gianluca Sforna <giallu@gmail.com> - 2015.03.1-3
- more fixes from package review
- activate cairo rendering
- add python3 wrappers

* Mon Jul  6 2015 Gianluca Sforna <giallu@gmail.com> - 2015.03.1-2
- activate threading
- always test in verbose mode

* Thu Apr 30 2015 Gianluca Sforna <giallu@gmail.com> - 2015.03.1-1
* new upstream release

* Mon Dec  8 2014 Gianluca Sforna <giallu@gmail.com> - 2014.09.2-1
- new upstream release

* Wed Oct 29 2014 Gianluca Sforna <giallu@gmail.com> - 2014.09.1-1
- new upstream release
- rebase patches

* Wed Jul 16 2014 Gianluca Sforna <giallu@gmail.com> - 2014.03.1-3
- let base package own _datadir/RDKit

* Tue May 27 2014 Gianluca Sforna <giallu@gmail.com> - 2014.03.1-2
- fix EPEL build by adding python2_* macros

* Mon May 12 2014 Gianluca Sforna <giallu@gmail.com> - 2014.03.1-1
- new upstream release
- disable static build with cmake flag, drop related patch

* Sun Mar 30 2014 Gianluca Sforna <giallu@gmail.com> - 2013.09.2-1
- new upstream release
- more spec fixes from review ticket

* Mon Jan  6 2014 Gianluca Sforna <giallu@gmail.com> - 2013.09.1-2
- move cmake files under %%_libdir/cmake

* Mon Nov 11 2013 Gianluca Sforna <giallu@gmail.com> - 2013.09.1-1
- new upstream release

* Tue Jul 30 2013 Gianluca Sforna <giallu@gmail.com> - 2013.06.1-2
- use %%cmake macro
- fix tests in rawhide

* Sun Jul 28 2013 Gianluca Sforna <giallu@gmail.com> - 2013.06.1-1
- new upstream release
- spec clean up

* Thu May 30 2013 Gianluca Sforna <giallu@gmail.com> - 2013.03.2-1
- new upstream release
- fix shebang on rdkit/Chem/MCS.py

* Wed May 29 2013 Gianluca Sforna <giallu@gmail.com> - 2013.03-2
- spec fixes from package review (#804125)

* Sat Apr 27 2013 Gianluca Sforna <giallu@gmail.com> - 2013.03-1
- new upstream release

* Wed Feb  6 2013 Gianluca Sforna <giallu@gmail.com> - 2012.12-2
- add inchi support

* Tue Jan 22 2013 Gianluca Sforna <giallu@gmail.com> - 2012.12-1
- New upstream release
- BR fonts package

* Sun Oct 21 2012 Gianluca Sforna <giallu@gmail.com> - 2012.09-1
- New upstream release
- add python related requires

* Wed Jul 11 2012 Gianluca Sforna <giallu@gmail.com> - 2012.06-1
- New upstream release

* Fri Apr 13 2012 Gianluca Sforna <giallu@gmail.com> - 2012.03-1
- New upstream release
- Fix some packaging issues as per review (#804125)

* Wed Mar 07 2012 Gianluca Sforna <giallu@gmail.com> - 2011.12-1
- New upstream release

* Mon Dec 05 2011 Gianluca Sforna <giallu@gmail.com> - 2011.09-2.20111202svn1877
- Package a newer snapshot for postgres 9.1 support
- Remove rpath from postgres cartridge

* Fri Nov 25 2011 Gianluca Sforna <giallu@gmail.com> - 2011.09-1
- New upstream release
- rebase patches
- drop upstreamed patch

* Mon Aug 15 2011 Gianluca Sforna <giallu@gmail.com> - 2011.06-2
- Final release
- add SDMOlsupplier patch, fixes loop on tests

* Wed Jul  6 2011 Gianluca Sforna <giallu@gmail.com> - 2011.06-1
- New upstream (beta) release
- rebase patches

* Mon Jun 13 2011 Gianluca Sforna <giallu@gmail.com> - 2011.03-1
- New upstream release
- drop upstreamed patch

* Wed Apr  6 2011 Gianluca Sforna <giallu@gmail.com> - 2010.12-3
- Add draw_refactoring patch

* Fri Jan 14 2011 Gianluca Sforna <giallu@gmail.com> - 2010.12-2
- New upstream release
- filter auto-provides for python extensions

* Thu Dec 30 2010 Gianluca Sforna <giallu@gmail.com> - 2010.12-1
- New upstream (beta) release
- drop upstream patch
- add patches for rpath, static libs
- Fix spurious executable bits

* Mon Oct  4 2010 Gianluca Sforna <giallu@gmail.com> - 2010.09-1
- New upstream release
- Move build in tree to support tests
- build PostgreSQL cartridge

* Tue Sep  7 2010 Gianluca Sforna <giallu gmail com>
- Split subpackages

* Mon Jul  5 2010 Gianluca Sforna <giallu gmail com> - 2010.Q2-1
- Initial package