aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2024-05-04 00:16:24 +0000
committerYuri Victorovich <yuri@FreeBSD.org>2024-05-04 02:06:56 +0000
commitaf42bbacc245be293a76409adef3843d50aef9f0 (patch)
tree12f25ac6381aa669a57f99ac3b1b0d2c36052abd
parentb78025a96ed97269429207daeadace2849f2c5c2 (diff)
downloadports-af42bbacc245be293a76409adef3843d50aef9f0.tar.gz
ports-af42bbacc245be293a76409adef3843d50aef9f0.zip
audio/py-samplerate: New port: Python wrapper for libsamplerate based on pybind11 and NumPy
-rw-r--r--audio/Makefile1
-rw-r--r--audio/py-samplerate/Makefile33
-rw-r--r--audio/py-samplerate/distinfo3
-rw-r--r--audio/py-samplerate/files/patch-CMakeLists.txt33
-rw-r--r--audio/py-samplerate/pkg-descr2
5 files changed, 72 insertions, 0 deletions
diff --git a/audio/Makefile b/audio/Makefile
index 6cb0b167e054..9fa1446c7df8 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -659,6 +659,7 @@
SUBDIR += py-python-mpd2
SUBDIR += py-pyttsx3
SUBDIR += py-resampy
+ SUBDIR += py-samplerate
SUBDIR += py-simpleaudio
SUBDIR += py-soundcloud
SUBDIR += py-sounddevice
diff --git a/audio/py-samplerate/Makefile b/audio/py-samplerate/Makefile
new file mode 100644
index 000000000000..010017d57e9e
--- /dev/null
+++ b/audio/py-samplerate/Makefile
@@ -0,0 +1,33 @@
+PORTNAME= samplerate
+DISTVERSION= 0.2.1
+CATEGORIES= audio
+MASTER_SITES= PYPI
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER= yuri@FreeBSD.org
+COMMENT= Python wrapper for libsamplerate based on pybind11 and NumPy
+WWW= https://github.com/tuxu/python-samplerate
+
+LICENSE= MIT
+LICENSE_FILE= ${WRKSRC}/LICENSE.rst
+
+BUILD_DEPENDS= ${PY_SETUPTOOLS} \
+ ${PYTHON_PKGNAMEPREFIX}setuptools-scm>=6.2:devel/py-setuptools-scm@${PY_FLAVOR} \
+ pybind11>0:devel/pybind11 \
+ cmake:devel/cmake-core
+LIB_DEPENDS= libsamplerate.so:audio/libsamplerate
+RUN_DEPENDS= ${PYNUMPY}
+
+USES= cmake compiler:c++14-lang pkgconfig python
+USE_PYTHON= flavors pytest
+
+TEST_WRKSRC= ${WRKSRC}/tests
+TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
+PLIST_FILES= ${PYTHON_SITELIBDIR}/samplerate${PYTHON_EXT_SUFFIX}.so
+
+do-install:
+ ${MKDIR} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+ ${INSTALL_LIB} ${BUILD_WRKSRC}/samplerate${PYTHON_EXT_SUFFIX}.so ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
+.include <bsd.port.mk>
diff --git a/audio/py-samplerate/distinfo b/audio/py-samplerate/distinfo
new file mode 100644
index 000000000000..a0725985f378
--- /dev/null
+++ b/audio/py-samplerate/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1714760637
+SHA256 (samplerate-0.2.1.tar.gz) = 464d3574412024184fb7428ecbaa1b2e207bddf5fbc10a5d9ddc3fc1c7b7ab1e
+SIZE (samplerate-0.2.1.tar.gz) = 21494
diff --git a/audio/py-samplerate/files/patch-CMakeLists.txt b/audio/py-samplerate/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..7f822e90d3d4
--- /dev/null
+++ b/audio/py-samplerate/files/patch-CMakeLists.txt
@@ -0,0 +1,33 @@
+--- CMakeLists.txt.orig 2024-01-23 23:51:19 UTC
++++ CMakeLists.txt
+@@ -11,7 +11,9 @@ cmake_policy(SET CMP0094 NEW)
+ cmake_policy(SET CMP0094 NEW)
+
+ # adds the external dependencies
+-add_subdirectory(external)
++find_package(PkgConfig REQUIRED)
++find_package(pybind11 CONFIG REQUIRED)
++pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET samplerate)
+
+ pybind11_add_module(python-samplerate src/samplerate.cpp)
+
+@@ -25,7 +27,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
+ CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+ (CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32))
+- target_compile_options(python-samplerate PRIVATE -std=c++14 -O3 -Wall -Wextra)
++ target_compile_options(python-samplerate PRIVATE -std=c++14 -Wall -Wextra)
+ endif()
+
+ ### stick the package and libsamplerate version into the module
+@@ -43,4 +45,9 @@ set_target_properties(
+ LINKER_LANGUAGE C
+ )
+
+-target_link_libraries(python-samplerate PUBLIC samplerate)
++target_compile_options(python-samplerate PRIVATE
++ ${SAMPLERATE_CFLAGS}
++)
++target_link_options(python-samplerate PRIVATE
++ ${SAMPLERATE_LDFLAGS}
++)
diff --git a/audio/py-samplerate/pkg-descr b/audio/py-samplerate/pkg-descr
new file mode 100644
index 000000000000..7e3b3f7188be
--- /dev/null
+++ b/audio/py-samplerate/pkg-descr
@@ -0,0 +1,2 @@
+samplerate is a wrapper around Erik de Castro Lopo's libsamplerate (aka Secret
+Rabbit Code) for high-quality sample rate conversion.