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