diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2541ddd9e543..5dd139355777 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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) }} @@ -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 @@ -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: diff --git a/noxfile.py b/noxfile.py index a8b10a6fbf25..05cfdd70abf0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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 @@ -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)