Name py3-pybind11
Description Seamless operability between C++11 and Python
Version 2.13.6-r0
Package Base py3-pybind11
Homepage https://github.com/pybind/pybind11
Maintainers ['Carlo Landmeter <clandmeter@alpinelinux.org>']
Contributors []
Distro-repo https://gitlab.alpinelinux.org/alpine/aports/-/tree/3.22-stable/community/py3-pybind11
Sources ['$pkgname-2.13.6-r0.tar.gz::https://github.com/pybind/pybind11/archive/v2.13.6-r0.tar.gz']
Dependencies ['python3~3.12']
Optional-Dependencies []
Build-Dependencies ['boost-dev', 'cmake', 'py3-gpep517', 'py3-setuptools', 'py3-wheel', 'python3-dev', 'samurai']
Provides ['py-pybind11=2.13.6-r0', 'py3.12:pybind11=2.13.6-r0']
Builddate 03-01-2025 23:49:17
Architecture x86_64
Distro-Version v3.22
Licenses ['MPL-2.0']
Hash Q1kyq347ujUJ/Fr9+phKfeyNePTMg=
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=py3-pybind11
_pkgname=pybind11
pkgver=2.13.6
pkgrel=0
pkgdesc="Seamless operability between C++11 and Python"
url="https://github.com/pybind/pybind11"
arch="noarch"
license="MPL-2.0"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="
	boost-dev
	cmake
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	samurai
	"
checkdepends="
	catch2
	py3-pytest
	"
subpackages="$pkgname-dev $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/pybind/pybind11/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-pybind11" # Backwards compatibility
provides="py-pybind11=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	# fails with lto due to fortify-headers
	export CXXFLAGS="$CXXFLAGS -U_FORTIFY_SOURCE"

	python3 setup.py build

	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DPYTHON_EXECUTABLE=/usr/bin/python3 \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_PYTHON_INCLUDE_DIR=FALSE \
		-DPYBIND11_TEST="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build

	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	# No integrated ctest for running tests yet, use cmake targets
	# https://github.com/pybind/pybind11/issues/5095
	cmake --build build --target pytest
	cmake --build build --target cpptest
	cmake --build build --target test_cmake_build
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
497c25b33b09a9c42f67131ab82e35d689e8ce089dd7639be997305ff9a6d502447b79c824508c455d559e61f0186335b54dd2771d903a7c1621833930622d1a  py3-pybind11-2.13.6.tar.gz
"