File boost_python2.spec of Package boost_python2

#
# spec file for package boost
#
# 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/
#


%define ver 1.88.0
%define _ver 1_88_0
%define package_version %_ver
%define file_version %_ver
%define lib_appendix %_ver
%define docs_version 1.56.0
%define short_version 1_56
%define pname boost
%bcond_with    build_docs
%bcond_with package_pdf
%bcond_with build_quickbook
%bcond_with    boost_devel
%bcond_with ringdisabled

%define package_name boost%{library_version}
%define my_docdir %{_docdir}/boost%{library_version}

%if 0%{?suse_version} < 1500
  %define python2_sitearch %{python_sitearch}
%endif

%define build_base 0
%define name_suffix -extra
%bcond_with python3
%bcond_without python2
%bcond_with mpi

%bcond_with python_numpy
%bcond_with build_context
%define package_prefix %{_prefix}
%define package_bindir %{_bindir}
%define package_libdir %{_libdir}
%define package_includedir %{_includedir} 
%define base_name boost%{name_suffix}
%define package_python2_sitearch %python2_sitearch
%define package_python3_sitearch %python3_sitearch

%bcond_with boost_fiber

Name:           %{base_name}
Version:        %ver
Release:        0
%define library_version %_ver

Summary:        Boost C++ Libraries
License:        BSL-1.0
Group:          Development/Libraries/C and C++
URL:            http://www.boost.org
Source0:        https://boostorg.jfrog.io/artifactory/main/release/%{version}/source/boost_%{_ver}.tar.bz2
Source1:        boost-rpmlintrc
Source3:        http://downloads.sourceforge.net/project/boost/boost-docs/1.56.0/boost_1_56_pdf.tar.bz2
Source4:        existing_extra_docs
Source10:       exception.objdump
Source11:       __init__.py
Source100:      baselibs.conf
Source101:      symbol_diff.sh
Source102:      README.boost-devel
Patch1:         boost-thread.patch
Patch2:         boost-no_type_punning.patch
Patch4:         boost-pool_check_overflow.patch
Patch5:         boost-strict_aliasing.patch
Patch6:         boost-use_std_xml_catalog.patch
Patch7:         boost-rpmoptflags-only.patch
Patch9:         boost-aarch64-flags.patch
Patch15:        boost-1.57.0-python-abi_letters.patch
Patch16:        boost-1.55.0-python-test-PyImport_AppendInittab.patch
Patch17:        python_mpi.patch
Patch18:        dynamic_linking.patch
Patch20:        python_library_name.patch
Patch21:        boost-remove-cmakedir.patch
BuildRequires:  fdupes
BuildRequires:  gmp-devel
BuildRequires:  libbz2-devel
BuildRequires:  libexpat-devel
BuildRequires:  libicu-devel
BuildRequires:  pkgconfig(zlib)
BuildRequires:  gcc-c++
BuildRequires:  dos2unix
BuildRequires:  python2-devel
%if %{with python_numpy}
BuildRequires:  python2-numpy-devel
%endif

%description
Boost provides free peer-reviewed portable C++ source libraries. The
emphasis is on libraries that work well with the C++ Standard Library.
One goal is to establish "existing practice" and provide reference
implementations so that the Boost libraries are suitable for eventual
standardization. Some of the libraries have already been proposed for
inclusion in the C++ Standards Committee's upcoming C++ Standard
Library Technical Report.

Although Boost was begun by members of the C++ Standards Committee
Library Working Group, membership has expanded to include nearly two
thousand members of the C++ community at large.

%package     -n boost-license%{library_version}
Summary:        Boost License
Group:          Development/Libraries/C and C++
Provides:       boost-license = %{version}-%{release}
BuildArch:      noarch

%description -n boost-license%{library_version}
This package contains the license boost is provided under.
%package     -n %{package_name}-python2
Summary:        Boost.MPI Python 2.x serialization library
Group:          System/Libraries
Requires:       %{package_name}

%description -n %{package_name}-python2 
This package contains the Boost.MPI Python 2.x serialization
inteface.

%package     -n libboost_python-py2_7-%{library_version}
Summary:        Boost.Python runtime library
Group:          System/Libraries
Requires:       boost-license%{library_version}

%description -n libboost_python-py2_7-%{library_version}
This package contains the Boost::Python runtime library for python2.

%package     -n libboost_python-py2_7-%{library_version}-devel
Summary:        Development headers for Boost.Python library
Group:          Development/Libraries/C and C++
Requires:       libboost_container%{library_version}-devel = %{version}
Requires:       libboost_graph%{library_version}-devel = %{version}
Requires:       libboost_headers%{library_version}-devel = %{version}
Requires:       libboost_python-py2_7-%{library_version} = %{version}
Conflicts:      boost-devel < 1.63
Conflicts:      libboost_python-devel-impl
Provides:       libboost_python-devel-impl = %{version}
# for compatibility (maybe remove?)
Provides:       libboost_python-devel = %{version}

