File gemmi.spec of Package gemmi

#
# spec file for package gemmi
#
# Copyright (c) 2024 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 so_version 0
%{?sle15_python_module_pythons}
Name:           gemmi
Version:        0.7.3
Release:        0
Summary:        Macromolecular crystallography library and utilities
License:        MPL-2.0
URL:            https://project-gemmi.github.io/
Source:         https://github.com/project-gemmi/gemmi/archive/refs/tags/v%{version}.tar.gz#/gemmi-%{version}.tar.gz
BuildRequires:  %{python_module base}
BuildRequires:  %{python_module nanobind-devel}
# numpy, pytest to run the tests
BuildRequires:  %{python_module numpy}
BuildRequires:  %{python_module pytest}
BuildRequires:  cmake
# need compiler w/ -stdc=c++-17
%if 0%{?suse_version} > 0 && 0%{?suse_version} < 1600 && 0%{?is_opensuse}
BuildRequires:  gcc10-c++
%else
BuildRequires:  gcc-c++
%endif
BuildRequires:  python-rpm-macros
BuildRequires:  zlib-devel
Requires:       libgemmi_cpp%{so_version} = %{version}

%define python_subpackage_only 1
%python_subpackages

%description
GEMMI is a library for structural biology, accompanied by a set of
programs, developed primarily for use in macromolecular crystallography.

%package -n libgemmi_cpp%{so_version}
Summary:        Shared library for GEMMI, a library for structural biology

%description -n libgemmi_cpp%{so_version}
GEMMI is a library for structural biology, accompanied by a set of
programs, developed primarily for use in macromolecular crystallography.

This package provides the shared library for GEMMI.

%package devel
Summary:        GEMMI development files
Requires:       libgemmi_cpp%{so_version} = %{version}

%description devel
GEMMI is a library for structural biology, accompanied by a set of
programs, developed primarily for use in macromolecular crystallography.

This package contains build data and header files for developing
applications that use GEMMI.

%package -n python-%{name}
Summary:        Python %{python_version} bindings for GEMMI
Group:          Development/Languages/Python

%description -n python-%{name}
GEMMI is a library for structural biology, accompanied by a set of
programs, developed primarily for use in macromolecular crystallography.

This package contains the python %{python_version} bindings for GEMMI.

%prep
%autosetup -p1

# Examples must not be executable, must not have hashbangs
sed -E -i "1{\@#!/usr/bin/env python@d}" examples/*.py

%build
%{python_expand #
mkdir -p ../build_$python
cp -pr . ../build_$python
pushd ../build_$python
%if 0%{?suse_version} > 0 && 0%{?suse_version} < 1600 && 0%{?is_opensuse}
export CXX=g++-10
export CXXFLAGS="%{?optflags} -std=c++17"
%endif
%cmake \
  -DBUILD_SHARED_LIBS=ON \
  -DPython_EXECUTABLE=%{_bindir}/$python \
  -DUSE_PYTHON=ON \
  -DADD_SOVERSION=ON
%cmake_build
# For C++ library tests
%cmake_build cpptest
popd
}

%install
%{python_expand #
pushd ../build_$python
%cmake_install
popd
}

%check
%{python_expand #
pushd ../build_$python
%ctest
popd
}
export PATH+=:%{buildroot}%{_bindir}
%pytest_arch

%ldconfig_scriptlets -n libgemmi_cpp%{so_version}

%files
%license LICENSE.txt
%doc README.md
%{_bindir}/gemmi

%files -n libgemmi_cpp%{so_version}
%license LICENSE.txt
%{_libdir}/libgemmi_cpp.so.%{so_version}*

%files devel
%license LICENSE.txt
%{_includedir}/gemmi/
%{_libdir}/*.so
%{_libdir}/cmake/gemmi/

%files %{python_files %{name}}
%{python_sitearch}/%{name}/

%changelog
openSUSE Build Service is sponsored by