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