Integrate Rust into the build process properly (#5410)

This commit is contained in:
Alex Gaynor 2020-12-22 14:33:47 -05:00 committed by GitHub
parent 9108bb0a69
commit c84d6ee060
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 465 additions and 21 deletions

View file

@ -4,3 +4,10 @@ updates:
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: cargo
directory: "/src/rust/"
schedule:
interval: daily
allow:
# Also update indirect dependencies
- dependency-type: all

View file

@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
PYTHON:
- {VERSION: "3.9", TOXENV: "pep8,packaging,docs", COVERAGE: "false"}
- {VERSION: "3.9", TOXENV: "pep8,rust,packaging,docs", COVERAGE: "false"}
- {VERSION: "pypy3", TOXENV: "pypy3"}
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.0l"}}
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1i"}}
@ -26,6 +26,8 @@ jobs:
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "libressl", VERSION: "3.1.5"}}
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "libressl", VERSION: "3.2.3"}}
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "libressl", VERSION: "3.3.1"}}
RUST:
- stable
name: "${{ matrix.PYTHON.TOXENV }} ${{ matrix.PYTHON.OPENSSL.TYPE }} ${{ matrix.PYTHON.OPENSSL.VERSION }} ${{ matrix.PYTHON.OPENSSL.CONFIG_FLAGS }}"
timeout-minutes: 30
steps:
@ -34,6 +36,12 @@ jobs:
uses: actions/setup-python@v2.2.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.RUST }}
override: true
default: true
- run: git clone --depth=1 https://github.com/google/wycheproof
- run: python -m pip install tox requests coverage
- name: Compute config hash and set config vars
@ -107,10 +115,47 @@ jobs:
- run: 'tox -- --wycheproof-root="$HOME/wycheproof"'
env:
TOXENV: ${{ matrix.IMAGE.TOXENV }}
RUSTUP_HOME: /root/.rustup
- uses: ./.github/actions/upload-coverage
with:
name: "${{ matrix.IMAGE.TOXENV }} on ${{ matrix.IMAGE.IMAGE }}"
linux-rust:
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON:
- {VERSION: "3.9", TOXENV: "py39"}
RUST:
# Cover MSRV and in-dev versions
- 1.45.0
- beta
- nightly
name: "${{ matrix.PYTHON.TOXENV }} with Rust ${{ matrix.RUST }}"
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2.2.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.RUST }}
override: true
default: true
- run: git clone --depth=1 https://github.com/google/wycheproof
- run: python -m pip install tox coverage
- name: Tests
run: |
tox -r -- --color=yes --wycheproof-root=wycheproof
env:
TOXENV: ${{ matrix.PYTHON.TOXENV }}
- uses: ./.github/actions/upload-coverage
with:
name: "${{ matrix.PYTHON.TOXENV }} with Rust ${{ matrix.RUST }}"
macos:
runs-on: macos-latest
strategy:
@ -118,6 +163,8 @@ jobs:
PYTHON:
- {VERSION: "3.6", TOXENV: "py36", EXTRA_CFLAGS: ""}
- {VERSION: "3.9", TOXENV: "py39", EXTRA_CFLAGS: "-DUSE_OSRANDOM_RNG_FOR_TESTING"}
RUST:
- stable
name: "${{ matrix.PYTHON.TOXENV }} on macOS"
timeout-minutes: 30
steps:
@ -126,6 +173,12 @@ jobs:
uses: actions/setup-python@v2.2.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.RUST }}
override: true
default: true
- run: python -m pip install tox requests coverage
@ -155,11 +208,13 @@ jobs:
strategy:
matrix:
WINDOWS:
- {ARCH: 'x86', WINDOWS: 'win32'}
- {ARCH: 'x64', WINDOWS: 'win64'}
- {ARCH: 'x86', WINDOWS: 'win32', RUST_TRIPLE: 'i686-pc-windows-msvc'}
- {ARCH: 'x64', WINDOWS: 'win64', RUST_TRIPLE: 'x86_64-pc-windows-msvc'}
PYTHON:
- {VERSION: "3.6", TOXENV: "py36", MSVC_VERSION: "2019", CL_FLAGS: ""}
- {VERSION: "3.9", TOXENV: "py39", MSVC_VERSION: "2019", CL_FLAGS: "/D USE_OSRANDOM_RNG_FOR_TESTING"}
RUST:
- stable
JOB_NUMBER: [0, 1, 2, 3]
name: "${{ matrix.PYTHON.TOXENV }} on ${{ matrix.WINDOWS.WINDOWS }} (part ${{ matrix.JOB_NUMBER }})"
timeout-minutes: 30
@ -170,6 +225,13 @@ jobs:
with:
python-version: ${{ matrix.PYTHON.VERSION }}
architecture: ${{ matrix.WINDOWS.ARCH }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.RUST }}
override: true
default: true
target: ${{ matrix.WINDOWS.RUST_TRIPLE }}
- run: python -m pip install tox requests coverage
- name: Download OpenSSL
@ -203,6 +265,10 @@ jobs:
- dynamodb-encryption-sdk
- certbot
- certbot-josepy
RUST:
- stable
PYTHON:
- 3.7
name: "Downstream tests for ${{ matrix.DOWNSTREAM }}"
timeout-minutes: 30
steps:
@ -210,7 +276,13 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2.2.1
with:
python-version: 3.7
python-version: ${{ matrix.PYTHON }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.RUST }}
override: true
default: true
- run: python -m pip install -U pip wheel
- run: ./.github/downstream.d/${{ matrix.DOWNSTREAM }}.sh install
- run: pip uninstall -y enum34
@ -228,6 +300,12 @@ jobs:
uses: actions/setup-python@v2.2.1
with:
python-version: 3.9
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
default: true
- run: python -m pip install -U tox
- run: tox -r -- --color=yes
env:

