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 | 73667de | 2014-07-14 12:33:27 -0500 | [diff] [blame] | 16 | * x86-64 CentOS 7.x, 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`` |
Paul Kehrer | e683dee | 2014-08-09 08:15:23 -1000 | [diff] [blame] | 31 | * ``OpenSSL 1.0.1e-fips`` (``RHEL/CentOS 7``) |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 32 | * ``OpenSSL 1.0.1e-freebsd`` |
Paul Kehrer | 73667de | 2014-07-14 12:33:27 -0500 | [diff] [blame] | 33 | * ``OpenSSL 1.0.1h`` |
Paul Kehrer | fb8dcdb | 2014-04-20 19:25:18 -0500 | [diff] [blame] | 34 | * ``OpenSSL 1.0.2 beta`` |
| 35 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 36 | On Windows |
| 37 | ---------- |
Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame] | 38 | |
Paul Kehrer | 156360a | 2014-06-30 12:14:01 -0600 | [diff] [blame] | 39 | The wheel package on Windows is a statically linked build (as of 0.5) so all |
| 40 | dependencies are included. Just run |
| 41 | |
| 42 | .. code-block:: console |
| 43 | |
| 44 | $ pip install cryptography |
| 45 | |
| 46 | If you prefer to compile it yourself you'll need to have OpenSSL installed. |
| 47 | There are `pre-compiled binaries`_ available. If your installation is in an |
| 48 | unusual location set the ``LIB`` and ``INCLUDE`` environment variables to |
Paul Kehrer | 2a39f7f | 2014-07-02 22:56:01 -0500 | [diff] [blame] | 49 | include the corresponding locations.For example: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 50 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 51 | .. code-block:: console |
| 52 | |
| 53 | C:\> \path\to\vcvarsall.bat x86_amd64 |
Paul Kehrer | 2a39f7f | 2014-07-02 22:56:01 -0500 | [diff] [blame] | 54 | C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB% |
| 55 | C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE% |
| 56 | C:\> pip install cryptography |
| 57 | |
| 58 | You can also choose to build statically or dynamically using the |
Paul Kehrer | 419e67a | 2014-07-05 11:15:55 -0500 | [diff] [blame] | 59 | ``PYCA_WINDOWS_LINK_TYPE`` variable. Allowed values are ``static`` (default) |
| 60 | and ``dynamic``. |
Paul Kehrer | 2a39f7f | 2014-07-02 22:56:01 -0500 | [diff] [blame] | 61 | |
| 62 | .. code-block:: console |
| 63 | |
| 64 | C:\> \path\to\vcvarsall.bat x86_amd64 |
| 65 | C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB% |
| 66 | C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE% |
Paul Kehrer | 419e67a | 2014-07-05 11:15:55 -0500 | [diff] [blame] | 67 | C:\> set PYCA_WINDOWS_LINK_TYPE=dynamic |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 68 | C:\> pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 69 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 70 | Building cryptography on Linux |
| 71 | ------------------------------ |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 72 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 73 | ``cryptography`` should build very easily on Linux provided you have a C |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 74 | compiler, headers for Python (if you're not using ``pypy``), and headers for |
| 75 | the OpenSSL and ``libffi`` libraries available on your system. |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 76 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 77 | For Debian and Ubuntu, the following command will ensure that the required |
Chris Glass | f82d94f | 2014-02-13 11:46:49 +0100 | [diff] [blame] | 78 | dependencies are installed: |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 79 | |
| 80 | .. code-block:: console |
| 81 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 82 | $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 83 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 84 | For Fedora and RHEL-derivatives, the following command will ensure that the |
| 85 | required dependencies are installed: |
Ayrx | a674c6b | 2014-02-15 21:24:23 +0800 | [diff] [blame] | 86 | |
| 87 | .. code-block:: console |
| 88 | |
| 89 | $ sudo yum install gcc libffi-devel python-devel openssl-devel |
| 90 | |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 91 | You should now be able to build and install cryptography with the usual |
| 92 | |
| 93 | .. code-block:: console |
| 94 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 95 | $ pip install cryptography |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 96 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 97 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 98 | Using your own OpenSSL on Linux |
| 99 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 100 | |
| 101 | Python links to OpenSSL for its own purposes and this can sometimes cause |
| 102 | problems when you wish to use a different version of OpenSSL with cryptography. |
| 103 | If you want to use cryptography with your own build of OpenSSL you will need to |
| 104 | make sure that the build is configured correctly so that your version of |
| 105 | OpenSSL doesn't conflict with Python's. |
| 106 | |
| 107 | The options you need to add allow the linker to identify every symbol correctly |
| 108 | even when multiple versions of the library are linked into the same program. If |
| 109 | you are using your distribution's source packages these will probably be |
| 110 | patched in for you already, otherwise you'll need to use options something like |
| 111 | this when configuring OpenSSL: |
| 112 | |
| 113 | .. code-block:: console |
| 114 | |
| 115 | $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared |
| 116 | |
| 117 | You'll also need to generate your own ``openssl.ld`` file. For example:: |
| 118 | |
| 119 | OPENSSL_1.0.1F_CUSTOM { |
| 120 | global: |
| 121 | *; |
| 122 | }; |
| 123 | |
| 124 | You should replace the version string on the first line as appropriate for your |
| 125 | build. |
| 126 | |
| 127 | Using your own OpenSSL on OS X |
| 128 | ------------------------------ |
| 129 | |
| 130 | To link cryptography against a custom version of OpenSSL you'll need to set |
Alex Gaynor | f244150 | 2014-05-17 20:09:33 -0700 | [diff] [blame] | 131 | ``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via |
| 132 | `Homebrew`_ or `MacPorts`_: |
Ayrx | 1ced5b8 | 2014-04-08 19:41:26 +0800 | [diff] [blame] | 133 | |
| 134 | `Homebrew`_ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 135 | |
| 136 | .. code-block:: console |
| 137 | |
| 138 | $ brew install openssl |
Ayrx | 1ced5b8 | 2014-04-08 19:41:26 +0800 | [diff] [blame] | 139 | $ 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] | 140 | |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 141 | or `MacPorts`_: |
| 142 | |
| 143 | .. code-block:: console |
| 144 | |
| 145 | $ sudo port install openssl |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 146 | $ 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] | 147 | |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 148 | Building cryptography with conda |
| 149 | -------------------------------- |
| 150 | |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 151 | 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] | 152 | will result in an error. This can be resolved by setting the library path |
| 153 | environment variable for your platform. |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame] | 154 | |
| 155 | On OS X: |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 156 | |
| 157 | .. code-block:: console |
| 158 | |
| 159 | $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 160 | |
David Reid | 18563e6 | 2014-05-07 16:20:09 -0700 | [diff] [blame] | 161 | and on Linux: |
David Reid | e43861d | 2014-05-07 16:19:08 -0700 | [diff] [blame] | 162 | |
| 163 | .. code-block:: console |
| 164 | |
| 165 | $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography |
| 166 | |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 167 | 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] | 168 | information, consult `Greg Wilson's blog post`_ on the subject. |
Alex Gaynor | eb50a2c | 2014-05-02 09:38:33 -0700 | [diff] [blame] | 169 | |
| 170 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 171 | .. _`Homebrew`: http://brew.sh |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame] | 172 | .. _`MacPorts`: http://www.macports.org |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 173 | .. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html |
Alex Gaynor | d694838 | 2014-05-02 14:10:14 -0700 | [diff] [blame] | 174 | .. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110 |
Alex Gaynor | d8fc257 | 2014-05-02 10:33:36 -0700 | [diff] [blame] | 175 | .. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html |