如何为 Windows 构建 SQL 密码 Python 绑定

How to build SQL Cipher Python Binding for Windows

我在 Windows machine 上为 SQL 密码构建 python 绑定时遇到问题。我已经成功地为 Macintosh 构建了 python 绑定。我想在 Mac 和 PC 上使用我的 python 脚本。

我是 python 的新手,不完全理解它失败的原因,但我开始尝试调试 setup.py 脚本并发现错误在 build_extension(self, ext)第 147 行的方法。

我构建的步骤:

  1. https://github.com/rigglemania/pysqlcipher3
  2. https://github.com/sqlcipher/sqlcipher
  3. http://www.jerryrw.com/howtocompile.php

我克隆了上面的存储库并按照 Jerry 关于如何构建 sqlcipher 的说明进行了操作。我拿了 sqlite3.c 和 sqlite3.h 文件并将它们放在您的合并文件夹中,然后我尝试构建合并。我收到以下错误。我尝试只构建,但也因同样的错误而失败。

错误:

running build_amalgamation
Builds a C extension using a sqlcipher amalgamation
building 'pysqlcipher3._sqlite3' extension
['path']

问题:

  1. 有什么方法可以在我的 mac 上构建 sqlcipher 并将其用于 PC? (将文件从 MAC 传输到 PC)?
  2. 有人可以帮我为 PC 构建 sqlcipher3 python 绑定吗?

我是 python 的新手,如有任何帮助,我们将不胜感激。

https://github.com/rigglemania/pysqlcipher3

1) 安装免费的 VS 2015 社区版

注意:确保 select 所有 GCC 选项(VC++、C++ 等)。如果您不确定 select 所有选项。

2) 从 https://slproweb.com/products/Win32OpenSSL.html

安装了预构建的 OpenSSL 二进制文件(Win32 OpenSSL v1.0.2d 或更高版本)

3) 确认OPENSSL_CONF环境变量在环境变量中设置正确。见 http://www.computerhope.com/issues/ch000549.htm

注意:这不应该是根 openssl 路径(例如:C:/openssl-Win32),而应该是配置文件的路径(例如:C:/openssl-Win32/bin/openssl.cfg)

4) 将 (C:/OpenSSL-Win32/include/openssl) 目录下的 openssl 文件夹复制到 VC include 目录 (ex: C:/Program Files (x86)/Microsoft Visual Studio 14.0 /VC/include)

注意:确认以下路径存在(../../VC/include/openssl/aes.h)

5) 安装 Python 3.5(32 位)。

注意:如果您安装了 python 64 位,您可能需要在安装 python 32 位之前卸载它。

6) 使用 SQL Cipher 3 合并,或者您可以按照本教程 http://www.jerryrw.com/howtocompile.php.

编译最新的 SQL Cipher 合并

7) 点击开始,运行,cmd。在 CMD 提示符中导航到您签出此存储库的文件夹。 运行"python setup.py build_amalgamation"

8) 运行 "python setup.py install"。通过尝试解密数据库来测试新库。

注意:如果解密失败,请检查您是否有正确的合并文件。