View file

@ -13,8 +13,6 @@ jobs:
matrix:
PYTHON: ["cp36-cp36m"]
MANYLINUX:
- NAME: manylinux1_x86_64
CONTAINER: "cryptography-manylinux1:x86_64"
- NAME: manylinux2010_x86_64
CONTAINER: "cryptography-manylinux2010:x86_64"
- NAME: manylinux2014_x86_64
@ -23,7 +21,7 @@ jobs:
steps:
- run: /opt/python/${{ matrix.PYTHON }}/bin/python -m virtualenv .venv
- name: Install Python dependencies
run: .venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
run: .venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3' setuptools-rust"
- run: .venv/bin/pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir tmpwheelhouse
- run: |
REGEX="cp3([0-9])*"
@ -77,9 +75,15 @@ jobs:
${{ matrix.PYTHON.BIN_PATH }} .github/workflows/download_openssl.py macos openssl-macos-x86-64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
default: true
- run: ${{ matrix.PYTHON.BIN_PATH }} -m virtualenv venv
- run: venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
- run: venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3' setuptools-rust"
- run: venv/bin/pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir wheelhouse
- name: Build the wheel
run: |
@ -104,8 +108,8 @@ jobs:
strategy:
matrix:
WINDOWS:
- {ARCH: 'x86', WINDOWS: 'win32'}
- {ARCH: 'x64', WINDOWS: 'win64'}
- {ARCH: 'x86', WINDOWS: 'win32', RUST_TRIPLE: 'i686-pc-windows-msvc'}
- {ARCH: 'x64', WINDOWS: 'win64', RUST_TRIPLE: 'x86_64-pc-windows-msvc'}
PYTHON:
- {VERSION: "3.8", MSVC_VERSION: "2019", "ABI_VERSION": "cp36"}
name: "${{ matrix.PYTHON.VERSION }} ${{ matrix.WINDOWS.WINDOWS }} ${{ matrix.PYTHON.ABI_VERSION }}"
@ -116,6 +120,14 @@ jobs:
with:
python-version: ${{ matrix.PYTHON.VERSION }}
architecture: ${{ matrix.WINDOWS.ARCH }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
default: true
target: ${{ matrix.WINDOWS.RUST_TRIPLE }}
- run: pip install requests
- name: Download OpenSSL
run: |
@ -126,7 +138,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- run: python -m pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
- run: python -m pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3' setuptools-rust"
- run: pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir wheelhouse
shell: bash
- run: cd cryptography* && python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/cryptography*.whl ../wheelhouse

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ htmlcov/
.eggs/
*.py[cdo]
.hypothesis/
target/

View file

@ -49,10 +49,6 @@
nodeset: ubuntu-bionic
vars:
wheel_builds:
- platform: manylinux1_x86_64
image: ghcr.io/pyca/cryptography-manylinux1:x86_64
pythons:
- cp36-cp36m
- platform: manylinux2010_x86_64
image: ghcr.io/pyca/cryptography-manylinux2010:x86_64
pythons:

View file

@ -32,3 +32,7 @@
become: yes
when: ansible_distribution == 'CentOS'
- name: Install rust
include_role:
name: ensure-rust

View file

@ -11,7 +11,7 @@ for P in ${PYTHONS}; do
"${PYBIN}"/python -m virtualenv .venv
.venv/bin/pip install cffi six ipaddress "enum34; python_version < '3'"
.venv/bin/pip install cffi six ipaddress "enum34; python_version < '3'" setuptools-rust
REGEX="cp3([0-9])*"
if [[ "${PYBIN}" =~ $REGEX ]]; then

View file

@ -23,6 +23,15 @@
become: yes
when: ansible_distribution in ['Debian', 'Ubuntu']
- name: Install rust
include_role:
name: ensure-rust
- name: Install setuptools-rust
pip:
name: setuptools-rust
become: yes
- name: Create sdist
command: |
python3 setup.py sdist

View file

@ -1,14 +1,19 @@
Changelog
=========
.. _v3-4:
3.4 - `master`_
~~~~~~~~~~~~~~~
.. note:: This version is not yet released and is under active development.
* **BACKWARDS INCOMPATIBLE:** Support for Python 2 has been removed.
* We now ship ``manylinux2014`` wheels in addition to our ``manylinux1`` and
``manylinux2010`` wheels.
* We now ship ``manylinux2014`` wheels, and no longer ship ``manylinux1``
wheels.
* ``cryptography`` now incorporates Rust code. Users building ``cryptography``
themselves will need to have the Rust toolchain installed, users who use an
officially produced wheel will not need to make any changes.
.. _v3-3-1:

View file

@ -10,6 +10,7 @@ include pyproject.toml
recursive-include docs *
recursive-include src/_cffi_src *.py *.c *.h
recursive-include src/rust Cargo.toml Cargo.lock *.rs
prune docs/_build
recursive-include tests *.py
exclude vectors

View file

@ -44,6 +44,7 @@ sys.path.insert(0, os.path.abspath("."))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
@ -198,3 +199,5 @@ linkcheck_ignore = [
# Inconsistent small DH params they seem incapable of fixing
r"https://www.secg.org/sec1-v2.pdf",
]
autosectionlabel_prefix_document = True

View file

@ -117,6 +117,19 @@ upstream, ``cryptography`` is also dropping support for them. To fix this issue
you should upgrade to a newer version of OpenSSL (1.1.0 or later). This may
require you to upgrade to a newer operating system.
Installing ``cryptography`` fails with ``error: Can not find Rust compiler``
----------------------------------------------------------------------------
Building ``cryptography`` from source requires you have :ref:`Rust installed
and available<installation:Rust>` on your ``PATH``. You may be able to fix this
by upgrading to a newer version of ``pip`` which will install a pre-compiled
``cryptography`` wheel. If not, you'll need to install Rust.
For the current release *only* you can temporarily bypass the requirement to
have Rust installed by setting the ``CRYPTOGRAPHY_DONT_BUILD_RUST`` environment
variable. Note that this option will be removed in the next release and not
having Rust available will be a hard error.
Why are there no wheels for my Python3.x version?
-------------------------------------------------

View file

@ -61,6 +61,9 @@ platforms). ``cryptography`` links against the new 1.1.0 names by default. If
you need to compile ``cryptography`` against an older version then you **must**
set ``CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL`` or else installation will fail.
You will also need to have :ref:`Rust installed and
available<installation:Rust>`.
If you need to rebuild ``cryptography`` for any reason be sure to clear the
local `wheel cache`_.
@ -70,7 +73,7 @@ Building cryptography on Linux
------------------------------
``cryptography`` ships ``manylinux`` wheels (as of 2.0) so all dependencies
are included. For users on pip 8.1 or above running on a ``manylinux1`` (or
are included. For users on pip 19.0 or above running on a ``manylinux2010`` (or
greater) compatible distribution (almost everything except Alpine) all you
should need to do is:
@ -83,6 +86,9 @@ If you are on Alpine or just want to compile it yourself then
using ``pypy``), and headers for the OpenSSL and ``libffi`` libraries
available on your system.
On all Linux distributions you will need to have :ref:`Rust installed and
available<installation:Rust>`.
Alpine
~~~~~~
@ -229,6 +235,9 @@ open a terminal window and run:
This will install a compiler (clang) along with (most of) the required
development headers.
You will also need to have :ref:`Rust installed and
available<installation:Rust>`.
You'll also need OpenSSL, which you can obtain from `Homebrew`_ or `MacPorts`_.
Cryptography does **not** support Apple's deprecated OpenSSL distribution.
@ -267,6 +276,13 @@ You can also build cryptography statically:
If you need to rebuild ``cryptography`` for any reason be sure to clear the
local `wheel cache`_.
Rust
----
Building ``cryptography`` requires having a working Rust toolchain. The current
minimum supported Rust version is 1.45.0.
Instructions for installing Rust can be found on `the Rust Project's website`_.
.. _`Homebrew`: https://brew.sh
.. _`MacPorts`: https://www.macports.org
@ -274,3 +290,4 @@ local `wheel cache`_.
.. _virtualenv: https://virtualenv.pypa.io/en/latest/
.. _openssl.org: https://www.openssl.org/source/
.. _`wheel cache`: https://pip.pypa.io/en/stable/reference/pip_install/#caching
.. _`the Rust Project's website`: https://www.rust-lang.org/tools/install

