15
0

Accepting request 1248956 from home:hsk17:d-l-p

a small c++ / python binding library, developed by pybind11's creator as a more efficient alternative to pybind11.  is required by the latest release 0.7.0 of science:gemmi.

OBS-URL: https://build.opensuse.org/request/show/1248956
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-nanobind?expand=0&rev=1
This commit is contained in:
2025-03-03 10:29:23 +00:00
committed by Git OBS Bridge
commit 261ee336c9
6 changed files with 245 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -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

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

3
nanobind-2.5.0.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:acb2e1997c44f2c79f510c66e7ff9f4cac0502e9fe275ebc7af7571e869f8df0
size 900479

View File

@@ -0,0 +1,35 @@
originally 0001-Hardcode-path-to-nanobind-installation.patch:
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Sat, 6 Apr 2024 01:20:15 +0200
Subject: Hardcode path to nanobind installation
added patching source_dir(), for reasons of orthogonality, though
source_dir() is currently unused in nanobind module's python code
---
src/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/__init__.py b/src/__init__.py
index 76539c3..fe16ec9 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -6,15 +6,15 @@
def source_dir() -> str:
"Return the path to the nanobind source directory."
- return os.path.join(os.path.abspath(os.path.dirname(__file__)), "src")
+ return "/usr/share/nanobind/src"
def include_dir() -> str:
"Return the path to the nanobind include directory"
- return os.path.join(os.path.abspath(os.path.dirname(__file__)), "include")
+ return "/usr/share/nanobind/include"
def cmake_dir() -> str:
"Return the path to the nanobind CMake module directory."
- return os.path.join(os.path.abspath(os.path.dirname(__file__)), "cmake")
+ return "/usr/share/nanobind/cmake"
__version__ = "2.5.0"

35
python-nanobind.changes Normal file
View File

@@ -0,0 +1,35 @@
-------------------------------------------------------------------
Sun Feb 9 08:31:26 UTC 2025 - Friedrich Haubensak <hsk17@mail.de>
- update to release 2.5.0
- adapt nanobind-installationpath.patch to fit 2.5.0
-------------------------------------------------------------------
Wed Dec 11 17:36:05 UTC 2024 - Friedrich Haubensak <hsk17@mail.de>
- update to release 2.4.0
- adapt nanobind-installationpath.patch to fit 2.4.0
-------------------------------------------------------------------
Sat Dec 7 16:26:33 UTC 2024 - Friedrich Haubensak <hsk17@mail.de>
- add python-devel to Recommends:
-------------------------------------------------------------------
Fri Oct 4 19:14:21 UTC 2024 - Friedrich Haubensak <hsk17@mail.de>
- update to release 2.2.0
- adapt nanobind-installationpath.patch to fit 2.2.0
-------------------------------------------------------------------
Mon Aug 12 16:13:51 UTC 2024 - Friedrich Haubensak <hsk17@mail.de>
- update to release 2.1.0
- adapt nanobind-installationpath.patch to fit 2.1.0
-------------------------------------------------------------------
Thu Jun 20 13:35:09 UTC 2024 - Friedrich Haubensak <hsk17@mail.de>
- initial submit at release 2.0.0
- nanobind-installationpath.patch: hardcode path to nanobind
installation (from debian)

148
python-nanobind.spec Normal file
View File

