pythonpython-3.xdistutilssqlcipherpysqlcipher

How to build SQL Cipher Python Binding for Windows


I'm having trouble building a python binding for SQL cipher on my Windows machine. I have already sucessfully built the python binding for Macintosh. I would like to use my python script on both Mac and PC.

I’m new to python and don’t fully understand why it is failing but I began trying to debug the setup.py script and found the error is in the build_extension(self, ext) method at line 147.

Steps I took to build:

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

I cloned the repos above and followed Jerry’s instructions on how to build sqlcipher. I took the sqlite3.c and sqlite3.h files and placed them in your amalgamation folder then I attempted to build amalgamation. I got the error below. I attempted to just build and that failed with the same error as well.

Error:

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

Questions:

  1. Is there any way I can build the sqlcipher on my mac and use it for PC? (transfer the files over from MAC to PC)?
  2. Can someone help me build sqlcipher3 python binding for PC?

I'm new to python and any help would be appreciated.


Solution

  • See https://github.com/rigglemania/pysqlcipher3

    1) Install the free VS 2015 Community Edition

    Note: Make sure to select all the GCC options (VC++, C++, etc). If you are unsure select all options.

    2) Installed a prebuilt OpenSSL binary (Win32 OpenSSL v1.0.2d or later) from https:// slproweb.com/products/Win32OpenSSL.html

    3) Confirm that the OPENSSL_CONF environment variable is set properly in environment variables. See http:// www.computerhope.com/issues/ch000549.htm

    Note: This should not be root openssl path (ex: C:/openssl-Win32), but instead should be the path to the config file (ex: C:/openssl-Win32/bin/openssl.cfg)

    4) Copy the openssl folder in (C:/OpenSSL-Win32/include/openssl) directory to the VC include directory (ex: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include)

    Note: Confirm the following path exists (../../VC/include/openssl/aes.h)

    5) Install Python 3.5 (32 bit).

    Note: If you have python 64 bit installed you may have to uninstall it before installing python 32 bit.

    6) Use the SQL Cipher 3 amalgamations or you may compile the latest SQL Cipher amalgamation by following this tutorial http://www.jerryrw.com/howtocompile.php.

    7) Click start, Run, cmd. In the CMD prompt navigate to the folder where you checked out this repository. Run "python setup.py build_amalgamation"

    8) Run "python setup.py install". Test the new library by attempting to decrypt a database.

    Note: If the decrypt fails please check that you have the correct amalgamation files.