File mera.spec of Package mera
#
# spec file for package mera
#
# 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/
#
%if 0%{?suse_version} > 1600
%bcond_with tvm
%else
%bcond_with tvm
%endif
Name: mera
Version: 1.6.0
Release: 0
Summary: MERA
License: GPL-2.0-only
Group: System/Kernel
URL: https://github.com/Edgecortix-Inc/mera
Source0: https://github.com/Edgecortix-Inc/mera/archive/refs/tags/%{version}.tar.gz#/mera-%{version}.tar.gz
Source1: preamble
Source10: https://github.com/Edgecortix-Inc/mera-tvm-public/archive/refs/tags/%{version}.tar.gz#/mera-tvm-public-%{version}.tar.gz
Source11: https://github.com/Edgecortix-Inc/mera-dna-public/archive/refs/tags/%{version}.tar.gz#/mera-dna-public-%{version}.tar.gz
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1aaba11da9aa7d7d6b52a74d45b31cac118295a1
Patch0: kernel-6.4.diff
BuildRequires: %{kernel_module_package_buildreqs}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel}
%if %{with tvm}
BuildRequires: cmake
BuildRequires: dlpack-devel
BuildRequires: dmlc-core-devel
BuildRequires: gcc-c++
%endif
%kernel_module_package -p %_sourcedir/preamble
%define python_subpackage_only 1
%python_subpackages
%description
MERA
%package -n python-mera
Summary: MERA
License: Apache-2.0
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires: python-PyYAML
Requires: python-matplotlib
Requires: python-seaborn
%description -n python-mera
MERA
%prep
%setup -q -a 10 -a 11
%autopatch -p1
mv mera-tvm-public-%{version}/* mera-tvm/
mv mera-dna-public-%{version}/* mera-dna/
%if %{with tvm}
pushd lib
%ifarch x86_64
ln -s libmeradna-full.x86.so.%{version} libmeradna-full.x86.so
ln -s libmeradna-runtime.x86.so.%{version} libmeradna-runtime.x86.so
%endif
popd
pushd mera-tvm
mkdir -p %{__builddir}
cp cmake/config.cmake %{__builddir}/
# -DUSE_LIBBACKTRACE=OFF does not prevent it trying to get it via git
sed -i 's/USE_LIBBACKTRACE AUTO/USE_LIBBACKTRACE OFF/' %{__builddir}/config.cmake
popd
%endif
pushd src/mera/pcie_driver
set -- *
mkdir source
mv "$@" source/
mkdir obj
popd
%build
pushd src/mera/pcie_driver
for flavor in %{flavors_to_build}; do
rm -rf obj/$flavor
cp -r source obj/$flavor
make %{?_smp_mflags} -C %{kernel_source $flavor} %{?linux_make_arch} modules M=$PWD/obj/$flavor
done
popd
%pyproject_wheel
%if %{with tvm}
export MERA_HOME=$PWD
pushd mera-tvm
%cmake -DMERADNA_RUNTIME_ONLY=ON -DDMLC_PATH="%{_includedir}/dmlc" -DDLPACK_PATH="%{_includedir}/dlpack"
%cmake_build runtime
popd
pushd cpp
export TVM_LIBRARY_PATH=../mera-tvm/%{__builddir}
%cmake
%cmake_build
popd
%endif
%install
pushd src/mera/pcie_driver
export INSTALL_MOD_PATH=%{buildroot}
for flavor in %{flavors_to_build}; do
make -C %{kernel_source $flavor} %{?linux_make_arch} modules_install M=$PWD/obj/$flavor
done
popd
%pyproject_install
%python_expand rm -rf %{buildroot}%{$python_sitelib}/mera/pcie_driver
%python_clone -a %{buildroot}%{_bindir}/mera
%python3_fix_shebang
%python_expand %fdupes %{buildroot}%{$python_sitelib}/mera
%if %{with tvm}
pushd mera-tvm
%cmake_install
popd
pushd cpp
%cmake_install
popd
%endif
%post -n python-mera
%python_install_alternative mera
%postun -n python-mera
%python_uninstall_alternative mera
%files %{python_files mera}
%python_alternative %{_bindir}/mera
%{python_sitelib}/mera
%{python_sitearch}/mera-%{version}.dist-info
%changelog