git: 8ba5333df123 - main - misc/py-natten: New port: Neighborhood Attention Extension

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Sun, 21 Jul 2024 08:49:19 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8ba5333df123e9b774e77aafaced6a7f09fa20c0

commit 8ba5333df123e9b774e77aafaced6a7f09fa20c0
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-07-21 07:05:23 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-07-21 08:49:13 +0000

    misc/py-natten: New port: Neighborhood Attention Extension
---
 misc/Makefile            |  1 +
 misc/py-natten/Makefile  | 35 +++++++++++++++++++++++++++++++++++
 misc/py-natten/distinfo  |  3 +++
 misc/py-natten/pkg-descr |  2 ++
 4 files changed, 41 insertions(+)

diff --git a/misc/Makefile b/misc/Makefile
index 50c996620935..b926b4a3282d 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -454,6 +454,7 @@
     SUBDIR += py-mmsegmentation
     SUBDIR += py-molequeue
     SUBDIR += py-mxnet
+    SUBDIR += py-natten
     SUBDIR += py-npTDMS
     SUBDIR += py-numcodecs
     SUBDIR += py-onnx
diff --git a/misc/py-natten/Makefile b/misc/py-natten/Makefile
new file mode 100644
index 000000000000..7204fcc70488
--- /dev/null
+++ b/misc/py-natten/Makefile
@@ -0,0 +1,35 @@
+PORTNAME=	natten
+DISTVERSION=	0.17.1
+CATEGORIES=	misc python
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Neighborhood Attention Extension
+WWW=		https://shi-labs.com/natten/
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	cmake:devel/cmake-core \
+		pybind11>0:devel/pybind11 \
+		${PYTHON_PKGNAMEPREFIX}pytorch>=2.0.0:misc/py-pytorch@${PY_FLAVOR}
+LIB_DEPENDS=	libabsl_str_format_internal.so:devel/abseil \
+		libprotobuf.so:devel/protobuf
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pytorch>=2.0.0:misc/py-pytorch@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	distutils autoplist
+
+post-install:
+	# strip binary
+	@${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/natten/libnatten${PYTHON_EXT_SUFFIX}.so
+	# delete stray files, see https://github.com/SHI-Labs/NATTEN/issues/152
+	@${RM} -r \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/CMakeFiles \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/CMakeCache.txt \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/cmake_install.cmake \
+		${STAGEDIR}${PYTHON_SITELIBDIR}/Makefile
+
+.include <bsd.port.mk>
diff --git a/misc/py-natten/distinfo b/misc/py-natten/distinfo
new file mode 100644
index 000000000000..55316d7ac669
--- /dev/null
+++ b/misc/py-natten/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1721530370
+SHA256 (natten-0.17.1.tar.gz) = a2142722faa41fa3ae6d22e91ed527b2a6da5c4fe09a006f36d68edccaf9c643
+SIZE (natten-0.17.1.tar.gz) = 10848470
diff --git a/misc/py-natten/pkg-descr b/misc/py-natten/pkg-descr
new file mode 100644
index 000000000000..f23cf2ed757a
--- /dev/null
+++ b/misc/py-natten/pkg-descr
@@ -0,0 +1,2 @@
+NATTEN is an open-source project dedicated to providing fast implementations
+for Neighborhood Attention, a sliding window self-attention mechanism.