Skip to content

Instantly share code, notes, and snippets.

@csarron
Last active March 27, 2021 02:51
Show Gist options
  • Save csarron/4a6180cd52fc1bfeb717545997b76b80 to your computer and use it in GitHub Desktop.
Save csarron/4a6180cd52fc1bfeb717545997b76b80 to your computer and use it in GitHub Desktop.
pylucence build and install on macOS and Ubuntu

install prebuilt eggs:

Ubuntu: may need to export libjvm.so ls -l /etc/alternatives/java will output something like: /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java then do: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/ export JCC_JDK=/usr/lib/jvm/java-8-openjdk-amd64

for macOS: easy_install JCC-3.2-py3.6-macosx-10.13-x86_64.egg lucene-7.5.0-py3.6-macosx-10.13-x86_64.egg for Ubuntu: easy_install JCC-3.2-py3.5-linux-x86_64.egg lucene-7.5.0-py3.5-linux-x86_64.egg for Jetson TX2: easy_install JCC-3.2-py3.5-linux-aarch64.egg lucene-7.5.0-py3.5-linux-aarch64.egg

built pylucene yourself:

download pylucene src: https://archive.apache.org/dist/lucene/pylucene/pylucene-7.5.0-src.tar.gz and unzip to pylucene-7.5.0

follow guides at: http://lucene.apache.org/pylucene/install.html

caveats:
pip install setuptools==38.7.0 for both macOS and ubuntu (cause: higher setuptools removed legacy api SetuptoolsVersion) for macOS: java6 (download at https://support.apple.com/kb/DL1572?locale=en_US) is required according to the official notes

need to run make first and then make bdist

build egg files for jcc and pylucence: cd pylucene-7.5.0/jcc/, python setup.py bdist_egg will generate jcc.egg (like dist/JCC-3.2-py3.6-macosx-10.13-x86_64.egg or dist/JCC-3.2-py3.5-linux-x86_64.egg) cd .., make bdist will generate pylucene.egg (like dist/lucene-7.4.0-py3.6-macosx-10.13-x86_64.egg or dist/lucene-7.5.0-py3.5-linux-x86_64.egg)

notes for TX2: jcc/setup.py:140 add 'linux/aarch64': ['-L%(linux)s/jre/lib/aarch64' %(JDK), '-ljava', '-L%(linux)s/jre/lib/aarch64/server' %(JDK), '-ljvm', '-Wl,-rpath=%(linux)s/jre/lib/aarch64:%(linux)s/jre/lib/aarch64/server' %(JDK)], to LFLAGS and use ANT=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-arm64/ /usr/bin/ant PYTHON=python JCC=$(PYTHON) -m jcc --shared NUM_FILES=8 in Makefile

for ant issue: cd pylucene-7.5.0/lucene-java-7.5.0/lucene/ and do ant ivy-bootstrap

Update

pip install jcc
wget https://archive.apache.org/dist/lucene/pylucene/pylucene-7.5.0-src.tar.gz
tar xzf pylucene-7.5.0-src.tar.gz
cd pylucene-7.5.0/lucene-java-7.5.0/lucene/
ant ivy-bootstrap
ant
cd ../../
make all install ANT=ant PYTHON=python "JCC=python -m jcc --shared" NUM_FILES=8

Colab

from google.colab import drive
drive.mount('/content/drive')

!sudo apt install ant openjdk-8-jdk
!sudo  update-java-alternatives --set java-1.8.0-openjdk-amd64

!ls /usr/lib/jvm/default-java/lib/
!sudo  update-java-alternatives --list
!ant -v
!java -version

!wget https://archive.apache.org/dist/lucene/pylucene/pylucene-7.5.0-src.tar.gz; tar xzf pylucene-7.5.0-src.tar.gz;

!cd pylucene-7.5.0/jcc; export LD_LIBRARY_PATH="/usr/lib/jvm/java-8-openjdk-amd64/lib":$LD_LIBRARY_PATH; JCC_JDK="/usr/lib/jvm/java-8-openjdk-amd64" python setup.py install;

!cd pylucene-7.5.0/lucene-java-7.5.0/lucene/; sed -i -e 's/value="http:/value="https:/g' common-build.xml; ant ivy-bootstrap; ant;

!cd pylucene-7.5.0; export LD_LIBRARY_PATH="/usr/lib/jvm/java-8-openjdk-amd64/lib":$LD_LIBRARY_PATH; export JCC_JDK="/usr/lib/jvm/java-8-openjdk-amd64"; make all install ANT=ant PYTHON=python "JCC=python -m jcc --shared" NUM_FILES=8

!cd pylucene-7.5.0/test3; python test_PyLucene.py

!python /content/pylucene-7.5.0/test3/test_PyLuceneThread.py

!ls /content/drive/
!cp pylucene-7.5.0/jcc/dist/JCC-3.3-py3.7-linux-x86_64.egg /content/drive/MyDrive/data/
!cp pylucene-7.5.0/dist/lucene-7.5.0-py3.7-linux-x86_64.egg /content/drive/MyDrive/data/
!cp -r pylucene-7.5.0/test3 /content/drive/MyDrive/data/pylucene-7.5.0-test3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment