Skip to content

Commit

Permalink
Migrate a bit more logic to pyproject.toml (#9489)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Aug 23, 2023
1 parent 2879af1 commit afc06e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ requires = [
"wheel",
# Must be kept in sync with `project.dependencies`
"cffi>=1.12; platform_python_implementation != 'PyPy'",
"setuptools-rust>=0.11.4",
"setuptools-rust>=1.7.0",
]
build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -81,6 +81,13 @@ docstest = ["pyenchant >=1.6.11", "twine >=1.12.0", "sphinxcontrib-spelling >=4
sdist = ["build"]
pep8test = ["black", "ruff", "mypy", "check-sdist"]

[[tool.setuptools-rust.ext-modules]]
target = "cryptography.hazmat.bindings._rust"
path = "src/rust/Cargo.toml"
py-limited-api = true
rust-version = ">=1.63.0"


[tool.black]
line-length = 79
target-version = ["py37"]
Expand Down
30 changes: 2 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@

from setuptools import setup

try:
from setuptools_rust import RustExtension
except ImportError:
print(
"""
=============================DEBUG ASSISTANCE==========================
If you are seeing an error here please try the following to
successfully install cryptography:
Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
=============================DEBUG ASSISTANCE==========================
"""
)
raise


# distutils emits this warning if you pass `setup()` an unknown option. This
# is what happens if you somehow run this file without `cffi` installed:
# `cffi_modules` is an unknown option.
Expand All @@ -47,17 +30,8 @@
raise RuntimeError("cryptography is not compatible with PyPy3 < 7.3.10")

try:
# See pyproject.toml for most of the config metadata.
setup(
rust_extensions=[
RustExtension(
"cryptography.hazmat.bindings._rust",
"src/rust/Cargo.toml",
py_limited_api=True,
rust_version=">=1.63.0",
)
],
)
# See pyproject.toml for the config metadata.
setup()
except:
# Note: This is a bare exception that re-raises so that we don't interfere
# with anything the installation machinery might want to do. Because we
Expand Down

0 comments on commit afc06e2

Please sign in to comment.