@@ -0,0 +1,148 @@
#
# spec file for package python-nanobind
#
# 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/
#
%{?sle15_python_module_pythons}
Name: python-nanobind
Version: 2.5.0
Release: 0
Summary: Tiny And Efficient C++/Python Bindings
License: BSD-3-Clause
URL: https://github.com/wjakob/nanobind
Source: https://github.com/wjakob/nanobind/archive/refs/tags/v%{version}.tar.gz#/nanobind-%{version}.tar.gz
# PATCH-FEATURE-OPENSUSE nanobind-installationpath.patch
Patch1: nanobind-installationpath.patch
BuildRequires: cmake
BuildRequires: %{python_module base}
BuildRequires: python-rpm-macros
BuildArch: noarch
## req'd for tests
%if 0%{?sle_version} >= 150500 && 0%{?is_opensuse}
BuildRequires: gcc10-c++
%else
BuildRequires: gcc-c++
%endif
BuildRequires: eigen3-devel
BuildRequires: robin-map-devel >= 1.3.0, robin-map-devel < 2.0.0
BuildRequires: %{python_module devel}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module typing_extensions if %python-base < 3.11}
BuildRequires: %{python_module pytest}
%if "%{python_flavor}" == "python310"
Requires: python310-typing_extensions
%endif
%python_subpackages
%description
nanobind is a small binding library that exposes C++ types in Python
and vice versa. It is reminiscent of Boost.Python and pybind11 and
uses near-identical syntax. In contrast to these existing tools,
nanobind is more efficient: bindings compile in a shorter amount of
time, produce smaller binaries, and have better runtime performance.
This package contains the Python module.
%package -n nanobind-common-devel
Summary: Tiny And Efficient C++/Python Bindings
%description -n nanobind-common-devel
nanobind is a small binding library that exposes C++ types in Python
and vice versa. It is reminiscent of Boost.Python and pybind11 and
uses near-identical syntax. In contrast to these existing tools,
nanobind is more efficient: bindings compile in a shorter amount of
time, produce smaller binaries, and have better runtime performance.
This package contains files for developing applications using nanobind.
%package devel
Summary: Tiny And Efficient C++/Python Bindings
%if 0%{?sle_version} >= 150500 && 0%{?is_opensuse}
Requires: gcc10-c++
%else
Requires: gcc-c++
%endif
Requires: nanobind-common-devel = %{version}
Requires: python-devel
Requires: python-nanobind = %{version}
Requires: robin-map-devel >= 1.3.0, robin-map-devel < 2.0.0
%description devel
nanobind is a small binding library that exposes C++ types in Python
and vice versa. It is reminiscent of Boost.Python and pybind11 and
uses near-identical syntax. In contrast to these existing tools,
nanobind is more efficient: bindings compile in a shorter amount of
time, produce smaller binaries, and have better runtime performance.
This package contains files for developing applications using nanobind.
%prep
%autosetup -p1 -n nanobind-%{version}
sed -e '1s/^#!.*/#/' -i src/stubgen.py
%build
%{python_expand #
mkdir -p ../build_$python
cp -pr . ../build_$python
pushd ../build_$python
%cmake \
-DNB_INSTALL_DATADIR="%{_datadir}/nanobind" \
-DNB_USE_SUBMODULE_DEPS=OFF \
-DNB_TEST_SHARED_BUILD=ON \
-DNB_TEST_STABLE_ABI=ON \
%if 0%{?sle_version} >= 150500 && 0%{?is_opensuse}
-DCMAKE_CXX_COMPILER=g++-10 \
%endif
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \
-DPython_EXECUTABLE=%{_bindir}/$python
%cmake_build CXX_INCLUDES="-I%{_includedir}/$python -I%{_builddir}/%{buildsubdir}/include -I%{_includedir}/eigen3"
popd
}
%install
%{python_expand #
pushd ../build_$python
%cmake_install
popd
mkdir -p %{buildroot}%{$python_sitelib}/nanobind
mv %{buildroot}%{_datadir}/nanobind/__*.py %{buildroot}%{$python_sitelib}/nanobind
cp %{buildroot}%{_datadir}/nanobind/stubgen.py %{buildroot}%{$python_sitelib}/nanobind
}
%check
%{python_expand #
pushd ../build_$python
cd build
$python -m pytest
popd
}
%files %{python_files}
%license LICENSE
%{python_sitelib}/nanobind
%files -n nanobind-common-devel
%license LICENSE
%doc README.md
%{_datadir}/nanobind
%files %{python_files devel}
%license LICENSE
%changelog