%description -n libboost_python-py2_7-%{library_version}-devel
Development headers for Boost::Python library for python2.

%package     -n libboost_numpy-py2_7-%{library_version}
Summary:        Boost.Python.NumPy runtime library
Group:          System/Libraries
Requires:       boost-license%{library_version}

%description -n libboost_numpy-py2_7-%{library_version}
This package contains the Boost::Python::NumPy runtime library for python2.

%package     -n libboost_numpy-py2_7-%{library_version}-devel
Summary:        Development headers for Boost.Python.NumPy library
Group:          Development/Libraries/C and C++
Requires:       libboost_headers%{library_version}-devel = %{version}
Requires:       libboost_numpy-py2_7-%{library_version} = %{version}
Conflicts:      boost-devel < 1.63
Conflicts:      libboost_numpy-devel-impl
Provides:       libboost_numpy-devel-impl = %{version}

%description -n libboost_numpy-py2_7-%{library_version}-devel
Development headers for Boost::Python::NumPy library for python2.

%prep
%setup -q -n boost_%{library_version}
#-b 3
#everything in the tarball has the executable flag set ...
find -type f ! \( -name \*.sh -o -name \*.py -o -name \*.pl \) -exec chmod -x {} +
%patch -P1 -p1
%patch -P2
%patch -P4
%patch -P5
%patch -P6 -p1
%patch -P7
%patch -P9 -p1
%patch -P15 -p1
%patch -P16 -p1
%patch -P17 -p1
%patch -P18 -p1
%patch -P20 -p1
%patch -P21 -p1

%build
find . -type f -exec chmod u+w {} +

# General case
cat << EOF >user-config.jam
import os ;
local RPM_OPT_FLAGS = [ os.environ RPM_OPT_FLAGS ] ;
using gcc : : : <compileflags>\$(RPM_OPT_FLAGS) ;
project user-config ;
EOF

# Since boost build system is broken and incable of handling multiple python versions,
# we need to build boost piece by piece. First time to build all the non-python bits,
# then we build MPI and/or PYTHON modules for two python versions we need.
# MPI builds a python module.
cat << \EOF >.build
export PY_LIBRARIES_FLAGS="--with-python"

# Dummy entry to make sure we don't build everything
export LIBRARIES_FLAGS="--with-system"

EOF

# Need specific Boost Jam config files.
#   1. one all "normal" libraries
#   2. one for each python version for for python/mpi libraries
#      use staging directories for MPI/PYTHON combinations.

# General case
# alias boost_python_alias : : <library>/boost/python//boost_python ;
cat << EOF >user-config.jam
EOF

# bootstrap b2
./bootstrap.sh \
    --prefix=%{package_prefix} --exec-prefix=%{package_bindir} \
    --libdir=%{package_libdir} --includedir=%{package_includedir} \
    --with-toolset=gcc

# Read shared build instructions
. ./.build

# Build boost base PYTHON and MPI, installed in python staging
cp user-config.jam user-config-py.jam
cat << EOF >> user-config-py.jam
using python
     : %{py_ver}
     : %{_bindir}/python2
     : %{_includedir}/python%{py_ver}
     : %{_libdir}/python%{py_ver}
     :
     :
     ;
EOF

./b2 -d+2 -q --user-config=./user-config-py.jam \
    --build-type=minimal --build-dir=./python-build \
    --python-buildid=py2.7 \
    --stagedir=./python-stage %{?_smp_mflags} \
    $PY_LIBRARIES_FLAGS \
    threading=multi link=shared runtime-link=shared stage

%if 0
# This is run for both mini and non-mini build
./b2 -d+2 -q --user-config=./user-config.jam \
    --build-type=minimal --build-dir=./build \
    --stagedir=./stage %{?_smp_mflags} \
    $LIBRARIES_FLAGS \
    threading=multi link=shared runtime-link=shared stage
%endif

# Verify that all symbols built in different stages are interchangeable.
# Can't be too careful!
cp %{SOURCE101} .
chmod +x symbol_diff.sh
#./symbol_diff.sh python-stage/lib/libboost_serialization.so  stage/lib/libboost_serialization.so
#./symbol_diff.sh python-stage/lib/libboost_mpi.so            stage/lib/libboost_mpi.so

%install

# Read shared build instructions
. ./.build

./b2 -d+2 -q --user-config=./user-config-py.jam \
    --build-type=minimal --build-dir=./python-build \
    --python-buildid=py2.7 \
    --prefix=%{buildroot}%{package_prefix} --exec-prefix=%{buildroot}%{package_bindir} \
    --libdir=%{buildroot}%{package_libdir} --includedir=%{buildroot}%{package_includedir} \
    --stagedir=./python-stage %{?_smp_mflags} \
    $PY_LIBRARIES_FLAGS \
    threading=multi link=shared runtime-link=shared install

