Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame^] | 1 | Installation |
| 2 | ============ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 3 | |
| 4 | You can install ``cryptography`` with ``pip``: |
| 5 | |
| 6 | .. code-block:: console |
| 7 | |
| 8 | $ pip install cryptography |
| 9 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 10 | On Windows |
| 11 | ---------- |
Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame^] | 12 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 13 | If you're on Windows you'll need to make sure you have OpenSSL installed. |
| 14 | There are `pre-compiled binaries`_ available. If your installation is in |
| 15 | an unusual location set the ``LIB`` and ``INCLUDE`` environment variables |
| 16 | to include the corresponding locations. For example: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 17 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 18 | .. code-block:: console |
| 19 | |
| 20 | C:\> \path\to\vcvarsall.bat x86_amd64 |
| 21 | C:\> set LIB=C:\OpenSSL-1.0.1f-64bit\lib;%LIB% |
| 22 | C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE% |
| 23 | C:\> pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 24 | |
| 25 | Using your own OpenSSL on Linux |
| 26 | ------------------------------- |
| 27 | |
| 28 | Python links to OpenSSL for its own purposes and this can sometimes cause |
| 29 | problems when you wish to use a different version of OpenSSL with cryptography. |
| 30 | If you want to use cryptography with your own build of OpenSSL you will need to |
| 31 | make sure that the build is configured correctly so that your version of |
| 32 | OpenSSL doesn't conflict with Python's. |
| 33 | |
| 34 | The options you need to add allow the linker to identify every symbol correctly |
| 35 | even when multiple versions of the library are linked into the same program. If |
| 36 | you are using your distribution's source packages these will probably be |
| 37 | patched in for you already, otherwise you'll need to use options something like |
| 38 | this when configuring OpenSSL: |
| 39 | |
| 40 | .. code-block:: console |
| 41 | |
| 42 | $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared |
| 43 | |
| 44 | You'll also need to generate your own ``openssl.ld`` file. For example:: |
| 45 | |
| 46 | OPENSSL_1.0.1F_CUSTOM { |
| 47 | global: |
| 48 | *; |
| 49 | }; |
| 50 | |
| 51 | You should replace the version string on the first line as appropriate for your |
| 52 | build. |
| 53 | |
| 54 | Using your own OpenSSL on OS X |
| 55 | ------------------------------ |
| 56 | |
| 57 | To link cryptography against a custom version of OpenSSL you'll need to set |
| 58 | ``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via |
| 59 | `Homebrew`_: |
| 60 | |
| 61 | .. code-block:: console |
| 62 | |
| 63 | $ brew install openssl |
| 64 | |
| 65 | Then install cryptography linking against the brewed version: |
| 66 | |
| 67 | .. code-block:: console |
| 68 | |
| 69 | $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography |
| 70 | |
| 71 | |
| 72 | .. _`Homebrew`: http://brew.sh |
| 73 | .. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html |