Skip to content

Commit

Permalink
Merge pull request cms-sw#1881 from degano/pydxr_sqlite_76XStable
Browse files Browse the repository at this point in the history
Update py2-dxr to use pysqlite 2.8 to load extension in sqlite 3.8.
  • Loading branch information
aledegano committed Oct 12, 2015
2 parents 6d5feaf + ed9116b commit 0ac2a78
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 17 deletions.
1 change: 1 addition & 0 deletions cmssw-tool-conf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Requires: py2-markupsafe-toolfile
Requires: py2-ordereddict-toolfile
Requires: py2-parsimonious-toolfile
Requires: py2-pygments-toolfile
Requires: py2-pysqlite-toolfile
Requires: py2-PyYAML-toolfile
Requires: py2-docopt-toolfile
Requires: py2-prettytable-toolfile
Expand Down
31 changes: 31 additions & 0 deletions py2-dxr-sqlite38.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/dxr/utils.py b/dxr/utils.py
index c4dbc0e..489a08b 100644
--- a/dxr/utils.py
+++ b/dxr/utils.py
@@ -7,13 +7,14 @@ import ctypes
# different version, will fail to load. If you're having trouble getting
# trilite to load, make sure you're not importing sqlite3 beforehand. Afterward
# is fine.
-ctypes.CDLL('libtrilite.so').load_trilite_extension()
+#ctypes.CDLL('libtrilite.so').load_trilite_extension()

import os
from os import dup
from os.path import join, dirname
import jinja2
-import sqlite3
+#import sqlite3
+from pysqlite2 import dbapi2 as sqlite3
import string
from sys import stdout
from urllib import quote, quote_plus
@@ -112,6 +113,9 @@ def connect_db(dir):

