On Sun, Sep 12, 2021 at 11:57:11AM +0900, SASANO Takayoshi wrote:
> Hi,
> 
> marisa-0.2.6 trie library is now imported to textproc/libmarisa,
> so here is the Python(3) binding will be settled at textproc/py-marisa.
> 
> this is needed to build libkkc.
> 
> 
> thanks to inoguchi@ that telling me about libmarisa is already posted.
> 
> -- 
> SASANO Takayoshi (JG1UAA) <u...@mx5.nisiq.net>
> 


> 

Hello,

This is just my thoughts, but this could be a subpackage of libmarisa since
it uses the same dist file, and libxml does the same kind of thing.

Use MULTI_PACKAGES.
Rename DESCR and PLIST to DESCR-main and PLIST-main.
Add DESCR-python and PLIST-python.
This diff adds python bindings only, and I think we can add perl and ruby
bindings too.

Index: textproc/libmarisa/Makefile
===================================================================
RCS file: /cvs/ports/textproc/libmarisa/Makefile,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 Makefile
--- textproc/libmarisa/Makefile 11 Sep 2021 07:55:18 -0000      1.1
+++ textproc/libmarisa/Makefile 12 Sep 2021 12:57:36 -0000
@@ -1,9 +1,11 @@
 # $OpenBSD: Makefile,v 1.1 2021/09/11 07:55:18 inoguchi Exp $
 
-COMMENT =      C++ library for MARISA matching algorithm
+COMMENT-main =         C++ library for MARISA matching algorithm
+COMMENT-python =       marisa-trie bindings for Python (SWIG)
 
-V =            0.2.6
-PKGNAME =      libmarisa-${V}
+V =                    0.2.6
+PKGNAME-main =         libmarisa-${V}
+PKGNAME-python =       libmarisa-python-${V}
 
 GH_ACCOUNT =   s-yata
 GH_PROJECT =   marisa-trie
@@ -18,7 +20,25 @@ MAINTAINER = Yifei Zhan <open...@zhan.sc
 # dual license: either BSD 2-clause or LGPLv2.1+
 PERMIT_PACKAGE =       Yes
 
-WANTLIB += ${COMPILER_LIBCXX} c m
+PSEUDO_FLAVORS =       no_python
+FLAVOR? =
+
+MULTI_PACKAGES =       -main -python
+
+WANTLIB-main += ${COMPILER_LIBCXX} c m
+
+.include <bsd.port.arch.mk>
+
+.if ${BUILD_PACKAGES:M-python}
+BUILD_DEPENDS =                devel/swig
+.endif
+
+.if ${BUILD_PACKAGES:M-python}
+MODULES +=             lang/python
+BUILD_DEPENDS +=       lang/python/${MODPY_VERSION}
+LIB_DEPENDS-python =   ${BUILD_PKGPATH}-main=${V} ${MODPY_LIB_DEPENDS}
+WANTLIB-python =       ${COMPILER_LIBCXX} ${MODPY_WANTLIB}
+.endif
 
 AUTOCONF_VERSION =     2.69
 AUTOMAKE_VERSION =     1.15
@@ -27,6 +47,21 @@ CONFIGURE_ARGS =     CXX="${CXX}" CXXFLAGS="
 
 .if ${MACHINE_ARCH} == "amd64"
 CONFIGURE_ARGS +=      --enable-sse2
+.endif
+
+post-build:
+.if ${BUILD_PACKAGES:M-python}
+       cd ${WRKDIST}/bindings && make swig-python
+       cd ${WRKDIST}/bindings/python && \
+           ${MODPY_BIN} setup.py build_ext \
+           --include-dirs=${WRKSRC}/include/ \
+           --library-dirs=${WRKSRC}/lib/marisa/.libs
+.endif
+
+post-install:
+.if ${BUILD_PACKAGES:M-python}
+       cd ${WRKDIST}/bindings/python && \
+           ${MODPY_BIN} setup.py install --prefix=${WRKINST}/usr/local
 .endif
 
 .include <bsd.port.mk>
