[pylucene-dev] building PyLucene in script; diffs between Python
2.5 and 2.4?
Andi Vajda
vajda at osafoundation.org
Mon Jun 16 19:46:12 PDT 2008
On Mon, 16 Jun 2008, Bill Janssen wrote:
> I'm trying to work out a single script for building PyLucene from a
> source tarball on a Linux distribution. I've got two distributions
> handy, Red Hat (Fedora, CentOS) and Ubuntu. The CentOS machine is
> running Python 2.4.3, apparently the latest release for CentOS, and
> the Ubuntu machine is running Python 2.5.2. Both have the latest
> setuptools installed. I'm using Sun Java 1.5.0 on each.
>
> My tcsh script looks like this ($javahome is the Java home, and
> $python is the Python interpreter):
>
> # we need to know whether to use 32-bit or 64-bit libraries
> set arch=`${python} -c "import platform; print platform.uname()[4]"`
> # we need to know whether Python supports the -m commandline flag
> set moduleflag=`${python} -c "import sys; print (sys.version_info >= (2, 5)) and '1' or '0'"`
>
> echo "javahome is $javahome, arch is $arch, moduleflag is $moduleflag"
>
> setenv JCC_ARGSEP ";"
> setenv JCC_INCLUDES "${javahome}/include;${javahome}/include/linux"
> if (($arch == "x86_64") || ($arch == "amd64")) then
> setenv JCC_LFLAGS "-L${javahome}/jre/lib/amd64;-ljava;-Wl,-rpath=${javahome}/jre/lib/amd64:${javahome}/jre/lib/amd64/server"
> else
> setenv JCC_LFLAGS "-L${javahome}/jre/lib/i386;-ljava;-Wl,-rpath=${javahome}/jre/lib/i386:${javahome}/jre/lib/i386/client"
> endif
> cd jcc
> ${python} setup.py install
> cd ..
> setenv JAVA_HOME "$javahome" # for ant
> if ($moduleflag == "1") then
> set JCCCOMMAND="${python} -m jcc --shared"
> else
> setenv PYTHONPATH ./jcc/build/lib.*/jcc
> set JCCCOMMAND="${python} ${PYTHONPATH}/__init__.py --shared"
> endif
> echo $JCCCOMMAND
> make PREFIX_PYTHON=/usr ANT=ant PYTHON=${python} JCC="${JCCCOMMAND}" NUM_FILES=1
> make PREFIX_PYTHON=/usr ANT=ant PYTHON=${python} JCC="${JCCCOMMAND}" NUM_FILES=1 install
> unsetenv PYTHONPATH
>
> My question is, why can't I use the same JCCCOMMAND on both Pythons?
> When I try to use the __init__.py form with Python 2.5, I get an
> unusable PyLucene install (the ImportError is that _lucene.so doesn't
> include the symbol "init_lucene").
I don't know the answer to your specific question but there are a couple of
things wrong or strange in what you're doing:
- The LFLAGS for linux should include -ljvm and -L<dir to libjvm.so>
I've seen that one some systems (at least Gentoo), failure to include
on the link line is going to cause it to fail startup because the
dynamic linker is not going to find the library.
The same applies for -R/-rpath, it should include the path to libjvm.so.
The latest JCC setup.py in trunk has that change [1].
- This "setenv PYTHONPATH ./jcc/build/lib.*/jcc" strikes me as doubly
suspicious:
. the use of * is probably not going to work as expected if there is
more than one match
. setting PYTHONPATH has some specific meaning to Python already, it
seems that you mean to use it differently here; yes, you are
unsetting it later, but what if that doesn't happen, for some buggy
reason ?
Andi..
[1] http://svn.osafoundation.org/pylucene/trunk/jcc/jcc/setup.py
More information about the pylucene-dev
mailing list