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 Stapleton | bd0c7a6 | 2014-03-15 18:08:21 +0000 | [diff] [blame] | 13 | Currently we test ``cryptography`` on Python 2.6, 2.7, 3.2, 3.3 and PyPy on |
| 14 | these operating systems. |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 15 | |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 16 | * x86-64 CentOS 6.4 and CentOS 5 |
| 17 | * x86-64 FreeBSD 9.2 and FreeBSD 10 |
Alex Stapleton | 13432b2 | 2014-03-15 19:18:16 +0000 | [diff] [blame] | 18 | * OS X 10.9 and OS X 10.8 |
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 |
Alex Stapleton | b468417 | 2014-03-15 18:02:13 +0000 | [diff] [blame] | 21 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 22 | On Windows |
| 23 | ---------- |
Alex Gaynor | 84d5c6b | 2014-02-02 10:12:34 -0800 | [diff] [blame] | 24 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 25 | If you're on Windows you'll need to make sure you have OpenSSL installed. |
| 26 | There are `pre-compiled binaries`_ available. If your installation is in |
| 27 | an unusual location set the ``LIB`` and ``INCLUDE`` environment variables |
| 28 | to include the corresponding locations. For example: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 29 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 30 | .. code-block:: console |
| 31 | |
| 32 | C:\> \path\to\vcvarsall.bat x86_amd64 |
| 33 | C:\> set LIB=C:\OpenSSL-1.0.1f-64bit\lib;%LIB% |
| 34 | C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE% |
| 35 | C:\> pip install cryptography |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 36 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 37 | Building cryptography on Linux |
| 38 | ------------------------------ |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 39 | |
Chris Glass | 2e15c7f | 2014-02-13 19:10:10 +0100 | [diff] [blame] | 40 | ``cryptography`` should build very easily on Linux provided you have a C |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 41 | compiler, headers for Python (if you're not using ``pypy``), and headers for |
| 42 | the OpenSSL and ``libffi`` libraries available on your system. |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 43 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 44 | For Debian and Ubuntu, the following command will ensure that the required |
Chris Glass | f82d94f | 2014-02-13 11:46:49 +0100 | [diff] [blame] | 45 | dependencies are installed: |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 46 | |
| 47 | .. code-block:: console |
| 48 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 49 | $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 50 | |
Ayrx | d9702f9 | 2014-02-15 23:57:13 +0800 | [diff] [blame] | 51 | For Fedora and RHEL-derivatives, the following command will ensure that the |
| 52 | required dependencies are installed: |
Ayrx | a674c6b | 2014-02-15 21:24:23 +0800 | [diff] [blame] | 53 | |
| 54 | .. code-block:: console |
| 55 | |
| 56 | $ sudo yum install gcc libffi-devel python-devel openssl-devel |
| 57 | |
Chris Glass | 87c4edb | 2014-02-13 09:34:21 +0100 | [diff] [blame] | 58 | You should now be able to build and install cryptography with the usual |
| 59 | |
| 60 | .. code-block:: console |
| 61 | |
Alex Gaynor | 4992384 | 2014-02-13 10:32:56 -0800 | [diff] [blame] | 62 | $ pip install cryptography |
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 | Using your own OpenSSL on Linux |
| 65 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 66 | |
| 67 | Python links to OpenSSL for its own purposes and this can sometimes cause |
| 68 | problems when you wish to use a different version of OpenSSL with cryptography. |
| 69 | If you want to use cryptography with your own build of OpenSSL you will need to |
| 70 | make sure that the build is configured correctly so that your version of |
| 71 | OpenSSL doesn't conflict with Python's. |
| 72 | |
| 73 | The options you need to add allow the linker to identify every symbol correctly |
| 74 | even when multiple versions of the library are linked into the same program. If |
| 75 | you are using your distribution's source packages these will probably be |
| 76 | patched in for you already, otherwise you'll need to use options something like |
| 77 | this when configuring OpenSSL: |
| 78 | |
| 79 | .. code-block:: console |
| 80 | |
| 81 | $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared |
| 82 | |
| 83 | You'll also need to generate your own ``openssl.ld`` file. For example:: |
| 84 | |
| 85 | OPENSSL_1.0.1F_CUSTOM { |
| 86 | global: |
| 87 | *; |
| 88 | }; |
| 89 | |
| 90 | You should replace the version string on the first line as appropriate for your |
| 91 | build. |
| 92 | |
| 93 | Using your own OpenSSL on OS X |
| 94 | ------------------------------ |
| 95 | |
| 96 | To link cryptography against a custom version of OpenSSL you'll need to set |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame^] | 97 | ``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via `Homebrew`_: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 98 | |
| 99 | .. code-block:: console |
| 100 | |
| 101 | $ brew install openssl |
| 102 | |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame^] | 103 | or `MacPorts`_: |
| 104 | |
| 105 | .. code-block:: console |
| 106 | |
| 107 | $ sudo port install openssl |
| 108 | |
| 109 | |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 110 | Then install cryptography linking against the brewed version: |
| 111 | |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame^] | 112 | on `Homebrew`_: |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 113 | .. code-block:: console |
| 114 | |
| 115 | $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography |
| 116 | |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame^] | 117 | on `MacPorts`_: |
| 118 | .. code-block:: console |
| 119 | |
| 120 | $ 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] | 121 | |
| 122 | .. _`Homebrew`: http://brew.sh |
Kimmo Parviainen-Jalanko | e01e0bf | 2014-03-19 18:57:09 +0200 | [diff] [blame^] | 123 | .. _`MacPorts`: http://www.macports.org |
skeuomorf | bc26efb | 2014-01-29 08:31:47 +0200 | [diff] [blame] | 124 | .. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html |