lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andi Vajda <va...@apache.org>
Subject Re: JCC Install
Date Sun, 22 Feb 2009 22:28:31 GMT

On Fri, 20 Feb 2009, Jacob Floyd wrote:

> Here I am again.
> After talking with some of the gentoo devs, they suggested I modify
> the setup.py to include gentoo specifics and send it upstream. As it
> is, they don't like to have to specify all the lflags, and in fact it
> becomes troublesome, because we'd then have to duplicate what you're
> doing (sniffing for x86/x86_x86_64...) within the ebuild. Instead, it
> would be nicer to have something like a JCC_JAVA_DIR, that specifies
> where the java install is, and then use that within Includes and
> lflags. In my case I would then set not the JCC_LFLAGS variable but
> the JCC_JAVA_DIR, and the setup.py would automatically give me either
> i386/i686/x86_64.
>
> I don't know if you prefer a copy or a patch, and I don't know if I
> can attach things going to the list, so here's the setup.py and the
> diff (available for the next 30 days):
> setup.py http://dpaste.com/123231/
> setup.py.diff http://dpaste.com/123234/
> Note that I moved some of the variables up or down, to keep it simple
> for users to change just what they need.
>
> What do you think?

Thank you for the patch.
This is the second time in a week that someone suggest the same thing: a 
variable to specify the JDK root (JAVA_HOME or somesuch).
I'll take the ideas from both patches and incorporate that into JCC's 
setup.py.

I've since remembered why I haven't noticed the need for this myself before.
Getting annoyed with having to modify setup.py myself and needing a way to 
build JCC that didn't involve editing the file, I added a long time ago the 
possibility to set all these flags via environment variables (as you 
noticed). I then do the right thing, once, in the Makefile driving my build 
and all is good.

This is, for example, what I've done, on Gentoo 64-bit no less, at my day 
job (see snippets of a Makefile below) where I had to support various 
versions of Python (2.4, 2.5 and 2.6) and various versions of Java (1.5 and 
1.6). Note that Gentoo has a very handy utility, called java-config, that 
makes it easy to do a bunch of things with your java installation(s), such 
as knowing where they are and making one the default.

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

ifeq ($(OS),Linux)
PYTHON_VER:=$(shell $(PYTHON) -c "import sys; print '%s.%s' %(sys.version_info[0:2])")
JCC_EGG:=JCC-$(JCC_VER)-py$(PYTHON_VER)-linux-$(ARCH).egg
ifeq ($(ARCH),x86_64)
ARCH=amd64
endif
JDK:=$(shell java-config -O)
JCC_ENV=\
   PYTHONPATH=$(PACKAGES) \
   INSTALL_OPT="--install-dir $(PACKAGES)" \
   JCC_INCLUDES="$(JDK)/include:$(JDK)/include/linux" \
   JCC_LFLAGS="-L$(JDK)/jre/lib/$(ARCH):-ljava:-lverify:-L$(JDK)/jre/lib/$(ARCH)/server:-ljvm:-Wl,-rpath=$(JDK)/jre/lib/$(ARCH):-Wl,-rpath=$(JDK)/jre/lib/$(ARCH)/server"
PYLUCENE_ENV=\
   PYTHONPATH=$(PACKAGES) \
   ANT=ant \
   INSTALL_OPT="--install-dir $(PACKAGES)" \
   LUCENE=$(LUCENE_DIR) \
   PYTHON=$(PYTHON) \
   JCC="$(PYTHON) $(PACKAGES)/$(JCC_EGG)/jcc/__init__.py --shared" \
   NUM_FILES=2
endif

jcc.egg: setuptools.egg $(JCC_DIR)
 	mkdir -p $(PACKAGES)
 	cd $(JCC_DIR); $(JCC_ENV) \
             $(PYTHON) setup.py build $(DBG_FLAGS) \
                                install --install-lib $(PACKAGES)
 	touch $@

lucene.egg: $(LUCENE_DIR) $(PYLUCENE_DIR)
 	cd $(PYLUCENE_DIR); $(PYLUCENE_ENV) make -e compile install
 	touch $@

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

Note that jcc.egg and lucene.egg are pseudo files I use to let make know 
where it needs to build jcc and/or PyLucene.

Maybe a similar environment variable technique should be used for the Gentoo 
ebuild. It would solve the problem of having to modify setup.py.
Still, like I said earlier, having a JCC_JDK variable (or somesuch) to root 
all java-based flags on in setup.py would make it simpler to build JCC in 
the manual case.

The same technique works on the PyLucene build. I believe I implemented this 
environment variable based build first at OSAF for the Chandler build, 
actually :)

Andi..

Mime
View raw message