diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2020-12-22 14:33:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-22 13:33:47 -0600 |
commit | c84d6ee0605645a24fd93c436967ee2519aa586a (patch) | |
tree | 9e8a5935bc099a0ef87431673dcb1d8cb2df39ad /setup.py | |
parent | 9108bb0a69ea850b9943c2b27623cfe50c15d068 (diff) | |
download | cryptography-c84d6ee0605645a24fd93c436967ee2519aa586a.tar.gz |
Integrate Rust into the build process properly (#5410)
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -5,10 +5,13 @@ # for complete details. import os +import platform import sys from setuptools import find_packages, setup +from setuptools_rust import RustExtension + base_dir = os.path.dirname(__file__) src_dir = os.path.join(base_dir, "src") @@ -23,7 +26,24 @@ with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f: # `setup_requirements` must be kept in sync with `pyproject.toml` -setup_requirements = ["cffi>=1.12"] +setup_requirements = ["cffi>=1.12", "setuptools-rust>=0.11.4"] + +if os.environ.get("CRYPTOGRAPHY_DONT_BUILD_RUST"): + rust_extensions = [] +else: + rust_extensions = [ + RustExtension( + "_rust", + "src/rust/Cargo.toml", + py_limited_api=True, + # Enable abi3 mode if we're not using PyPy. + features=( + [] + if platform.python_implementation() == "PyPy" + else ["pyo3/abi3-py36"] + ), + ) + ] with open(os.path.join(base_dir, "README.rst")) as f: long_description = f.read() @@ -108,6 +128,7 @@ try: "src/_cffi_src/build_openssl.py:ffi", "src/_cffi_src/build_padding.py:ffi", ], + rust_extensions=rust_extensions, ) except: # noqa: E722 # Note: This is a bare exception that re-raises so that we don't interfere @@ -128,6 +149,7 @@ except: # noqa: E722 instructions for your platform. 3) Check our frequently asked questions for more information: https://cryptography.io/en/latest/faq.html + 4) Ensure you have a recent Rust toolchain installed. =============================DEBUG ASSISTANCE============================= """ ) |