diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4397fa3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +sqlcipher/sqlite3.h +build/* +dist/* +sqlcipher3.egg-info/* diff --git a/setup.py b/setup.py index 5f69599..f5753ee 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ # import os import setuptools +import shutil import sys from distutils import log @@ -52,20 +53,25 @@ class AmalgationLibSqliteBuilder(build_ext): amalgamation_header = os.path.join(amalgamation_root, 'sqlite3.h') amalgamation_source = os.path.join(amalgamation_root, 'sqlite3.c') + header_dir = os.path.join(amalgamation_root, 'sqlcipher') + header_file = os.path.join(header_dir, 'sqlite3.h') + amalgamation_message = ('Sqlcipher amalgamation not found. Please download' ' or build the amalgamation and make sure the ' 'following files are present in the sqlcipher3 ' 'folder: sqlite3.h, sqlite3.c') def check_amalgamation(self): - if not os.path.exists(self.amalgamation_root): - os.mkdir(self.amalgamation_root) - header_exists = os.path.exists(self.amalgamation_header) source_exists = os.path.exists(self.amalgamation_source) if not header_exists or not source_exists: raise RuntimeError(self.amalgamation_message) + if not os.path.exists(self.header_dir): + os.mkdir(self.header_dir) + if not os.path.exists(self.header_file): + shutil.copy(self.amalgamation_header, self.header_file) + def build_extension(self, ext): log.info(self.description)