mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
Simplify noxfile interaction with pyproject.toml (#9807)
This commit is contained in:
parent
0dc5a80d2d
commit
fcc2bba8a0
2 changed files with 22 additions and 18 deletions
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
|
@ -124,7 +124,7 @@ jobs:
|
|||
# pypy3-3.8 and pypy3-3.9 -- both of them show up as 7.3.11.
|
||||
key: ${{ matrix.PYTHON.VERSION }}-${{ steps.setup-python.outputs.python-version }}-${{ matrix.PYTHON.NOXSESSION }}-${{ env.OPENSSL_HASH }}
|
||||
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt 'nox'
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt 'nox' 'tomli; python_version < "3.11"'
|
||||
- name: Create nox environment
|
||||
run: |
|
||||
nox -v --install-only
|
||||
|
|
@ -198,7 +198,7 @@ jobs:
|
|||
- run: |
|
||||
echo "OPENSSL_FORCE_FIPS_MODE=1" >> $GITHUB_ENV
|
||||
if: matrix.IMAGE.FIPS
|
||||
- run: /venv/bin/python -m pip install -c ci-constraints-requirements.txt 'nox'
|
||||
- run: /venv/bin/python -m pip install -c ci-constraints-requirements.txt 'nox' 'tomli; python_version < "3.11"'
|
||||
- run: '/venv/bin/nox -v --install-only'
|
||||
env:
|
||||
CARGO_TARGET_DIR: ${{ format('{0}/src/rust/target/', github.workspace) }}
|
||||
|
|
@ -249,7 +249,7 @@ jobs:
|
|||
cache-dependency-path: ci-constraints-requirements.txt
|
||||
- run: rustup component add llvm-tools-preview
|
||||
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt 'nox'
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt 'nox' 'tomli; python_version < "3.11"'
|
||||
|
||||
- name: Clone wycheproof
|
||||
timeout-minutes: 2
|
||||
|
|
@ -312,7 +312,7 @@ jobs:
|
|||
timeout-minutes: 2
|
||||
with:
|
||||
key: ${{ matrix.PYTHON.NOXSESSION }}-${{ matrix.WINDOWS.ARCH }}-${{ steps.setup-python.outputs.python-version }}
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt "nox"
|
||||
- run: python -m pip install -c ci-constraints-requirements.txt "nox" "tomli; python_version < '3.11'"
|
||||
|
||||
- uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0
|
||||
with:
|
||||
|
|
|
|||
32
noxfile.py
32
noxfile.py
|
|
@ -14,6 +14,11 @@ import uuid
|
|||
|
||||
import nox
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ImportError:
|
||||
import tomli as tomllib # type: ignore[import-not-found,no-redef]
|
||||
|
||||
nox.options.reuse_existing_virtualenvs = True
|
||||
|
||||
|
||||
|
|
@ -27,6 +32,11 @@ def install(session: nox.Session, *args: str) -> None:
|
|||
)
|
||||
|
||||
|
||||
def load_pyproject_toml() -> dict:
|
||||
with (pathlib.Path(__file__).parent / "pyproject.toml").open("rb") as f:
|
||||
return tomllib.load(f)
|
||||
|
||||
|
||||
@nox.session
|
||||
@nox.session(name="tests-ssh")
|
||||
@nox.session(name="tests-randomorder")
|
||||
|
|
@ -152,22 +162,16 @@ def docs_linkcheck(session: nox.Session) -> None:
|
|||
|
||||
@nox.session
|
||||
def flake(session: nox.Session) -> None:
|
||||
# Just install the dependencies needed for these tests - basically
|
||||
# `pip install .[pep8test,test,ssh,nox]`, but without installing `.`
|
||||
# TODO: Ideally there'd be a pip flag to install just our dependencies,
|
||||
# but not install us.
|
||||
pyproject_data = load_pyproject_toml()
|
||||
install(
|
||||
session,
|
||||
"setuptools-rust",
|
||||
"cffi>=1.12; platform_python_implementation != 'PyPy'",
|
||||
"wheel",
|
||||
"ruff",
|
||||
"check-sdist",
|
||||
"mypy",
|
||||
"bcrypt",
|
||||
"click",
|
||||
"pytest",
|
||||
"nox",
|
||||
*pyproject_data["build-system"]["requires"],
|
||||
*pyproject_data["project"]["optional-dependencies"]["pep8test"],
|
||||
*pyproject_data["project"]["optional-dependencies"]["test"],
|
||||
*pyproject_data["project"]["optional-dependencies"]["ssh"],
|
||||
*pyproject_data["project"]["optional-dependencies"]["nox"],
|
||||
)
|
||||
install(session, "-e", "vectors/")
|
||||
|
||||
|
|
@ -198,10 +202,10 @@ def rust(session: nox.Session) -> None:
|
|||
}
|
||||
)
|
||||
|
||||
# Just install the dependencies needed for the Rust build.rs
|
||||
# TODO: Ideally there'd be a pip flag to install just our dependencies,
|
||||
# but not install us.
|
||||
install(session, "cffi", "setuptools")
|
||||
pyproject_data = load_pyproject_toml()
|
||||
install(session, *pyproject_data["build-system"]["requires"])
|
||||
|
||||
with session.chdir("src/rust/"):
|
||||
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue