From cc7181e7de500e5acf8277c6b7abcf1946bbb6bb Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 30 Jul 2025 09:30:51 +0200 Subject: [PATCH] Use dependency groups (#94) * Use dependency groups * Ensure dev env contains pytest * Doesn't work * Use dep group in dev env * update ruff --- .github/CONTRIBUTING.md | 10 +++++----- .github/workflows/ci.yml | 5 ++++- .pre-commit-config.yaml | 2 +- pyproject.toml | 11 ++++++----- tox.ini | 11 ++--------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d66fc73..1ffd801 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -69,14 +69,14 @@ $ git submodule update # update the vendored Argon2 C library to the version w Now an editable version of *argon2-cffi-bindings* along with its test requirements can be installed as usual: ```console -$ python -Im pip install --upgrade pip setuptools cffi # PLEASE don't skip this step -$ python -Im pip install -e '.[dev]' +$ python -Im pip install --upgrade pip # PLEASE don't skip this step +$ python -Im pip install -e . --group dev ``` At this point, ```console -$ python -m pytest +$ python -Im pytest ``` should work and pass. @@ -99,8 +99,8 @@ You can also run them anytime (as our tox does) using: $ pre-commit run --all-files ``` -[^dev]: *pre-commit* should have been installed into your virtualenv automatically when you ran `pip install -e '.[dev]'` above. - If *pre-commit* is missing, your probably need to run `pip install -e '.[dev]'` again. +[^dev]: *pre-commit* should have been installed into your virtualenv automatically when you ran `python -Im pip install -e . --group dev` above. + If *pre-commit* is missing, your probably need to run `python -Im pip install -e . --group dev` again. ## Code diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0b2a8f..efc0601 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version-file: .python-version-default - - run: python -Im pip install -e .[dev] + - run: python -Im pip install -e . --group dev - name: Import package run: python -c 'from _argon2_cffi_bindings import ffi, lib; print(lib.ARGON2_VERSION_NUMBER)' @@ -129,6 +129,9 @@ jobs: - run: ldd src/_argon2_cffi_bindings/_ffi.abi3.so if: startsWith(matrix.os , 'ubuntu') + - name: Check presence of pytest + run: pytest --version + cog-check: name: Ensure cogified files are up-to-date runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 840c7e1..4eebba8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.2 + rev: v0.12.7 hooks: - id: ruff-check args: [--fix, --exit-non-zero-on-fix] diff --git a/pyproject.toml b/pyproject.toml index acb4c14..5e374f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,14 +44,15 @@ dependencies = [ "cffi>=2.0.0b1; python_version >= '3.14'", ] -[project.optional-dependencies] +[dependency-groups] tests = ["pytest"] -dev = ["argon2-cffi-bindings[tests]", "cogapp", "pre-commit", "wheel"] +dev = [{ include-group = "tests" }, "cogapp", "pre-commit"] + [project.urls] Tidelift = "https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek" Changelog = "https://github.com/hynek/argon2-cffi-bindings/blob/main/CHANGELOG.md" -GitHub= "https://github.com/hynek/argon2-cffi-bindings" +GitHub = "https://github.com/hynek/argon2-cffi-bindings" Funding = "https://github.com/sponsors/hynek" @@ -65,8 +66,8 @@ local_scheme = "no-local-version" [tool.cibuildwheel] -build = [ - "cp39-*" , # We have portable abi3 wheels. +build = [ + "cp39-*", # We have portable abi3 wheels. "cp314t-*", # Free-threading / nogil. "pp310-*", # PyPy 3.9 is EOL and doesn't build on Windows anymore. ] diff --git a/tox.ini b/tox.ini index 7897751..7b78d2e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,3 @@ -[flake8] -exclude = src/_argon2_cffi_bindings/_ffi.py -ignore = - # Black vs flake8 conflict - E203 - - [tox] min_version = 4 env_list = @@ -38,14 +31,14 @@ commands = cog --check -P README.md CHANGELOG.md [testenv] description = Run tests. -extras = tests +dependency_groups = tests commands = pytest {posargs} [testenv:system-argon2] description = Run tests against bindings that use a system installation of Argon2. set_env = ARGON2_CFFI_USE_SYSTEM=1 -extras = tests +dependency_groups = tests install_command = pip install {opts} --no-binary=argon2-cffi-bindings {packages}