On Fri, 26 Feb 2010, Bill Janssen wrote:

I've been looking over the various code in my build scripts to cope with
JCC variations necessary to build PyLucene, and I wonder if some of it
might not be better pushed back into the JCC package itself.  I've attached
the portion of my Linux build script to show you what I mean.

This seems to me both brittle and bizarre (yes, it's a csh script).
Couldn't some of this be put into JCC, and some into a configure script
for PyLucene?  A good chunk is coping with setuptools, which might be
pushed into the setup.py file for JCC.  And adding a wrapper tool, say
called "jcc", for use in the PyLucene Makefile, might also be a good
thing; it could know where Java is, make sure the target install
directory is on the PYTHONPATH, for instance, and handle the difference
in jcc invocations.

Some of what your script is doing seems to be taken care of already by jcc's setup.py. If you set the JCC_JDK env var to where you think the JDK is installed, then the other settings like INCLUDES, CFLAGS, LFLAGS, etc... are derived from it.

Andi..


And I haven't even looked at 3.x yet...

Bill


   # figure out site-packages location.  We need to know this because
   # we need to use setuptools if we are going to support the
   # "--shared" option in JCC, which we need, and setuptools is broken
   # in that it thinks we are children playing with matches and won't
   # install into directories that aren't on our sys.path *already*,
   # even if we're not currently using things from that directory.  So
   # we need to figure out where setuptools will put this, so that we
   # can use "--shared" with JCC.

   # Most unices use site-packages, but one of them uses dist-packages
   set sitedir=`${python} -c "import sys; print [x for x in sys.path if 
(x.endswith('/site-packages') or x.endswith('/dist-packages'))][0]"`
   set py_major=`${python} -c "import sys; print sys.version_info[0]"`
   set py_minor=`${python} -c "import sys; print sys.version_info[1]"`
   # 64-bit libraries go into lib64, not lib
   set arch=`${python} -c "import platform; print platform.uname()[4]"`
   if (($arch == "x86_64") || ($arch == "amd64")) then
      set libdir="lib64"
   else
      set libdir="lib"
   endif
   # let's hope setuptools figures it the same way!
   set sitespot=${distdir}/${libdir}/python${py_major}.${py_minor}/site-packages
   if (! -d ${sitespot}) then
      mkdir -p ${sitespot}
   endif

   # finally make setuptools happy by making sure this is on our PYTHONPATH
   setenv PYTHONPATH ${sitespot}

   # now, we need to make sure we have the properly patched version of
   # setuptools.  So just re-install setuptools after adding the patch.
   cd ../setuptools-*
   if ( -e ../pylucene-*/jcc/jcc/patches/patch.43.0.6c7 ) then
      patch -Nup0 < ../pylucene-*/jcc/jcc/patches/patch.43.0.6c7
   else if ( -e ../pylucene-*/jcc/jcc/patches/patch.43 ) then
      patch -Nup0 < ../pylucene-*/jcc/jcc/patches/patch.43
   endif
   python setup.py build
   python setup.py install --prefix=${distdir}

   # we need to know where java is, to build PyLucene.  There's no good
   # way to know this, on Linux, so UpLib added a script that looks in all the
   # usual places, and works about 70% of the time.
   set javahome=`${python} ../uplib-*/unix/linux/figure-linux-java.py`
   echo "JAVA_HOME is ${javahome}"
   # We need to know whether Python supports the -m commandline flag.
   # There are (of course) three different flavors:  -m jcc.__main__, -m jcc, 
and something old.
   set moduleflag=`${python} -c "import sys; print ((sys.version_info >= (2, 6)) and 
'2') or ((sys.version_info >= (2, 5)) and '1') or '0'"`

   cd ../pylucene-*/jcc

   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;-L${javahome}/jre/lib/amd64/server;-ljvm;-Wl,-rpath=${javahome}/jre/lib/amd64:${javahome}/jre/lib/amd64/server"
   else
      setenv JCC_LFLAGS 
"-L${javahome}/jre/lib/i386;-ljava;-L${javahome}/jre/lib/i386/client;-ljvm;-Wl,-rpath=${javahome}/jre/lib/i386:${javahome}/jre/lib/i386/client"
   endif
   setenv PYTHONPATH ${sitespot}
   ${python} setup.py install --prefix=${distdir}
   cd ..
   setenv JAVA_HOME "$javahome"
   if ($moduleflag == "2") then
      set JCCCOMMAND="${python} -m jcc.__main__ --shared"
   else if ($moduleflag == "1") then
      set JCCCOMMAND="${python} -m jcc --shared"
   else
      set jccpath=./jcc/build/lib.*/jcc
      setenv PYTHONPATH ${PYTHONPATH}:${jccpath}
      set JCCCOMMAND="${python} ${jccpath}/__init__.py --shared"
   endif
   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 INSTALL_OPT="--prefix '${distdir}'"
   set lucenejar=`pwd`/build/lucene/lucene-core-*jar
   echo "lucenejar is $lucenejar"
   setenv PYTHONPATH ${sitespot}

Reply via email to