File libArcus.spec of Package libArcus

#
# spec file for package libArcus
#
# Copyright (c) 2023 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/
#

%{?primary_python:%define pythons %primary_python}
%{?sle15_python_module_pythons}
%define pyqt_build_for_qt6 1
%define sover 3
%define gccver 13
Name:           libArcus
%define sversion        5.3.0
Version:        5.3.0
Release:        0
Summary:        3D printer control software
License:        LGPL-3.0-only
Group:          Development/Libraries/C and C++
URL:            https://github.com/Ultimaker/%name
Source0:        https://github.com/Ultimaker/libArcus/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://github.com/Ultimaker/pyArcus/archive/%{version}.tar.gz#/pyArcus-%{version}.tar.gz

Source2:        StandardProjectSettings.cmake
Source3:        SIPMacros.cmake
Source4:        CMakeLists.txt
Source5:        FindSIP.cmake

# PATCH-FIX-OPENSUSE - use Qt5 sip import name, taken from Fedora
#Patch0:         libArcus-3.5.1-PyQt5.sip.patch
# PATCH-FIX-UPSTREAM
#Patch1:         0001-Use-single-parameter-SetTotalBytesLimit-fix-protobuf.patch
BuildRequires:  cmake >= 3.23
BuildRequires:  gcc%{?gccver}-c++
BuildRequires:  protobuf-devel >= 3.0.0
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module packaging}
BuildRequires:  %{python_module PyQt6-sip}
BuildRequires:  %{python_module sip}
BuildRequires:  %{python_module pyqt-builder}
BuildRequires:  %{python_module sip6-devel}
BuildRequires:  python-pyqt-rpm-macros
BuildRequires:  python-rpm-macros
#!BuildIgnore:  libgcc_s1


%description
Communication library between internal components for Ultimaker software

%package -n %name%{sover}
Summary:        3D printer control software
# The forked libArcus-lulzbot uses the same SONAME ...
Group:          System/Libraries
Provides:       libArcus-Ultimaker
# libArcus-lulzbot is a fork of libArcus that did not rename its libs and we happen
# ro run into a file conflict. Explicitly mark this conflict, even though it sounds odd
Conflicts:      libArcus1

%description -n %name%{sover}
Communication library between internal components for Ultimaker software

%package devel
Summary:        Header files for libArcus
Group:          Development/Libraries/C and C++
Requires:       libArcus%{sover} = %{version}
Requires:       protobuf-devel >= 3.0.0
Requires:       %{python_flavor}-sip-devel

%description devel
The %{name}-devel package includes the header files, libraries and development
tools necessary for compiling and linking programs which use %{name}.

%package -n %{python_flavor}-Arcus
Summary:        Python bindings for libArcus
Group:          Development/Languages/Python
Requires:       libArcus-Ultimaker
Requires:       %{python_flavor}-PyQt6-sip

%description -n %{python_flavor}-Arcus
Python bindings for the Arcus communication library.

%prep
%autosetup -n %{name}-%{version} -p1 -a 1
cp -a pyArcus-%{version}/python .
cp -a pyArcus-%{version}/include/pyArcus include
mkdir cmake
cp -a %{SOURCE2} %{SOURCE3} %{SOURCE5} cmake/
rm -rf CMakeLists.txt
cp -a %{SOURCE4} .
cp -a pyArcus-%{version}/src/PythonMessage.cpp python/

sed -i "s|import sip; print(sip.SIP_VERSION_STR)|import PyQt6.sip; print(PyQt6.sip.SIP_VERSION_STR)|" cmake/FindSIP.cmake
sed -i "s|PyQt5|PyQt6|" cmake/FindSIP.cmake

%build
%{?gccver:export CXX=g++-%{gccver}}
%{?gccver:export CC=gcc-%{gccver}}
%cmake -DBUILD_EXAMPLES:BOOL=OFF -DCMAKE_SKIP_RPATH:BOOL=ON \
       -DPYTHON_EXECUTABLE=/usr/bin/python%{python_version} \
       -DPython_SITELIB_LOCAL=%{python_sitelib} \
       -DCXX=g++-%{gccver}

#-DSIP_INCLUDE_DIR="%{python_sitelib}/Qt6/include/python3.10m"
  
%make_build

%install
%pyqt_install
#%cmake_install
# Create a minimal dist-info (PEP 241/314)
#cat > %{buildroot}%{python_sitearch}/Arcus-%{version}.egg-info <<HERE_EOF
Metadata-Version: 1.1
Name:           Arcus
Version:        %{version}
Summary:        Python bindings for libArcus
Author-email: info@ultimaker.com
License:        LGPL-3.0-only
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
HERE_EOF

%post   -n %name%{sover} -p /sbin/ldconfig

%postun -n %name%{sover} -p /sbin/ldconfig

%files devel
%doc TODO.md
%{_includedir}/Arcus
%{_libdir}/cmake/Arcus
%{_libdir}/libArcus.so

%files -n %name%{sover}
%license LICENSE
%doc README.md
%{_libdir}/libArcus.so.*

%files -n %{python_flavor}-Arcus
%license LICENSE
%{python_sitearch}/Arcus.so
%{python_sitearch}/Arcus-*.egg-info

%changelog
openSUSE Build Service is sponsored by