Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify noxfile interaction with pyproject.toml #9807

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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
Expand Down Expand Up @@ -196,7 +196,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) }}
Expand Down Expand Up @@ -247,7 +247,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
Expand Down Expand Up @@ -310,7 +310,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:
Expand Down
32 changes: 18 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

import nox

try:
import tomllib
except ImportError:
import tomli as tomllib # type: ignore[import-not-found,no-redef]

nox.options.reuse_existing_virtualenvs = True


Expand All @@ -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")
Expand Down Expand Up @@ -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/")

Expand Down Expand Up @@ -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)
Expand Down
Loading