From 23faefad3cef3de542d89407e275092e594c08bb Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 28 Mar 2024 01:37:30 -0400 Subject: [PATCH 1/3] ci: use uv in a few places Signed-off-by: Henry Schreiner --- .github/workflows/ci.yml | 14 +++++++++----- noxfile.py | 18 +++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 079b9cf3..9a22e745 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,7 @@ jobs: - "3.10" - "3.11" - "3.12" + name: Check Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v4 @@ -47,19 +48,22 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true + - name: Setup uv + uses: yezz123/setup-uv@v4 + with: + uv-venv: ".venv" + - name: Requirements check - run: python -m pip list + run: up pip list - name: Install package - run: python -m pip install -e ".[test]" + run: uv pip install -e ".[test]" - name: Test package run: python -m pytest - name: Install plotting requirements too - if: matrix.python-version != '3.12' - run: python -m pip install -e ".[test,plot]" + run: uv pip install -e ".[test,plot]" - name: Test plotting too - if: matrix.python-version != '3.12' run: python -m pytest --mpl diff --git a/noxfile.py b/noxfile.py index 416194c5..e2e6f7e3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,10 +7,9 @@ import nox -ALL_PYTHONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] - +nox.needs_version = ">=2024.3.2" nox.options.sessions = ["lint", "tests"] - +nox.options.default_venv_backend = "uv|virtualenv" DIR = Path(__file__).parent.resolve() @@ -35,7 +34,7 @@ def pylint(session: nox.Session) -> None: session.run("pylint", "hist", *session.posargs) -@nox.session(python=ALL_PYTHONS, reuse_venv=True) +@nox.session(reuse_venv=True) def tests(session): """ Run the unit and regular tests. @@ -102,12 +101,9 @@ def build(session): Build an SDist and wheel. """ - build_p = DIR.joinpath("build") - if build_p.exists(): - shutil.rmtree(build_p) - - session.install("build") - session.run("python", "-m", "build") + args = [] if shutil.which("uv") else ["uv"] + session.install("build==1.2.0", *args) + session.run("python", "-m", "build", "--installer=uv") @nox.session() @@ -130,6 +126,6 @@ def boost(session): session.chdir("boost-histogram") session.install(".") session.chdir(DIR) - session.install("-e.[test,plot]") + session.install("-e.[test,plot]", "pip") session.run("pip", "list") session.run("pytest", *session.posargs) From 905e6cc172724f586e3abb89ee419277f7d338a3 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 28 Mar 2024 01:42:26 -0400 Subject: [PATCH 2/3] Apply suggestions from code review --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a22e745..7292df95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: uv-venv: ".venv" - name: Requirements check - run: up pip list + run: uv pip list - name: Install package run: uv pip install -e ".[test]" From c393cc27c085395cdfbaa31930198f6249b2225a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 28 Mar 2024 01:59:55 -0400 Subject: [PATCH 3/3] ci: more uv Signed-off-by: Henry Schreiner --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7292df95..0c1314de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,18 +14,20 @@ concurrency: cancel-in-progress: true jobs: - pre-commit: + pylint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup uv + uses: yezz123/setup-uv@v4 with: - python-version: "3.x" - - uses: pre-commit/action@v3.0.1 + uv-venv: ".venv" + - name: Install nox + run: uv pip install nox - name: PyLint run: | echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" - pipx run nox -s pylint + nox -s pylint checks: runs-on: ubuntu-latest