Dominic Chen | 9604d9e | 2015-10-10 05:13:31 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Alex Gaynor | 5951f46 | 2014-11-16 09:08:42 -0800 | [diff] [blame] | 3 | # This file is dual licensed under the terms of the Apache License, Version |
| 4 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository |
| 5 | # for complete details. |
Alex Gaynor | c37feed | 2014-03-08 08:32:56 -0800 | [diff] [blame] | 6 | |
| 7 | from __future__ import absolute_import, division, print_function |
| 8 | |
Alex Gaynor | f51f2c1 | 2014-01-03 07:33:01 -0800 | [diff] [blame] | 9 | import os |
Terry Chia | 361545d | 2014-07-28 12:06:54 +0800 | [diff] [blame] | 10 | import platform |
Alex Stapleton | 707b008 | 2014-04-20 22:24:41 +0100 | [diff] [blame] | 11 | import sys |
Alex Stapleton | a39a319 | 2014-03-14 20:03:12 +0000 | [diff] [blame] | 12 | |
Paul Kehrer | afc1ccd | 2014-03-19 11:49:32 -0400 | [diff] [blame] | 13 | from setuptools import find_packages, setup |
Donald Stufft | 446a457 | 2013-08-11 17:38:13 -0400 | [diff] [blame] | 14 | |
Paul Kehrer | afc1ccd | 2014-03-19 11:49:32 -0400 | [diff] [blame] | 15 | |
Alex Gaynor | 7630d6c | 2014-01-03 07:34:43 -0800 | [diff] [blame] | 16 | base_dir = os.path.dirname(__file__) |
Donald Stufft | c62a78c | 2014-11-07 19:17:08 -0500 | [diff] [blame] | 17 | src_dir = os.path.join(base_dir, "src") |
| 18 | |
| 19 | # When executing the setup.py, we need to be able to import ourselves, this |
| 20 | # means that we need to add the src/ directory to the sys.path. |
| 21 | sys.path.insert(0, src_dir) |
Alex Gaynor | 7630d6c | 2014-01-03 07:34:43 -0800 | [diff] [blame] | 22 | |
Donald Stufft | 5f12a1b | 2013-08-11 16:37:43 -0400 | [diff] [blame] | 23 | about = {} |
Donald Stufft | c62a78c | 2014-11-07 19:17:08 -0500 | [diff] [blame] | 24 | with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f: |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame^] | 25 | exec (f.read(), about) |
Donald Stufft | 5f12a1b | 2013-08-11 16:37:43 -0400 | [diff] [blame] | 26 | |
| 27 | |
Alex Gaynor | 2af3d4c | 2018-07-23 13:10:13 -0400 | [diff] [blame] | 28 | # `setup_requirements` must be kept in sync with `pyproject.toml` |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame^] | 29 | setup_requirements = ["cffi>=1.12"] |
Donald Stufft | 5f12a1b | 2013-08-11 16:37:43 -0400 | [diff] [blame] | 30 | |
Paul Kehrer | 7d17cbb | 2015-08-20 13:25:15 -0500 | [diff] [blame] | 31 | if platform.python_implementation() == "PyPy": |
Paul Kehrer | 3c68250 | 2018-12-10 12:13:31 +0800 | [diff] [blame] | 32 | if sys.pypy_version_info < (5, 4): |
Paul Kehrer | 7d17cbb | 2015-08-20 13:25:15 -0500 | [diff] [blame] | 33 | raise RuntimeError( |
Paul Kehrer | 3c68250 | 2018-12-10 12:13:31 +0800 | [diff] [blame] | 34 | "cryptography is not compatible with PyPy < 5.4. Please upgrade " |
Alex Gaynor | ba45d28 | 2018-04-08 16:39:08 -0400 | [diff] [blame] | 35 | "PyPy to use this library." |
Paul Kehrer | 7d17cbb | 2015-08-20 13:25:15 -0500 | [diff] [blame] | 36 | ) |
Julian Berman | 4cf3811 | 2015-02-24 10:51:53 -0500 | [diff] [blame] | 37 | |
Peter Odding | 3ae89a5 | 2014-07-12 02:06:56 +0200 | [diff] [blame] | 38 | |
Alex Gaynor | 7630d6c | 2014-01-03 07:34:43 -0800 | [diff] [blame] | 39 | with open(os.path.join(base_dir, "README.rst")) as f: |
Alex Gaynor | f51f2c1 | 2014-01-03 07:33:01 -0800 | [diff] [blame] | 40 | long_description = f.read() |
| 41 | |
| 42 | |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame^] | 43 | try: |
| 44 | setup( |
| 45 | name=about["__title__"], |
| 46 | version=about["__version__"], |
| 47 | description=about["__summary__"], |
| 48 | long_description=long_description, |
| 49 | long_description_content_type="text/x-rst", |
| 50 | license=about["__license__"], |
| 51 | url=about["__uri__"], |
| 52 | author=about["__author__"], |
| 53 | author_email=about["__email__"], |
| 54 | classifiers=[ |
| 55 | "Development Status :: 5 - Production/Stable", |
| 56 | "Intended Audience :: Developers", |
| 57 | "License :: OSI Approved :: Apache Software License", |
| 58 | "License :: OSI Approved :: BSD License", |
| 59 | "Natural Language :: English", |
| 60 | "Operating System :: MacOS :: MacOS X", |
| 61 | "Operating System :: POSIX", |
| 62 | "Operating System :: POSIX :: BSD", |
| 63 | "Operating System :: POSIX :: Linux", |
| 64 | "Operating System :: Microsoft :: Windows", |
| 65 | "Programming Language :: Python", |
| 66 | "Programming Language :: Python :: 2", |
| 67 | "Programming Language :: Python :: 2.7", |
| 68 | "Programming Language :: Python :: 3", |
| 69 | "Programming Language :: Python :: 3.6", |
| 70 | "Programming Language :: Python :: 3.7", |
| 71 | "Programming Language :: Python :: 3.8", |
| 72 | "Programming Language :: Python :: 3.9", |
| 73 | "Programming Language :: Python :: Implementation :: CPython", |
| 74 | "Programming Language :: Python :: Implementation :: PyPy", |
| 75 | "Topic :: Security :: Cryptography", |
Paul Kehrer | e3d2fc1 | 2018-03-05 20:50:10 -0400 | [diff] [blame] | 76 | ], |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame^] | 77 | package_dir={"": "src"}, |
| 78 | packages=find_packages( |
| 79 | where="src", exclude=["_cffi_src", "_cffi_src.*"] |
| 80 | ), |
| 81 | include_package_data=True, |
| 82 | python_requires=( |
| 83 | ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*" |
| 84 | ), |
| 85 | install_requires=["six >= 1.4.1"] + setup_requirements, |
| 86 | setup_requires=setup_requirements, |
| 87 | extras_require={ |
| 88 | ":python_version < '3'": ["enum34", "ipaddress"], |
| 89 | "test": [ |
| 90 | "pytest>=3.6.0,!=3.9.0,!=3.9.1,!=3.9.2", |
| 91 | "pretend", |
| 92 | "iso8601", |
| 93 | "pytz", |
| 94 | "hypothesis>=1.11.4,!=3.79.2", |
| 95 | ], |
| 96 | "docs": [ |
| 97 | "sphinx >= 1.6.5,!=1.8.0,!=3.1.0,!=3.1.1", |
| 98 | "sphinx_rtd_theme", |
| 99 | ], |
| 100 | "docstest": [ |
| 101 | "doc8", |
| 102 | "pyenchant >= 1.6.11", |
| 103 | "twine >= 1.12.0", |
| 104 | "sphinxcontrib-spelling >= 4.0.1", |
| 105 | ], |
| 106 | "pep8test": [ |
| 107 | "black", |
| 108 | "flake8", |
| 109 | "flake8-import-order", |
| 110 | "pep8-naming", |
| 111 | ], |
| 112 | # This extra is for OpenSSH private keys that use bcrypt KDF |
| 113 | # Versions: v3.1.3 - ignore_few_rounds, v3.1.5 - abi3 |
| 114 | "ssh": ["bcrypt >= 3.1.5"], |
| 115 | }, |
| 116 | # for cffi |
| 117 | zip_safe=False, |
| 118 | ext_package="cryptography.hazmat.bindings", |
| 119 | cffi_modules=[ |
| 120 | "src/_cffi_src/build_openssl.py:ffi", |
| 121 | "src/_cffi_src/build_padding.py:ffi", |
Alex Gaynor | 9417608 | 2016-01-17 23:28:05 -0500 | [diff] [blame] | 122 | ], |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame^] | 123 | ) |
| 124 | except: # noqa: E722 |
| 125 | # Note: This is a bare exception that re-raises so that we don't interfere |
| 126 | # with anything the installation machinery might want to do. Because we |
| 127 | # print this for any exception this msg can appear (e.g. in verbose logs) |
| 128 | # even if there's no failure. For example, SetupRequirementsError is raised |
| 129 | # during PEP517 building and prints this text. setuptools raises SystemExit |
| 130 | # when compilation fails right now, but it's possible this isn't stable |
| 131 | # or a public API commitment so we'll remain ultra conservative. |
| 132 | print( |
| 133 | """ |
| 134 | =============================DEBUG ASSISTANCE============================= |
| 135 | If you are seeing a compilation error please try the following steps to |
| 136 | successfully install cryptography: |
| 137 | 1) Upgrade to the latest pip and try again. This will fix errors for most |
| 138 | users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip |
| 139 | 2) Read https://cryptography.io/en/latest/installation.html for specific |
| 140 | instructions for your platform. |
| 141 | 3) Check our frequently asked questions for more information: |
| 142 | https://cryptography.io/en/latest/faq.html |
| 143 | =============================DEBUG ASSISTANCE============================= |
| 144 | """ |
| 145 | ) |
| 146 | raise |