From 55ef08022c392e1b91447c36025b0aa665a366bcd105f1d4077b6790879a1c3c Mon Sep 17 00:00:00 2001 From: Matwey Kornilov Date: Mon, 30 Dec 2024 14:15:15 +0000 Subject: [PATCH] - Run unit tests for all available python versions OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/xtensor-python?expand=0&rev=5 --- .gitattributes | 23 +++++ .gitignore | 1 + 0001-Install-as-arch-independent.patch | 30 ++++++ cxx-flags.patch | 13 +++ xtensor-python-0.27.0.tar.gz | 3 + xtensor-python.changes | 14 +++ xtensor-python.spec | 125 +++++++++++++++++++++++++ 7 files changed, 209 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 0001-Install-as-arch-independent.patch create mode 100644 cxx-flags.patch create mode 100644 xtensor-python-0.27.0.tar.gz create mode 100644 xtensor-python.changes create mode 100644 xtensor-python.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/0001-Install-as-arch-independent.patch b/0001-Install-as-arch-independent.patch new file mode 100644 index 0000000..941775f --- /dev/null +++ b/0001-Install-as-arch-independent.patch @@ -0,0 +1,30 @@ +From 627ff935c580e5d43824b5ec884502e8b9811394 Mon Sep 17 00:00:00 2001 +From: "Matwey V. Kornilov" +Date: Mon, 6 May 2024 20:57:19 +0300 +Subject: [PATCH] Install as arch-independent + +xternsor-python is header only library, so prefer arch-independed paths cmake. + +References: + * https://github.com/xtensor-stack/xtl/commit/d877d94836aff4d0f727acf3eaab8f4880ecb625 + * https://github.com/xtensor-stack/xtensor/commit/7738389861044c9618c7d59fb7602f7dddc1df7f +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6521c98..47af271 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -123,7 +123,7 @@ export(EXPORT ${PROJECT_NAME}-targets + install(FILES ${XTENSOR_PYTHON_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtensor-python) + +-set(XTENSOR_PYTHON_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE ++set(XTENSOR_PYTHON_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE + STRING "install path for xtensor-pythonConfig.cmake") + + configure_package_config_file(${PROJECT_NAME}Config.cmake.in +-- +2.44.0 + diff --git a/cxx-flags.patch b/cxx-flags.patch new file mode 100644 index 0000000..c9fcc27 --- /dev/null +++ b/cxx-flags.patch @@ -0,0 +1,13 @@ +Index: xtensor-python-0.27.0/test/CMakeLists.txt +=================================================================== +--- xtensor-python-0.27.0.orig/test/CMakeLists.txt ++++ xtensor-python-0.27.0/test/CMakeLists.txt +@@ -30,7 +30,7 @@ include(CheckCXXCompilerFlag) + string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -fvisibility=hidden") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder -Wconversion -fvisibility=hidden") + CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) + + if (HAS_CPP14_FLAG) diff --git a/xtensor-python-0.27.0.tar.gz b/xtensor-python-0.27.0.tar.gz new file mode 100644 index 0000000..4bdc78a --- /dev/null +++ b/xtensor-python-0.27.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40ee01bd213aeb7bf64f6d8a3257f4fa98ed31c401596c6c7b3b115f61a473b9 +size 65455 diff --git a/xtensor-python.changes b/xtensor-python.changes new file mode 100644 index 0000000..93b3dc5 --- /dev/null +++ b/xtensor-python.changes @@ -0,0 +1,14 @@ +------------------------------------------------------------------- +Thu Dec 19 13:50:59 UTC 2024 - Matwey Kornilov + +- Run unit tests for all available python versions + +------------------------------------------------------------------- +Mon May 27 17:29:38 UTC 2024 - Andreas Schwab + +- cxx-flags.patch: Remove unsupported compiler flag + +------------------------------------------------------------------- +Mon May 6 13:29:15 UTC 2024 - Matwey Kornilov + +- Initial version diff --git a/xtensor-python.spec b/xtensor-python.spec new file mode 100644 index 0000000..ff869e2 --- /dev/null +++ b/xtensor-python.spec @@ -0,0 +1,125 @@ +# +# spec file for package xtensor-python +# +# 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/ +# + + +Name: xtensor-python +Version: 0.27.0 +Release: 0 +Summary: Python bindings for the xtensor C++ multi-dimensional array library +License: BSD-3-Clause +URL: https://github.com/xtensor-stack/xtensor-python +Source0: https://github.com/xtensor-stack/xtensor-python/archive/refs/tags/%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Install-as-arch-independent.patch +Patch1: cxx-flags.patch +BuildRequires: %{python_module breathe} +BuildRequires: %{python_module numpy-devel} +BuildRequires: %{pythons} +BuildRequires: cmake +BuildRequires: doctest-devel +BuildRequires: doxygen +BuildRequires: fdupes +BuildRequires: gcc-c++ +BuildRequires: gtest +BuildRequires: make +BuildRequires: python-rpm-macros +BuildRequires: xtensor-devel >= 0.25.0 +BuildRequires: cmake(pybind11) >= 2.6.1 +Group: Development/Libraries/C and C++ + +%description +Enables inplace use of numpy arrays in C++ with all the benefits from xtensor: + * C++ universal function and broadcasting, + * STL - compliant APIs, + * A broad coverage of numpy APIs. + +The Python bindings for xtensor are based on the pybind11 C++ library, which +enables seamless interoperability between C++ and Python. + +%package devel +Summary: Development files for xtensor-python +BuildArch: noarch +Requires: xtensor-devel + +%description devel +Enables inplace use of numpy arrays in C++ with all the benefits from xtensor: + * C++ universal function and broadcasting, + * STL - compliant APIs, + * A broad coverage of numpy APIs. + +The Python bindings for xtensor are based on the pybind11 C++ library, which +enables seamless interoperability between C++ and Python. + +%package doc +Summary: Documentation for xtensor-python +Group: Documentation/HTML +BuildArch: noarch + +%description doc +Enables inplace use of numpy arrays in C++ with all the benefits from xtensor: + * C++ universal function and broadcasting, + * STL - compliant APIs, + * A broad coverage of numpy APIs. + +The Python bindings for xtensor are based on the pybind11 C++ library, which +enables seamless interoperability between C++ and Python. + +%prep +%autosetup -p1 + +%build +%define __builddir build + +%cmake +%cmake_build + +# build documentation +make -C %{_builddir}/%{buildsubdir}/docs html + +# build unit tests for each available python version +%{python_expand # + cd %{_builddir}/%{buildsubdir} + %define __builddir build.$python + %cmake -DBUILD_TESTS:BOOL=ON -DPYTHON_EXECUTABLE=%{_bindir}/$python + %cmake_build +} + +%install +%define __builddir build + +%cmake_install + +# install documentation +mkdir -p %{buildroot}/%{_docdir}/%{name} +cp -r %{_builddir}/%{buildsubdir}/docs/build/html/* %{buildroot}/%{_docdir}/%{name} + +%fdupes -s %{buildroot}/%{_docdir} + +%check +# run unit tests +%{python_expand # + %cmake_build -C %{_builddir}/%{buildsubdir}/build.$python xtest +} + +%files doc +%doc %{_docdir}/%{name} + +%files devel +%license LICENSE +%{_includedir}/xtensor-python +%{_datadir}/cmake/xtensor-python + +%changelog