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 | |
Alex Gaynor | a26c13a | 2015-09-25 17:52:06 -0400 | [diff] [blame] | 13 | Currently we test ``cryptography`` on Python 2.6, 2.7, 3.3, 3.4, 3.5, and PyPy |
| 14 | 2.6+ on these operating systems. |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 15 | |
Paul Kehrer | 73667de | 2014-07-14 12:33:27 -0500 | [diff] [blame] | 16 | * x86-64 CentOS 7.x, 6.4 and CentOS 5.x |
Paul Kehrer | bd88ee6 | 2015-02-20 10:38:31 -0600 | [diff] [blame] | 17 | * x86-64 FreeBSD 10 |
Paul Kehrer | cebb31a | 2014-11-26 10:09:19 -1000 | [diff] [blame] | 18 | * OS X 10.10 Yosemite, 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 |
Paul Kehrer | 698e806 | 2014-12-28 15:01:54 -0700 | [diff] [blame] | 20 | * x86-64 Debian Wheezy (7.x) and Jessie (8.x) |
Alex Stapleton | 13432b2 | 2014-03-15 19:18:16 +0000 | [diff] [blame] | 21 | * 32-bit Python on 64-bit Windows Server 2008 |
Paul Kehrer | 8ec8a86 | 2014-04-15 18:01:51 -0400 | [diff] [blame] | 22 | * 64-bit Python on 64-bit Windows Server 2012 |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 23 | |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 24 | We test compiling with ``clang`` as well as ``gcc`` and use the following |
| 25 | OpenSSL releases: |
| 26 | |
| 27 | * ``OpenSSL 0.9.8e-fips-rhel5`` (``RHEL/CentOS 5``) |
Alex Stapleton | 2c688a4 | 2014-05-04 15:22:29 +0100 | [diff] [blame] | 28 | * ``OpenSSL 0.9.8k`` |
Paul Kehrer | a5a432a | 2014-10-15 23:47:19 -0500 | [diff] [blame] | 29 | * ``OpenSSL 0.9.8za`` |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 30 | * ``OpenSSL 1.0.0-fips`` (``RHEL/CentOS 6.4``) |
| 31 | * ``OpenSSL 1.0.1`` |
Paul Kehrer | e683dee | 2014-08-09 08:15:23 -1000 | [diff] [blame] | 32 | * ``OpenSSL 1.0.1e-fips`` (``RHEL/CentOS 7``) |
Paul Kehrer | 96a0827 | 2015-02-21 18:37:38 -0600 | [diff] [blame] | 33 | * ``OpenSSL 1.0.1j-freebsd`` |
Paul Kehrer | a5a432a | 2014-10-15 23:47:19 -0500 | [diff] [blame] | 34 | * ``OpenSSL 1.0.1-latest`` (The most recent 1.0.1 release) |
Paul Kehrer | 4994597 | 2015-01-22 20:59:19 -0600 | [diff] [blame] | 35 | * ``OpenSSL 1.0.2`` |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 36 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 37 | On Windows |
| 38 | ---------- |
Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame] | 39 | |
Paul Kehrer | 156360a | 2014-06-30 12:14:01 -0600 | [diff] [blame] | 40 | The wheel package on Windows is a statically linked build (as of 0.5) so all |
| 41 | dependencies are included. Just run |
| 42 | |
| 43 | .. code-block:: console |
| 44 | |
| 45 | $ pip install cryptography |
| 46 | |
| 47 | If you prefer to compile it yourself you'll need to have OpenSSL installed. |
Paul Kehrer | 6608b7e | 2015-07-24 21:52:17 +0100 | [diff] [blame] | 48 | You can compile OpenSSL yourself as well or use the binaries we build for our |
| 49 | release infrastructure (`32-bit`_ and `64-bit`_). Wherever you place your copy |
| 50 | of OpenSSL you'll need to set the ``LIB`` and ``INCLUDE`` environment variables |
| 51 | to include the proper locations. For example: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 52 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 53 | .. code-block:: console |
| 54 | |
| 55 | C:\> \path\to\vcvarsall.bat x86_amd64 |
Paul Kehrer | 6608b7e | 2015-07-24 21:52:17 +0100 | [diff] [blame] | 56 | C:\> set LIB=C:\OpenSSL-win64\lib;%LIB% |
| 57 | C:\> set INCLUDE=C:\OpenSSL-win64\include;%INCLUDE% |
Paul Kehrer | 2a39f7f | 2014-07-02 22:56:01 -0500 | [diff] [blame] | 58 | C:\> pip install cryptography |
| 59 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 60 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 61 | Building cryptography on Linux |
| 62 | ------------------------------ |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 63 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 64 | ``cryptography`` should build very easily on Linux provided you have a C |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 65 | compiler, headers for Python (if you're not using ``pypy``), and headers for |
| 66 | the OpenSSL and ``libffi`` libraries available on your system. |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 67 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 68 | For Debian and Ubuntu, the following command will ensure that the required |
Chris Glass | f82d94f | 2014-02-13 11:46:49 +0100 | [diff] [blame] | 69 | dependencies are installed: |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 70 | |
| 71 | .. code-block:: console |
| 72 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 73 | $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 74 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 75 | For Fedora and RHEL-derivatives, the following command will ensure that the |
| 76 | required dependencies are installed: |
Ayrx | a674c6b | 2014-02-15 21:24:23 +0800 | [diff] [blame] | 77 | |
| 78 | .. code-block:: console |
| 79 | |
| 80 | $ sudo yum install gcc libffi-devel python-devel openssl-devel |
| 81 | |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 82 | You should now be able to build and install cryptography with the usual |
| 83 | |
| 84 | .. code-block:: console |
| 85 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 86 | $ pip install cryptography |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 87 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 88 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 89 | Using your own OpenSSL on Linux |
| 90 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 91 | |
| 92 | Python links to OpenSSL for its own purposes and this can sometimes cause |
| 93 | problems when you wish to use a different version of OpenSSL with cryptography. |
| 94 | If you want to use cryptography with your own build of OpenSSL you will need to |
| 95 | make sure that the build is configured correctly so that your version of |
| 96 | OpenSSL doesn't conflict with Python's. |
| 97 | |
| 98 | The options you need to add allow the linker to identify every symbol correctly |
| 99 | even when multiple versions of the library are linked into the same program. If |
| 100 | you are using your distribution's source packages these will probably be |
| 101 | patched in for you already, otherwise you'll need to use options something like |
| 102 | this when configuring OpenSSL: |
| 103 | |
| 104 | .. code-block:: console |
| 105 | |
| 106 | $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared |
| 107 | |
| 108 | You'll also need to generate your own ``openssl.ld`` file. For example:: |
| 109 | |
| 110 | OPENSSL_1.0.1F_CUSTOM { |
| 111 | global: |
| 112 | *; |
| 113 | }; |
| 114 | |
| 115 | You should replace the version string on the first line as appropriate for your |
| 116 | build. |
| 117 | |
Paul Kehrer | 451c8df | 2015-07-04 11:03:27 -0500 | [diff] [blame] | 118 | Building cryptography on OS X |
| 119 | ----------------------------- |
| 120 | |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 121 | The wheel package on OS X is a statically linked build (as of 1.0.1) so for |
| 122 | users on 10.10 (Yosemite) and above you need two steps: |
Paul Kehrer | 451c8df | 2015-07-04 11:03:27 -0500 | [diff] [blame] | 123 | |
| 124 | .. code-block:: console |
| 125 | |
| 126 | $ xcode-select --install |
| 127 | |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 128 | followed by |
Paul Kehrer | 451c8df | 2015-07-04 11:03:27 -0500 | [diff] [blame] | 129 | |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 130 | .. code-block:: console |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 131 | |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 132 | $ pip install cryptography |
| 133 | |
| 134 | If you want to build cryptography yourself or are on an older OS X version |
| 135 | cryptography requires the presence of a C compiler, development headers, and |
| 136 | the proper libraries. On OS X much of this is provided by Apple's Xcode |
| 137 | development tools. To install the Xcode command line tools open a terminal |
| 138 | window and run: |
| 139 | |
| 140 | .. code-block:: console |
| 141 | |
| 142 | $ xcode-select --install |
| 143 | |
| 144 | This will install a compiler (clang) along with (most of) the required |
| 145 | development headers. |
| 146 | |
| 147 | You'll also need OpenSSL, which you can obtain from `Homebrew`_ or `MacPorts`_. |
| 148 | |
| 149 | To build cryptography and dynamically link it: |
Ayrx | 1ced5b8 | 2014-04-08 19:41:26 +0800 | [diff] [blame] | 150 | |
| 151 | `Homebrew`_ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 152 | |
| 153 | .. code-block:: console |
| 154 | |
| 155 | $ brew install openssl |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 156 | $ env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 157 | |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 158 | `MacPorts`_: |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 159 | |
| 160 | .. code-block:: console |
| 161 | |
| 162 | $ sudo port install openssl |
Paul Kehrer | 1e071ac | 2015-09-05 16:30:25 -0500 | [diff] [blame] | 163 | $ env LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography |
| 164 | |
| 165 | You can also build cryptography statically: |
| 166 | |
| 167 | `Homebrew`_ |
| 168 | |
| 169 | .. code-block:: console |
| 170 | |
| 171 | $ brew install openssl |
| 172 | $ env CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 LDFLAGS="$(brew --prefix openssl)/lib/libssl.a $(brew --prefix openssl)/lib/libcrypto.a" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography |
| 173 | |
| 174 | `MacPorts`_: |
| 175 | |
| 176 | .. code-block:: console |
| 177 | |
| 178 | $ sudo port install openssl |
| 179 | $ env CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 LDFLAGS="/opt/local/lib/libssl.a /opt/local/lib/libcrypto.a" CFLAGS="-I/opt/local/include" pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 180 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 181 | Building cryptography with conda |
| 182 | -------------------------------- |
| 183 | |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 184 | Because of a `bug in conda`_, attempting to install cryptography out of the box |
David Reid | e162e26 | 2014-05-07 16:21:00 -0700 | [diff] [blame] | 185 | will result in an error. This can be resolved by setting the library path |
| 186 | environment variable for your platform. |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame] | 187 | |
| 188 | On OS X: |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 189 | |
| 190 | .. code-block:: console |
| 191 | |
| 192 | $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 193 | |
David Reid | 18563e6 | 2014-05-07 16:20:09 -0700 | [diff] [blame] | 194 | and on Linux: |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame] | 195 | |
| 196 | .. code-block:: console |
| 197 | |
| 198 | $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 199 | |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 200 | 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] | 201 | information, consult `Greg Wilson's blog post`_ on the subject. |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 202 | |
| 203 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 204 | .. _`Homebrew`: http://brew.sh |
Alex Gaynor | 3197ab5 | 2015-10-02 06:33:11 -0700 | [diff] [blame^] | 205 | .. _`MacPorts`: https://www.macports.org |
Paul Kehrer | 6608b7e | 2015-07-24 21:52:17 +0100 | [diff] [blame] | 206 | .. _`32-bit`: https://jenkins.cryptography.io/job/openssl-win32-release/ |
| 207 | .. _`64-bit`: https://jenkins.cryptography.io/job/openssl-win64-release/ |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 208 | .. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110 |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 209 | .. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html |