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 | |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 10 | Supported platforms |
| 11 | ------------------- |
| 12 | |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 13 | Currently we test ``cryptography`` on Python 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy |
| 14 | on these operating systems. |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 15 | |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 16 | * x86-64 CentOS 6.4 and CentOS 5.x |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 17 | * x86-64 FreeBSD 9.2 and FreeBSD 10 |
Paul Kehrer | c354a2b | 2014-04-15 18:34:27 -0400 | [diff] [blame] | 18 | * OS X 10.9 Mavericks, 10.8 Mountain Lion, and 10.7 Lion |
Alex Stapleton | b10e954 | 2014-03-15 18:09:33 +0000 | [diff] [blame] | 19 | * x86-64 Ubuntu 12.04 LTS |
Alex Stapleton | 13432b2 | 2014-03-15 19:18:16 +0000 | [diff] [blame] | 20 | * 32-bit Python on 64-bit Windows Server 2008 |
Paul Kehrer | 8ec8a86 | 2014-04-15 18:01:51 -0400 | [diff] [blame] | 21 | * 64-bit Python on 64-bit Windows Server 2012 |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 22 | |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 23 | We test compiling with ``clang`` as well as ``gcc`` and use the following |
| 24 | OpenSSL releases: |
| 25 | |
| 26 | * ``OpenSSL 0.9.8e-fips-rhel5`` (``RHEL/CentOS 5``) |
Alex Stapleton | 2c688a4 | 2014-05-04 15:22:29 +0100 | [diff] [blame] | 27 | * ``OpenSSL 0.9.8k`` |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 28 | * ``OpenSSL 0.9.8y`` |
| 29 | * ``OpenSSL 1.0.0-fips`` (``RHEL/CentOS 6.4``) |
| 30 | * ``OpenSSL 1.0.1`` |
| 31 | * ``OpenSSL 1.0.1e-freebsd`` |
| 32 | * ``OpenSSL 1.0.1g`` |
| 33 | * ``OpenSSL 1.0.2 beta`` |
| 34 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 35 | On Windows |
| 36 | ---------- |
Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame] | 37 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 38 | If you're on Windows you'll need to make sure you have OpenSSL installed. |
| 39 | There are `pre-compiled binaries`_ available. If your installation is in |
| 40 | an unusual location set the ``LIB`` and ``INCLUDE`` environment variables |
| 41 | to include the corresponding locations. For example: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 42 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 43 | .. code-block:: console |
| 44 | |
| 45 | C:\> \path\to\vcvarsall.bat x86_amd64 |
Paul Kehrer | 8ec8a86 | 2014-04-15 18:01:51 -0400 | [diff] [blame] | 46 | C:\> set LIB=C:\OpenSSL-1.0.1g-64bit\lib;%LIB% |
| 47 | C:\> set INCLUDE=C:\OpenSSL-1.0.1g-64bit\include;%INCLUDE% |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 48 | C:\> pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 49 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 50 | Building cryptography on Linux |
| 51 | ------------------------------ |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 52 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 53 | ``cryptography`` should build very easily on Linux provided you have a C |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 54 | compiler, headers for Python (if you're not using ``pypy``), and headers for |
| 55 | the OpenSSL and ``libffi`` libraries available on your system. |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 56 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 57 | For Debian and Ubuntu, the following command will ensure that the required |
Chris Glass | f82d94f | 2014-02-13 11:46:49 +0100 | [diff] [blame] | 58 | dependencies are installed: |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 59 | |
| 60 | .. code-block:: console |
| 61 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 62 | $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 63 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 64 | For Fedora and RHEL-derivatives, the following command will ensure that the |
| 65 | required dependencies are installed: |
Ayrx | a674c6b | 2014-02-15 21:24:23 +0800 | [diff] [blame] | 66 | |
| 67 | .. code-block:: console |
| 68 | |
| 69 | $ sudo yum install gcc libffi-devel python-devel openssl-devel |
| 70 | |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 71 | You should now be able to build and install cryptography with the usual |
| 72 | |
| 73 | .. code-block:: console |
| 74 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 75 | $ pip install cryptography |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 76 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 77 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 78 | Using your own OpenSSL on Linux |
| 79 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 80 | |
| 81 | Python links to OpenSSL for its own purposes and this can sometimes cause |
| 82 | problems when you wish to use a different version of OpenSSL with cryptography. |
| 83 | If you want to use cryptography with your own build of OpenSSL you will need to |
| 84 | make sure that the build is configured correctly so that your version of |
| 85 | OpenSSL doesn't conflict with Python's. |
| 86 | |
| 87 | The options you need to add allow the linker to identify every symbol correctly |
| 88 | even when multiple versions of the library are linked into the same program. If |
| 89 | you are using your distribution's source packages these will probably be |
| 90 | patched in for you already, otherwise you'll need to use options something like |
| 91 | this when configuring OpenSSL: |
| 92 | |
| 93 | .. code-block:: console |
| 94 | |
| 95 | $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared |
| 96 | |
| 97 | You'll also need to generate your own ``openssl.ld`` file. For example:: |
| 98 | |
| 99 | OPENSSL_1.0.1F_CUSTOM { |
| 100 | global: |
| 101 | *; |
| 102 | }; |
| 103 | |
| 104 | You should replace the version string on the first line as appropriate for your |
| 105 | build. |
| 106 | |
| 107 | Using your own OpenSSL on OS X |
| 108 | ------------------------------ |
| 109 | |
| 110 | To link cryptography against a custom version of OpenSSL you'll need to set |
Ayrx | 1ced5b8 | 2014-04-08 19:41:26 +0800 | [diff] [blame] | 111 | ``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via `Homebrew`_ or `MacPorts`_: |
| 112 | |
| 113 | `Homebrew`_ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 114 | |
| 115 | .. code-block:: console |
| 116 | |
| 117 | $ brew install openssl |
Ayrx | 1ced5b8 | 2014-04-08 19:41:26 +0800 | [diff] [blame] | 118 | $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 119 | |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 120 | or `MacPorts`_: |
| 121 | |
| 122 | .. code-block:: console |
| 123 | |
| 124 | $ sudo port install openssl |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 125 | $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 126 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 127 | Building cryptography with conda |
| 128 | -------------------------------- |
| 129 | |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 130 | Because of a `bug in conda`_, attempting to install cryptography out of the box |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame^] | 131 | will result in an error. This can be resolved by setting the library path environment variable for your platform. |
| 132 | |
| 133 | On OS X: |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 134 | |
| 135 | .. code-block:: console |
| 136 | |
| 137 | $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 138 | |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame^] | 139 | And on Linux: |
| 140 | |
| 141 | .. code-block:: console |
| 142 | |
| 143 | $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 144 | |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 145 | You will need to set this variable every time you start Python. For more |
Alex Gaynor | f65cba2 | 2014-05-02 10:40:57 -0700 | [diff] [blame] | 146 | information, consult `Greg Wilson's blog post`_ on the subject. |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 147 | |
| 148 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 149 | .. _`Homebrew`: http://brew.sh |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 150 | .. _`MacPorts`: http://www.macports.org |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 151 | .. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 152 | .. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110 |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 153 | .. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html |