-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
74 lines (66 loc) · 2.88 KB
/
Copy pathsetup.py
File metadata and controls
74 lines (66 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# # LICENSE MIT Neo Sahadeo 2026
#
# import sys
# from setuptools import setup, Extension
#
# sqlcipher_module = Extension('sqlcipher',
# sources=['sqlcipher_pyext.c'],
# extra_objects=['sqlcipher/sqlite3.o'],
# include_dirs=['.', './sqlcipher'],
# extra_link_args=['-lcrypto'],
# define_macros=[
# ('SQLITE_HAS_CODEC', None),
# ('SQLITE_TEMP_STORE', '2'),
# ('SQLITE_EXTRA_INIT', 'sqlcipher_extra_init'),
# ('SQLITE_EXTRA_SHUTDOWN', 'sqlcipher_extra_shutdown')
# ])
#
# setup(name='sqlcipher',
# version='0.1',
# author="Neo Sahadeo",
# description='Python binding for SQLCipher',
# ext_modules=[sqlcipher_module])
# LICENSE MIT Neo Sahadeo 2026
import os
import subprocess
import sys
from pathlib import Path
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
class CustomBuildExt(build_ext):
def build_before(self):
sqlcipher_dir = Path("sqlcipher")
if not sqlcipher_dir.exists():
subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/sqlcipher/sqlcipher"])
subprocess.check_call(["git", "clone", "https://github.com/sqlcipher/sqlcipher.git", str(sqlcipher_dir)])
else:
subprocess.check_call(["git", "-C", str(sqlcipher_dir), "pull"])
os.chdir(sqlcipher_dir)
subprocess.check_call(["./configure", "--with-tempstore=yes",
"CFLAGS=-DSQLITE_HAS_CODEC -DSQLITE_EXTRA_INIT=sqlcipher_extra_init -DSQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown",
"LDFLAGS=-lcrypto"])
subprocess.check_call(["make", "sqlite3.o"])
os.chdir("..")
def run(self):
self.build_before()
super().run()
sqlcipher_module = Extension('sqlcipher',
sources=['sqlcipher_pyext.c'],
extra_objects=['sqlcipher/sqlite3.o'],
include_dirs=['.', './sqlcipher'],
extra_link_args=['-lcrypto'],
define_macros=[
('SQLITE_HAS_CODEC', None),
('SQLITE_TEMP_STORE', '2'),
('SQLITE_EXTRA_INIT', 'sqlcipher_extra_init'),
('SQLITE_EXTRA_SHUTDOWN', 'sqlcipher_extra_shutdown')
])
setup(
name='sqlcipher',
version='0.1',
author="Neo Sahadeo",
description='Python binding for SQLCipher',
ext_modules=[sqlcipher_module],
cmdclass={'build_ext': CustomBuildExt},
zip_safe=False,
)