[Xapian-discuss] Problem with bindings and MinGW

Francesco Garosi franzg at users.sourceforge.net
Fri Mar 25 18:50:27 GMT 2005


Message body follows:

Hi,

I'm interested in Xapian as a possible search engine for a 
Python project I'm developing. The reason why I write to you, 
is that I saw that you've been fixing bugs... so please excuse 
me if I'm bothering you: I saw no other contact on the 
xapian.org web pages.

I've been spending the last two days trying to set up Python 
bindings for the library on Win32 with MinGW/MSYS. I know, 
it's probably not your main platform, but someone might need 
it as I do, for whatever reason. The reason why it fails, I think, 
is that Xapian::Remote::open is probably not supported on 
Win32.

When I realized it, I finally managed to exclude from the 
(provided) SWIG-generated xapian_wrap.cc the unsupported 
lines, and to "gently" raise an exception when remote_open() 
is called. Here is the patch for 
python/modern/xapian_wrap.cc:

--- xapian_wrap.cc_ORIG	Fri Mar 25 16:42:49 2005
+++ xapian_wrap.cc	Fri Mar 25 17:53:18 2005
@@ -15350 +15350,2 @@
-
+// remote_open should be removed to wrap in 
Win32/MinGW32
+#ifndef NO_REMOTE_OPEN
@@ -15597,0 +15599,6 @@
+#else
+static PyObject *_wrap_remote_open(PyObject *self, 
PyObject *args) {
+    PyErr_SetString(PyExc_NotImplementedError,"No 
matching function for 'remote_open'");
+    return NULL;
+}
+#endif // NO_REMOTE_OPEN

(I hope, the web mail program will not break too many lines). 
This patch works in conjunction with a Python distutils 
styled "setup.py" script, that follows:

#!/usr/bin/env python
# setup file for xapian

import os, sys
from distutils.core import setup, Extension

XAPIAN_BASE = ""
try:
    XAPIAN_BASE = os.environ['XAPIAN_BASE']
except KeyError:
    print "warning: XAPIAN_BASE not set, use xapian-config 
to determine it"

# please do not change the lines below
EXTRA_LDFLAGS = (
    "-v -Wl,--enable-runtime-pseudo-reloc "
    "-L%(xapianbase)s/lib -lstdc++ "
    "-lxapianqueryparser -lxapian "
    % {'xapianbase': XAPIAN_BASE}).split()
EXTRA_CFLAGS = (
    "-I%(xapianbase)s/include "
    % {'xapianbase': XAPIAN_BASE}).split()

DATA_FILES = []
if sys.platform == "win32":
    df = (
        "%(xapianbase)s/bin/libxapianqueryparser-5.dll "
        "%(xapianbase)s/bin/libxapian-5.dll "
        % {'xapianbase': XAPIAN_BASE}).split()
    DATA_FILES = [('.', df)]
    EXTRA_CFLAGS.append("-DNO_REMOTE_OPEN")

setup(name="Xapian",
      version="0.8.5",
      description="Xapian bindings for Python",
      author="The Xapian Team",
      author_email="xapian at users.sourceforge.net",
      url="http://xapian.org/",
      py_modules=["xapian"],
      data_files=DATA_FILES,
      ext_modules=[
          Extension("_xapian",
                    ["xapian_wrap.cc"],
                    extra_compile_args=EXTRA_CFLAGS,
                    extra_link_args=EXTRA_LDFLAGS,
                    )]
      )

# end.

...if a user wants to build it using the standard Python build 
system, he just has to patch the .cc file, copy this script in 
the python/modern directory, set the XAPIAN_BASE 
directory to where Xapian is installed and launch "python 
setup.py build -c mingw32 install" from a command line 
there. Still don't know how to make it work on other 
platforms - the provided build system should work perfectly.

I hope this will help someone if you disclose it...

Thank you for releasing the library as open source,

F.

>>@
Risposte/Replies :
Francesco Garosi
  Office: <f.garosi at usl7.toscana.it> (++39/0577/586937)
  Home: <franz.g at infinito.it> (++39/0577/47806)

--
This message has been sent to you, a registered SourceForge.net user,
by another site user, through the SourceForge.net site.  This message
has been delivered to your SourceForge.net mail alias.  You may reply
to this message using the "Reply" feature of your email client, or
using the messaging facility of SourceForge.net at:
https://sourceforge.net/sendmessage.php?touser=328337



More information about the Xapian-discuss mailing list