%if 0
# Generic install
./b2 -d+2 -q \
     --build-type=minimal --build-dir=./build --stagedir=./stage \
     --prefix=%{buildroot}%{package_prefix} --exec-prefix=%{buildroot}%{package_bindir} \
     --libdir=%{buildroot}%{package_libdir} --includedir=%{buildroot}%{package_includedir} \
     --user-config=./user-config.jam \
     $LIBRARIES_FLAGS \
     threading=multi link=shared runtime-link=shared install
%endif

rm -r %{buildroot}%{package_includedir}
rm -r %{buildroot}%{package_libdir}/cmake

# No python dependencies in the main tree

#! $(ldd %{buildroot}%{package_libdir}/*.so* | grep python\\.)

#rm -r %{buildroot}%{package_libdir}/libboost_python.so
#rm -r %{buildroot}%{package_libdir}/libboost_mpi_python.so
#ln -s libboost_mpi_python-py2_7.so %{buildroot}%{package_libdir}/libboost_mpi_python.so
ln -s libboost_python-py2_7.so     %{buildroot}%{package_libdir}/libboost_python.so

# Move Python libraries over to proper places
#mkdir -p %{buildroot}%{package_python2_sitearch}/boost/parallel/mpi/
#mv %{buildroot}/%{package_libdir}/mpi.so %{buildroot}%{package_python2_sitearch}/boost/parallel/mpi/
#install -m 0644 libs/mpi/build/__init__.py %{buildroot}%{package_python2_sitearch}/boost/parallel/mpi/
#install -m 0644 %{SOURCE11} %{buildroot}%{package_python2_sitearch}/boost/parallel
#install -m 0644 %{SOURCE11} %{buildroot}%{package_python2_sitearch}/boost

# duplicate from boost-base flavour
#rm %{buildroot}%{package_libdir}/cmake/BoostDetectToolset-%{version}.cmake
#rm -r %{buildroot}%{package_libdir}/cmake/Boost-%{version}
#rm -r %{buildroot}%{package_libdir}/cmake/boost_headers-%{version}
#rm -rf %{buildroot}%{package_libdir}/cmake/boost_{w,}serialization-%{version}
#rm -r %{buildroot}%{package_libdir}/cmake/boost_container-%{version}
rm -f %{buildroot}%{package_libdir}/libboost_container.so*
#rm -r %{buildroot}%{package_libdir}/cmake/boost_graph-%{version}
rm -f %{buildroot}%{package_libdir}/libboost_graph.so*
# If no library was needed to be built, system was built to avoid building everything.
# If needs to be removed from the extra package in that case
#rm -Rf %{buildroot}%{package_libdir}/cmake/boost_system-%{version}
#rm -Rf %{buildroot}%{package_libdir}/libboost_system.so*

#rm -rf %{buildroot}%{package_libdir}/libboost_numpy.so{,.%{version}}
#rm -rf %{buildroot}%{package_libdir}/libboost_mpi_python.so.%{version}
#rm -rf %{buildroot}%{package_libdir}/libboost_python.so.%{version}

#rm -r %{buildroot}%{package_includedir}/boost
#rm %{buildroot}%{package_libdir}/libboost_{w,}serialization*
#rmdir --ignore-fail-on-non-empty %{buildroot}%{package_libdir}
#fdupes %{buildroot}%{my_docdir}

%post -n libboost_python-py2_7-%{library_version} -p /sbin/ldconfig
%if %{with python_numpy}
%post -n libboost_numpy-py2_7-%{library_version} -p /sbin/ldconfig
%endif

%postun -n libboost_python-py2_7-%{library_version} -p /sbin/ldconfig
%if %{with python_numpy}
%postun -n libboost_numpy-py2_7-%{library_version} -p /sbin/ldconfig
%endif

%files -n libboost_python-py2_7-%{library_version}
%{package_libdir}/libboost_python-py2_7.so.%{version}

%files -n libboost_python-py2_7-%{library_version}-devel
##%dir %{package_libdir}/cmake/boost_python-%{version}
##%{package_libdir}/cmake/boost_python-%{version}/*
%{package_libdir}/libboost_python.so
%{package_libdir}/libboost_python-py2_7.so

%if %{with python_numpy}
%files -n libboost_numpy-py2_7-%{library_version}
%{package_libdir}/libboost_numpy-py2_7.so.%{version}

%files -n libboost_numpy-py2_7-%{library_version}-devel
##%dir %{package_libdir}/cmake/boost_numpy-%{version}
##%{package_libdir}/cmake/boost_numpy-%{version}/*
%{package_libdir}/libboost_numpy-py2_7.so

%endif # with numpy

%if 0

%files -n boost-license%{library_version}
%license LICENSE_1_0.txt
%if 0%{?sle_version} >= 120000 && 0%{?sle_version} <= 120200 && !0%{?is_opensuse}
%attr(755,root,root) %dir %{_defaultlicensedir}
%endif

%endif

%changelog
openSUSE Build Service is sponsored by