Index: textproc/libmarisa/pkg/DESCR
===================================================================
RCS file: textproc/libmarisa/pkg/DESCR
diff -N textproc/libmarisa/pkg/DESCR
--- textproc/libmarisa/pkg/DESCR        11 Sep 2021 07:55:18 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
-Matching Algorithm with Recursively Implemented StorAge (MARISA)
-is a static and space-efficient trie data structure. And libmarisa
-is a C++ library to provide an implementation of MARISA. Also, the
-package of libmarisa contains a set of command line tools for
-building and operating a MARISA-based dictionary.
Index: textproc/libmarisa/pkg/DESCR-main
===================================================================
RCS file: textproc/libmarisa/pkg/DESCR-main
diff -N textproc/libmarisa/pkg/DESCR-main
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ textproc/libmarisa/pkg/DESCR-main   12 Sep 2021 12:57:36 -0000
@@ -0,0 +1,5 @@
+Matching Algorithm with Recursively Implemented StorAge (MARISA)
+is a static and space-efficient trie data structure. And libmarisa
+is a C++ library to provide an implementation of MARISA. Also, the
+package of libmarisa contains a set of command line tools for
+building and operating a MARISA-based dictionary.
Index: textproc/libmarisa/pkg/DESCR-python
===================================================================
RCS file: textproc/libmarisa/pkg/DESCR-python
diff -N textproc/libmarisa/pkg/DESCR-python
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ textproc/libmarisa/pkg/DESCR-python 12 Sep 2021 12:57:36 -0000
@@ -0,0 +1 @@
+marisa-trie bindings for Python (SWIG)
Index: textproc/libmarisa/pkg/PLIST
===================================================================
RCS file: textproc/libmarisa/pkg/PLIST
diff -N textproc/libmarisa/pkg/PLIST
--- textproc/libmarisa/pkg/PLIST        11 Sep 2021 07:55:18 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-@comment $OpenBSD: PLIST,v 1.1 2021/09/11 07:55:18 inoguchi Exp $
-@bin bin/marisa-benchmark
-@bin bin/marisa-build
-@bin bin/marisa-common-prefix-search
-@bin bin/marisa-dump
-@bin bin/marisa-lookup
-@bin bin/marisa-predictive-search
-@bin bin/marisa-reverse-lookup
-include/marisa/
-include/marisa.h
-include/marisa/agent.h
-include/marisa/base.h
-include/marisa/exception.h
-include/marisa/iostream.h
-include/marisa/key.h
-include/marisa/keyset.h
-include/marisa/query.h
-include/marisa/scoped-array.h
-include/marisa/scoped-ptr.h
-include/marisa/stdio.h
-include/marisa/trie.h
-@static-lib lib/libmarisa.a
-lib/libmarisa.la
-@lib lib/libmarisa.so.${LIBmarisa_VERSION}
-lib/pkgconfig/marisa.pc
Index: textproc/libmarisa/pkg/PLIST-main
===================================================================
RCS file: textproc/libmarisa/pkg/PLIST-main
diff -N textproc/libmarisa/pkg/PLIST-main
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ textproc/libmarisa/pkg/PLIST-main   12 Sep 2021 12:57:36 -0000
@@ -0,0 +1,25 @@
+@comment $OpenBSD: PLIST-main,v$
+@bin bin/marisa-benchmark
+@bin bin/marisa-build
+@bin bin/marisa-common-prefix-search
+@bin bin/marisa-dump
+@bin bin/marisa-lookup
+@bin bin/marisa-predictive-search
+@bin bin/marisa-reverse-lookup
+include/marisa/
+include/marisa.h
+include/marisa/agent.h
+include/marisa/base.h
+include/marisa/exception.h
+include/marisa/iostream.h
+include/marisa/key.h
+include/marisa/keyset.h
+include/marisa/query.h
+include/marisa/scoped-array.h
+include/marisa/scoped-ptr.h
+include/marisa/stdio.h
+include/marisa/trie.h
+@static-lib lib/libmarisa.a
+lib/libmarisa.la
+@lib lib/libmarisa.so.${LIBmarisa_VERSION}
+lib/pkgconfig/marisa.pc
Index: textproc/libmarisa/pkg/PLIST-python
===================================================================
RCS file: textproc/libmarisa/pkg/PLIST-python
diff -N textproc/libmarisa/pkg/PLIST-python
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ textproc/libmarisa/pkg/PLIST-python 12 Sep 2021 12:57:36 -0000
@@ -0,0 +1,6 @@
+@comment $OpenBSD: PLIST-python,v$
+lib/python${MODPY_VERSION}/site-packages/${MODPY_PYCACHE}/
+lib/python${MODPY_VERSION}/site-packages/${MODPY_PYCACHE}marisa.${MODPY_PYC_MAGIC_TAG}pyc
+@so lib/python${MODPY_VERSION}/site-packages/_marisa.${MODPY_PYC_MAGIC_TAG}so
+lib/python${MODPY_VERSION}/site-packages/marisa-0.0.0-py${MODPY_VERSION}.egg-info
+lib/python${MODPY_VERSION}/site-packages/marisa.py

Reply via email to