Skip to content

Commit c155277

Browse files
committed
add package with debug symbols
1 parent 2d164a5 commit c155277

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
amalgamation
22
build
33
*.pyc
4+
.pybuild/
45
dist/
56
MANIFEST
67
debian/python-sqlcipher
8+
debian/python-sqlcipher-dbg
79
debian/*.log
810
debian/files
911
debian/*.substvars

debian/control

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Maintainer: Ben Carrillo <[email protected]>
33
Section: python
44
Priority: optional
55
Build-Depends: python-all-dev (>= 2.6.6-3), libsqlcipher-dev (>=2.2.1-2~), debhelper (>= 9)
6-
Standards-Version: 3.9.4
6+
Standards-Version: 3.9.6
77
Uploaders: Micah Anderson <[email protected]>
88
X-Python-Version: >= 2.5
99

@@ -17,3 +17,14 @@ Description: DB-API 2.0 interface for SQLCIPHER 3.x
1717
database engine. It is almost fully compliant with the Python database API
1818
version 2.0. At the same time, it also exposes the unique features of
1919
SQLCipher.
20+
21+
Package: python-sqlcipher-dbg
22+
Section: debug
23+
Priority: extra
24+
Architecture: any
25+
Depends: python-dbg, python-sqlcipher, libsqlcipher0 (>=2.2.1-2),
26+
${misc:Depends}, ${python:Depends}, ${shlibs:Depends}
27+
Description: DB-API 2.0 interface for SQLCIPHER 3.x
28+
Python interface to SQLCipher (debug extension)
29+
.
30+
This package contains the extensions built for the python debug interpreter.

debian/rules

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55
# Prevent setuptools/distribute from accessing the internet.
66
export http_proxy = http://127.0.0.1:9
77

8+
PACKAGE=python-sqlcipher
9+
810
%:
911
dh $@ --with python2 --buildsystem=python_distutils
1012

1113
override_dh_auto_build:
12-
python$* setup.py build_sqlcipher
14+
python$* setup.py build_with_system_sqlcipher
1315
python$* setup.py build_py
1416

17+
export DEBUG_MODE=1 && export DEB_CFLAGS_MAINT_APPEND=-O0 && python$*-dbg setup.py build_with_system_sqlcipher
18+
export DEBUG_MODE=1 && export DEB_CFLAGS_MAINT_APPEND=-O0 && python$*-dbg setup.py build_py
19+
1520
override_dh_auto_install:
1621
python$* setup.py install --skip-build --root=debian/python-sqlcipher \
1722
--install-layout=deb
23+
python$*-dbg setup.py install --skip-build --root=debian/python-sqlcipher-dbg \
24+
--install-layout=deb
25+
26+
override_dh_installdocs:
27+
dh_installdocs
28+
rm -rf debian/$(PACKAGE)-dbg/usr/share/doc/$(PACKAGE)-dbg
29+
ln -s $(PACKAGE) debian/$(PACKAGE)-dbg/usr/share/doc/$(PACKAGE)-dbg
30+
31+
override_dh_strip:
32+
dh_strip --dbg-package=$(PACKAGE)-dbg
1833

1934
override_dh_python2:
2035
dh_python2 --no-guessing-versions

debian/watch

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,37 @@ def __init__(self, *args, **kwargs):
141141
build.__init__(self, *args, **kwargs)
142142

143143

144+
DEBUG_MODE = os.environ.get("DEBUG_MODE", False)
145+
146+
144147
class LibSQLCipherBuilder(build_ext):
145148

146149
description = ("Build C extension linking against libsqlcipher library.")
147150

148151
def build_extension(self, ext):
152+
if DEBUG_MODE:
153+
self.__remove_compiler_option("-O2")
154+
self.__remove_compiler_option("-O1")
155+
149156
ext.extra_compile_args.append("-I/usr/include/sqlcipher/")
150157
ext.extra_link_args.append("-lsqlcipher")
151158
build_ext.build_extension(self, ext)
152159

160+
def __remove_compiler_option(self, option):
161+
"""
162+
Remove the specified compiler option.
163+
164+
Return true if the option was found. Return false otherwise.
165+
"""
166+
found = 0
167+
for attrname in ('compiler', 'compiler_so'):
168+
compiler = getattr(self.compiler, attrname, None)
169+
if compiler is not None:
170+
while option in compiler:
171+
compiler.remove(option)
172+
found += 1
173+
return found
174+
153175

154176
class MyBuildExt(build_ext):
155177
amalgamation = True # We want amalgamation on the default build for now
@@ -353,7 +375,7 @@ def get_setup_args():
353375
{"build_docs": DocBuilder,
354376
"build_ext": MyBuildExt,
355377
"build_static": AmalgamationBuilder,
356-
"build_sqlcipher": LibSQLCipherBuilder,
378+
"build_with_system_sqlcipher": LibSQLCipherBuilder,
357379
"cross_bdist_wininst": cross_bdist_wininst.bdist_wininst})
358380
return setup_args
359381

0 commit comments

Comments
 (0)