On Wed, 14 Oct 2009, Bill Janssen wrote:

Christian Heimes <li...@cheimes.de> wrote:

It makes no sense to offer binaries of an open source Python extension
except for Windows. Any other important operating system (Linux, Mac,
*BSD) has the necessary tools already on board or they can be easily
installed.

Well, building pylucene is pretty complicated.  Here's a script fragment
I use to build it on OS X.  $sitepackages is where to install it, and
$distdir is the prefix of that spot.  The Linux script is similarly
complicated by the difficulty of locating a JDK on Linux, and by the
lib/lib64 split.  The use of setuptools also means that you have to fool
the nagging condescending sanity checks in setuptools by setting things
like PYTHONPATH.

Hey, it looks like we have a budding configure script in the making here :)
Care to go all the way and contribute it ?

I see you're installing the Lucene jars some place. JCC normally copies them into the lucene egg it creates...

Still, I think that a setup.py based approach would have the benefit of telling us where Python is since it would be running already. All the logic to figure out Java location etc... can also be driven from Python, solving the other half of the problem. The same approach could be used for figuring out the Java stuff. Have a small class running in Java tell us.

On Linux, every distro has its own, incompatible, way of telling where java is. I just experienced this going from Gentoo to Fedora Core 11.

Andi..

-----------------------------------------------------------

# we need to know where java is, to build PyLucene
if ( -x /usr/libexec/java_home ) then
  set javahome=`/usr/libexec/java_home -v 1.5+`
else
  set javahome=/Library/Java/Home
endif
# 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'"`

setenv PYTHONPATH "${sitepackages}"

cd ../pylucene-*/jcc
${python} setup.py install --prefix=${distdir}
cd ..

setenv JAVA_HOME "$javahome"
set jccpath=./jcc/build/lib.*/jcc
setenv PYTHONPATH ${jccpath}:${PYTHONPATH}
set pythonhome=`dirname ${python}`
set pythonhome=`dirname ${pythonhome}`
if ( "${pyversion}" == "2.5" ) then
  set JCCCOMMAND="${python} -m jcc --shared"
else if ( "${pyversion}" == "2.3" ) then
  set JCCCOMMAND="${distdir}/lib/python${pyversion}/site-packages/jcc/__init__.py 
--shared"
else
  set JCCCOMMAND="${python} -m jcc.__main__ --shared"
endif
make PREFIX_PYTHON=${pythonhome} ANT=ant PYTHON=${python} JCC="${JCCCOMMAND}" 
NUM_FILES=1
make PREFIX_PYTHON=${pythonhome} ANT=ant PYTHON=${python} JCC="${JCCCOMMAND}" NUM_FILES=1 
install INSTALL_OPT="--prefix '${distdir}'"
unsetenv PYTHONPATH
install -m 444 build/lucene/lucene-core-*.jar ${distdir}/lib
set lucenejar=${distdir}/lib/lucene-core-*.jar

Reply via email to