blob: 4ebbc1b502032d99b42922d3554d62b5c9e83e70 [file] [log] [blame]
Dominic Chen9604d9e2015-10-10 05:13:31 +00001#!/usr/bin/env python
2
Alex Gaynor5951f462014-11-16 09:08:42 -08003# 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 Gaynorc37feed2014-03-08 08:32:56 -08006
7from __future__ import absolute_import, division, print_function
8
Alex Gaynorf51f2c12014-01-03 07:33:01 -08009import os
Terry Chia361545d2014-07-28 12:06:54 +080010import platform
Alex Stapleton707b0082014-04-20 22:24:41 +010011import sys
Alex Stapletona39a3192014-03-14 20:03:12 +000012
Paul Kehrerafc1ccd2014-03-19 11:49:32 -040013from setuptools import find_packages, setup
Donald Stufft446a4572013-08-11 17:38:13 -040014
Paul Kehrerafc1ccd2014-03-19 11:49:32 -040015
Alex Gaynor7630d6c2014-01-03 07:34:43 -080016base_dir = os.path.dirname(__file__)
Donald Stufftc62a78c2014-11-07 19:17:08 -050017src_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.
21sys.path.insert(0, src_dir)
Alex Gaynor7630d6c2014-01-03 07:34:43 -080022
Donald Stufft5f12a1b2013-08-11 16:37:43 -040023about = {}
Donald Stufftc62a78c2014-11-07 19:17:08 -050024with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f:
Lucia Lic6ba99d2021-11-08 22:06:11 +080025 exec (f.read(), about)
Donald Stufft5f12a1b2013-08-11 16:37:43 -040026
27
Alex Gaynor2af3d4c2018-07-23 13:10:13 -040028# `setup_requirements` must be kept in sync with `pyproject.toml`
Lucia Lic6ba99d2021-11-08 22:06:11 +080029setup_requirements = ["cffi>=1.12"]
Donald Stufft5f12a1b2013-08-11 16:37:43 -040030
Paul Kehrer7d17cbb2015-08-20 13:25:15 -050031if platform.python_implementation() == "PyPy":
Paul Kehrer3c682502018-12-10 12:13:31 +080032 if sys.pypy_version_info < (5, 4):
Paul Kehrer7d17cbb2015-08-20 13:25:15 -050033 raise RuntimeError(
Paul Kehrer3c682502018-12-10 12:13:31 +080034 "cryptography is not compatible with PyPy < 5.4. Please upgrade "
Alex Gaynorba45d282018-04-08 16:39:08 -040035 "PyPy to use this library."
Paul Kehrer7d17cbb2015-08-20 13:25:15 -050036 )
Julian Berman4cf38112015-02-24 10:51:53 -050037
Peter Odding3ae89a52014-07-12 02:06:56 +020038
Alex Gaynor7630d6c2014-01-03 07:34:43 -080039with open(os.path.join(base_dir, "README.rst")) as f:
Alex Gaynorf51f2c12014-01-03 07:33:01 -080040 long_description = f.read()
41
42
Lucia Lic6ba99d2021-11-08 22:06:11 +080043try:
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 Kehrere3d2fc12018-03-05 20:50:10 -040076 ],
Lucia Lic6ba99d2021-11-08 22:06:11 +080077 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 Gaynor94176082016-01-17 23:28:05 -0500122 ],
Lucia Lic6ba99d2021-11-08 22:06:11 +0800123 )
124except: # 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