setup.py 5.4 KB

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