"""
conn = sqlite3.connect(join(dir, ".dxr-xref.sqlite"))
+ conn.enable_load_extension(True)
+ conn.load_extension("libtrilite.so")
+ conn.enable_load_extension(False)
conn.text_factory = str
conn.execute("PRAGMA synchronous=off")
conn.execute("PRAGMA page_size=32768")
1 change: 1 addition & 0 deletions py2-dxr-toolfile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cat << \EOF_TOOLFILE >%{i}/etc/scram.d/py2-dxr.xml
<use name="py2-ordereddict"/>
<use name="py2-parsimonious"/>
<use name="py2-pygments"/>
<use name="py2-pysqlite"/>
</tool>
EOF_TOOLFILE

Expand Down
10 changes: 7 additions & 3 deletions py2-dxr.spec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### RPM external py2-dxr 1.0
## INITENV +PATH PYTHONPATH %i/$PYTHON_LIB_SITE_PACKAGES
BuildRequires: llvm sqlite
Requires: python zlib py2-setuptools py2-futures py2-jinja py2-markupsafe py2-ordereddict py2-parsimonious

Requires: python zlib py2-setuptools py2-futures py2-jinja py2-markupsafe py2-ordereddict py2-parsimonious py2-pysqlite
%define isdarwin %(case %{cmsos} in (osx*) echo 1 ;; (*) echo 0 ;; esac)
%define dxrCommit 6ea764102a
%define triliteCommit e64a2a1
%define re2Version 20140304
Expand All @@ -15,25 +15,29 @@ Patch0: py2-dxr
Patch1: trilite
Patch2: py2-dxr-fix-clang-linker-flags
Patch3: py2-dxr-clang36
Patch4: py2-dxr-sqlite38
%define keep_archives true

%prep
%setup -T -b0 -n dxr-%dxrCommit
%setup -T -D -a1 -c -n dxr-%dxrCommit
%setup -T -D -a2 -n dxr-%dxrCommit/trilite-%triliteCommit
%patch1 -p0
%patch1 -p1
cd ..
%patch0 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
mv trilite-%triliteCommit/* trilite
%setup -T -D -n dxr-%dxrCommit

# We are not using LLVM/Clang + libc++ on Darwin, but
# GCC + libstdc++. The ABIs are different, thus correct
# it accordingly.
# https://code.google.com/p/re2/issues/detail?id=99
%if %isdarwin
sed -ibak 's;__ZlsRNSt3__113basic_ostreamIcNS_11char_traitsIcEEEERKN3re211StringPieceE;__ZlsRSoRKN3re211StringPieceE;' ./trilite/re2/libre2.symbols.darwin
%endif

%build
export SQLITE_ROOT
Expand Down
23 changes: 23 additions & 0 deletions py2-pysqlite-toolfile.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### RPM external py2-pysqlite-toolfile 1.0
Requires: py2-pysqlite
%prep

%build

%install

mkdir -p %{i}/etc/scram.d
cat << \EOF_TOOLFILE >%{i}/etc/scram.d/py2-pysqlite.xml
<tool name="py2-pysqlite" version="@TOOL_VERSION@">
<info url="https://pypi.python.org/pypi/pysqlite"/>
<client>
<environment name="PY2_PYSQLITE" default="@TOOL_ROOT@"/>
<environment name="LIBDIR" default="$PY2_PYSQLITE/lib"/>
<runtime name="PYTHONPATH" value="$PY2_PYSQLITE/lib/python@PYTHONV@/site-packages" type="path"/>
</client>
</tool>
EOF_TOOLFILE

export PYTHONV=$(echo $PYTHON_VERSION | cut -f1,2 -d.)

## IMPORT scram-tools-post
16 changes: 6 additions & 10 deletions py2-pysqlite.spec
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
### RPM external py2-pysqlite 2.4.0
%define pythonv %(echo $PYTHON_VERSION | cut -f1,2 -d.)
%define distname pysqlite-%realversion
%define distmaindir %(echo %realversion | cut -d. -f1,2)
## INITENV +PATH PYTHONPATH %i/lib/python`echo $PYTHON_VERSION | cut -f1,2 -d.`/site-packages
Source: http://initd.org/pub/software/pysqlite/releases/%distmaindir/%realversion/%{distname}.tar.gz
Requires: python sqlite
### RPM external py2-pysqlite 2.8.1
## INITENV +PATH PYTHONPATH %i/$PYTHON_LIB_SITE_PACKAGES
Source: https://pypi.python.org/packages/source/p/pysqlite/pysqlite-%realversion.tar.gz
Requires: python sqlite py2-setuptools

%prep
%setup -n %{distname}
%setup -n pysqlite-%realversion
%build
perl -p -i -e "s!include_dirs=.*!include_dirs=$SQLITE_ROOT/include!" setup.cfg
perl -p -i -e "s!library_dirs=.*!library_dirs=$SQLITE_ROOT/lib!" setup.cfg
echo "include_dirs=$SQLITE_ROOT/include" >> setup.cfg
python setup.py build
%install
python setup.py install --prefix=%i
21 changes: 17 additions & 4 deletions trilite.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--- makefile.orig 2014-10-02 10:34:09.000000000 -0500
+++ makefile 2014-10-02 10:40:15.622458716 -0500
diff --git a/makefile b/makefile
index 7e746da..2405469 100644
--- a/makefile
+++ b/makefile
@@ -1,5 +1,5 @@
-CFLAGS := -Ire2/ $(shell pkg-config --cflags sqlite3) -Wall -fPIC -ansi
-LDFLAGS := -Lre2/obj -lre2 $(shell pkg-config --libs sqlite3) -shared
Expand All @@ -8,7 +10,7 @@
SOURCES := kmp.c scanstr.c varint.c hash.c expr.c match.c regexp.cpp cursor.c vtable.c trilite.c
OBJECTS := $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCES)))
all: debug
@@ -9,7 +9,7 @@
@@ -9,7 +9,7 @@ release: CFLAGS += -DNDEBUG -O3
release: LDFLAGS += -O3
release: re2/obj/libre2.a libtrilite.so
re2:
Expand All @@ -17,4 +19,15 @@
re2/obj/libre2.a: re2
$(MAKE) -C re2 CXXFLAGS='-Wall -O3 -pthread -fPIC'
%.o: %.cpp

diff --git a/trilite.h b/trilite.h
index 684a5fd..193e657 100644
--- a/trilite.h
+++ b/trilite.h
@@ -5,6 +5,6 @@

int sqlite3_extension_init(sqlite3*, char**, const sqlite3_api_routines*);

-void load_trigram_extension();
+void load_trilite_extension();

#endif /* TRILITE_TRILITE_H */

0 comments on commit 0ac2a78

Please sign in to comment.