On Sun, Sep 12, 2021 at 02:41:26PM +0100, Stuart Henderson wrote:
> On 2021/09/12 14:41, Stuart Henderson wrote:
> > - please merge the ".if ${BUILD_PACKAGES:M-python}" blocks
> > 
> > - the BUILD_DEPENDS on lang/python is set automatically by the python module
> > and shouldn't be listed separately
> > 
> > - ${BUILD_PKGPATH}-main=${V} should be ${BUILD_PKGPATH},-main=${V}
> > (the , is missing), but a LIB_DEPENDS entry is only valid if there is a
> > WANTLIB referencing a library from the dependency, so either a WANTLIB
> > entry is missing or it should be a RUN_DEPENDS (i didn't build-test;
> > run "make port-lib-depends-check" and add the WANTLIB if it complains)
> > 
> > - post-install should not hardcode /usr/local. I think you should probably
> > use "${MODPY_BIN} setup.py ${MODPY_DISTUTILS_INSTALL}" here.
> > 
> > - pkg/PLIST-main requires "@pkgpath textproc/libmarisa" otherwise the new
> > subpackage won't be considered by pkg_add as an update for the old
> > "non-subpackaged" version
> > 
> 
> ..also it needs "REVISION-main=0"

Thanks for checking this.

- Merged ".if ${BUILD_PACKAGES:M-python}" blocks into one.

- Removed "lang/python/${MODPY_VERSION}" from BUILD_DEPENDS.

- Added "," (= "${BUILD_PKGPATH},-main=${V}").
  Also added "m marisa" to WANTLIB-python after checking with
  "make port-lib-depends-check". I should run this before posting, sorry.

- ${MODPY_DISTUTILS_INSTALL} works great as I intended!

- Added "@pkgpath textproc/libmarisa" to pkg/PLIST-main.
  I had no idea about this. Thanks for telling me this.

- Added "REVISION-main=0".
  I didn't add REVISION-main with my last diff since I thought 'libmarisa-main'
  would be the first revision but it was wrong.

I had built and install this on amd64 and tested with
"bindings/python/sample.py", it ran with no error.

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 14:18:54 -0000
@@ -1,9 +1,13 @@
 # $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}
+
+REVISION-main =                0
 
 GH_ACCOUNT =   s-yata
 GH_PROJECT =   marisa-trie
@@ -18,7 +22,21 @@ 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
+MODULES +=             lang/python
+LIB_DEPENDS-python =   ${BUILD_PKGPATH},-main=${V} ${MODPY_LIB_DEPENDS}
+WANTLIB-python =       ${COMPILER_LIBCXX} ${MODPY_WANTLIB} m marisa
+.endif
 
 AUTOCONF_VERSION =     2.69
 AUTOMAKE_VERSION =     1.15
@@ -27,6 +45,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 ${MODPY_DISTUTILS_INSTALL}
 .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 14:18:54 -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 14:18:54 -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 14:18:54 -0000
@@ -0,0 +1,26 @@
+@comment $OpenBSD: PLIST-main,v$
+@pkgpath textproc/libmarisa
+@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 14:18:54 -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