Skip to content

Commit ee46537

Browse files
committed
cleanup setup
removing some past experiments, not used
1 parent 595d196 commit ee46537

File tree

1 file changed

+46
-143
lines changed

1 file changed

+46
-143
lines changed

setup.py

Lines changed: 46 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -130,151 +130,54 @@ def build_extension(self, ext):
130130

131131

132132
class AmalgamationBuildExt(build_ext):
133-
amalgamation = True # We want amalgamation on the default build for now
134-
static = False
133+
134+
amalgamation = True
135135

136136
def build_extension(self, ext):
137-
if self.amalgamation:
138-
# build with fulltext search enabled
139-
ext.define_macros.append(
140-
("SQLITE_ENABLE_FTS3", "1"))
141-
ext.define_macros.append(
142-
("SQLITE_ENABLE_FTS5", "1"))
143-
ext.define_macros.append(
144-
("SQLITE_ENABLE_RTREE", "1"))
145-
146-
# SQLCipher options
147-
ext.define_macros.append(
148-
("SQLITE_ENABLE_LOAD_EXTENSION", "1"))
149-
ext.define_macros.append(
150-
("SQLITE_HAS_CODEC", "1"))
151-
ext.define_macros.append(
152-
("SQLITE_TEMP_STORE", "2"))
153-
ext.define_macros.append(
154-
("HAVE_USLEEP", "1"))
155-
156-
ext.sources.append(os.path.join(AMALGAMATION_ROOT, "sqlite3.c"))
157-
ext.include_dirs.append(AMALGAMATION_ROOT)
158-
159-
if sys.platform == "win32":
160-
# Try to locate openssl
161-
openssl_conf = os.environ.get('OPENSSL_CONF')
162-
if not openssl_conf:
163-
sys.exit('Fatal error: OpenSSL could not be detected!')
164-
openssl = os.path.dirname(os.path.dirname(openssl_conf))
165-
166-
# Configure the compiler
167-
ext.include_dirs.append(os.path.join(openssl, "include"))
168-
ext.define_macros.append(("inline", "__inline"))
169-
170-
# Configure the linker
171-
if self.compiler.compiler_type == "msvc":
172-
ext.extra_link_args.append("libeay32.lib")
173-
ext.extra_link_args.append(
174-
"/LIBPATH:" + os.path.join(openssl, "lib")
175-
)
176-
if self.compiler.compiler_type == "mingw32":
177-
ext.extra_link_args.append("-lcrypto")
178-
else:
137+
# build with fulltext search enabled
138+
ext.define_macros.append(
139+
("SQLITE_ENABLE_FTS3", "1"))
140+
ext.define_macros.append(
141+
("SQLITE_ENABLE_FTS5", "1"))
142+
ext.define_macros.append(
143+
("SQLITE_ENABLE_RTREE", "1"))
144+
145+
# SQLCipher options
146+
ext.define_macros.append(
147+
("SQLITE_ENABLE_LOAD_EXTENSION", "1"))
148+
ext.define_macros.append(
149+
("SQLITE_HAS_CODEC", "1"))
150+
ext.define_macros.append(
151+
("SQLITE_TEMP_STORE", "2"))
152+
ext.define_macros.append(
153+
("HAVE_USLEEP", "1"))
154+
155+
ext.sources.append(os.path.join(AMALGAMATION_ROOT, "sqlite3.c"))
156+
ext.include_dirs.append(AMALGAMATION_ROOT)
157+
158+
if sys.platform == "win32":
159+
# Try to locate openssl
160+
openssl_conf = os.environ.get('OPENSSL_CONF')
161+
if not openssl_conf:
162+
sys.exit('Fatal error: OpenSSL could not be detected!')
163+
openssl = os.path.dirname(os.path.dirname(openssl_conf))
164+
165+
# Configure the compiler
166+
ext.include_dirs.append(os.path.join(openssl, "include"))
167+
ext.define_macros.append(("inline", "__inline"))
168+
169+
# Configure the linker
170+
if self.compiler.compiler_type == "msvc":
171+
ext.extra_link_args.append("libeay32.lib")
172+
ext.extra_link_args.append(
173+
"/LIBPATH:" + os.path.join(openssl, "lib")
174+
)
175+
if self.compiler.compiler_type == "mingw32":
179176
ext.extra_link_args.append("-lcrypto")
180-
181-
if self.static:
182-
self._build_extension(ext)
183-
else:
184-
build_ext.build_extension(self, ext)
185-
186-
def _build_extension(self, ext):
187-
sources = ext.sources
188-
if sources is None or type(sources) not in (ListType, TupleType):
189-
raise DistutilsSetupError, \
190-
("in 'ext_modules' option (extension '%s'), " +
191-
"'sources' must be present and must be " +
192-
"a list of source filenames") % ext.name
193-
sources = list(sources)
194-
195-
ext_path = self.get_ext_fullpath(ext.name)
196-
depends = sources + ext.depends
197-
if not (self.force or newer_group(depends, ext_path, 'newer')):
198-
log.debug("skipping '%s' extension (up-to-date)", ext.name)
199-
return
200177
else:
201-
log.info("building '%s' extension", ext.name)
202-
203-
# First, scan the sources for SWIG definition files (.i), run
204-
# SWIG on 'em to create .c files, and modify the sources list
205-
# accordingly.
206-
sources = self.swig_sources(sources, ext)
207-
208-
# Next, compile the source code to object files.
209-
210-
# XXX not honouring 'define_macros' or 'undef_macros' -- the
211-
# CCompiler API needs to change to accommodate this, and I
212-
# want to do one thing at a time!
213-
214-
# Two possible sources for extra compiler arguments:
215-
# - 'extra_compile_args' in Extension object
216-
# - CFLAGS environment variable (not particularly
217-
# elegant, but people seem to expect it and I
218-
# guess it's useful)
219-
# The environment variable should take precedence, and
220-
# any sensible compiler will give precedence to later
221-
# command line args. Hence we combine them in order:
222-
extra_args = ext.extra_compile_args or []
223-
224-
macros = ext.define_macros[:]
225-
for undef in ext.undef_macros:
226-
macros.append((undef,))
227-
228-
objects = self.compiler.compile(sources,
229-
output_dir=self.build_temp,
230-
macros=macros,
231-
include_dirs=ext.include_dirs,
232-
debug=self.debug,
233-
extra_postargs=extra_args,
234-
depends=ext.depends)
235-
236-
# XXX -- this is a Vile HACK!
237-
#
238-
# The setup.py script for Python on Unix needs to be able to
239-
# get this list so it can perform all the clean up needed to
240-
# avoid keeping object files around when cleaning out a failed
241-
# build of an extension module. Since Distutils does not
242-
# track dependencies, we have to get rid of intermediates to
243-
# ensure all the intermediates will be properly re-built.
244-
#
245-
self._built_objects = objects[:]
246-
247-
# Now link the object files together into a "shared object" --
248-
# of course, first we have to figure out all the other things
249-
# that go into the mix.
250-
if ext.extra_objects:
251-
objects.extend(ext.extra_objects)
252-
extra_args = ext.extra_link_args or []
253-
254-
# Detect target language, if not provided
255-
language = ext.language or self.compiler.detect_language(sources)
256-
257-
#self.compiler.link_shared_object(
258-
#objects, ext_path,
259-
#libraries=self.get_libraries(ext),
260-
#library_dirs=ext.library_dirs,
261-
#runtime_library_dirs=ext.runtime_library_dirs,
262-
#extra_postargs=extra_args,
263-
#export_symbols=self.get_export_symbols(ext),
264-
#debug=self.debug,
265-
#build_temp=self.build_temp,
266-
#target_lang=language)
267-
268-
# XXX may I have a static lib please?
269-
# hmm but then I cannot load that extension, or can I?
270-
output_dir = os.path.sep.join(ext_path.split(os.path.sep)[:-1])
271-
272-
self.compiler.create_static_lib(
273-
objects,
274-
#XXX get library name ... splitting ext_path?
275-
"sqlite",
276-
output_dir=output_dir,
277-
target_lang=language)
178+
ext.extra_link_args.append("-lcrypto")
179+
180+
build_ext.build_extension(self, ext)
278181

279182
def __setattr__(self, k, v):
280183
# Make sure we don't link against the SQLite
@@ -309,7 +212,7 @@ def get_setup_args():
309212
PYSQLITE_VERSION += "-%s" % PATCH_VERSION
310213

311214
# Need to bump minor version, patch handled badly.
312-
PYSQLCIPHER_VERSION = "2.6.9"
215+
PYSQLCIPHER_VERSION = "2.6.10"
313216

314217
setup_args = dict(
315218
name="pysqlcipher",
@@ -356,7 +259,7 @@ def get_setup_args():
356259

357260

358261
if BUNDLED:
359-
build_ext = AmalgamationBuildExt
262+
build_ext = AmalgamationBuildExt
360263
else:
361264
build_ext = LibSQLCipherBuilder
362265

0 commit comments

Comments
 (0)