View file

@ -106,6 +106,7 @@ testability
Thawte
timestamp
timestamps
toolchain
tunable
Ubuntu
unencrypted

View file

@ -6,6 +6,7 @@ requires = [
"wheel",
# Must be kept in sync with the `setup_requirements` in `setup.py`
"cffi>=1.12; platform_python_implementation != 'PyPy'",
"setuptools-rust>=0.11.4",
]
build-backend = "setuptools.build_meta"

View file

@ -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=============================
"""
)

241
src/rust/Cargo.lock generated Normal file
View file

@ -0,0 +1,241 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cryptography-rust"
version = "0.1.0"
dependencies = [
"pyo3",
]
[[package]]
name = "ctor"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "ghost"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5bcf1bbeab73aa4cf2fde60a846858dc036163c7c33bec309f8d17de785479"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "indoc"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5a75aeaaef0ce18b58056d306c27b07436fbb34b8816c53094b76dd81803136"
dependencies = [
"unindent",
]
[[package]]
name = "instant"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
"cfg-if",
]
[[package]]
name = "inventory"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f0f7efb804ec95e33db9ad49e4252f049e37e8b0a4652e3cd61f7999f2eff7f"
dependencies = [
"ctor",
"ghost",
"inventory-impl",
]
[[package]]
name = "inventory-impl"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75c094e94816723ab936484666968f5b58060492e880f3c8d00489a1e244fa51"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "libc"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
[[package]]
name = "lock_api"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312"
dependencies = [
"scopeguard",
]
[[package]]
name = "parking_lot"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi",
]
[[package]]
name = "paste"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1"
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "pyo3"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdd01a4c2719dd1f3ceab0875fa1a2c2cd3c619477349d78f43cd716b345436"
dependencies = [
"cfg-if",
"ctor",
"indoc",
"inventory",
"libc",
"parking_lot",
"paste",
"pyo3-macros",
"unindent",
]
[[package]]
name = "pyo3-macros"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f8218769d13e354f841d559a19b0cf22cfd55959c7046ef594e5f34dbe46d16"
dependencies = [
"pyo3-macros-backend",
"quote",
"syn",
]
[[package]]
name = "pyo3-macros-backend"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc4da0bfdf76f0a5971c698f2cb6b3f832a6f80f16dedeeb3f123eb0431ecce2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "smallvec"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
[[package]]
name = "syn"
version = "1.0.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "unindent"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

16
src/rust/Cargo.toml Normal file
View file

@ -0,0 +1,16 @@
[package]
name = "cryptography-rust"
version = "0.1.0"
authors = ["The cryptography developers <cryptography-dev@python.org>"]
edition = "2018"
publish = false
[dependencies]
pyo3 = { version = "0.13.0", features = ["extension-module"] }
[lib]
name = "cryptography_rust"
crate-type = ["cdylib"]
[profile.release]
lto = "thin"

8
src/rust/src/lib.rs Normal file
View file

@ -0,0 +1,8 @@
// This file is dual licensed under the terms of the Apache License, Version
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.
#[pyo3::prelude::pymodule]
fn _rust(_py: pyo3::Python<'_>, _m: &pyo3::types::PyModule) -> pyo3::PyResult<()> {
Ok(())
}

11
tox.ini
View file

@ -1,6 +1,6 @@
[tox]
minversion = 2.4
envlist = pypy3,py36,py37,py38,py39,docs,pep8,packaging
envlist = pypy3,py36,py37,py38,py39,docs,pep8,rust,packaging
isolated_build = True
[testenv]
@ -45,6 +45,15 @@ commands =
flake8 .
black --check .
[testenv:rust]
basepython = python3
changedir = src/rust/
allowlist_externals =
cargo
commands =
cargo fmt --all -- --check
cargo clippy -- -D warnings
[testenv:packaging]
deps =
check-manifest