Skip to content

Commit

Permalink
python uv configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
xoolive committed Sep 26, 2024
1 parent 81ff16c commit d5b3298
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,64 @@ permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
python:

runs-on: ${{ matrix.os }}

strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12"]
os:
- ubuntu-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

env:
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Set up uv
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up uv
if: ${{ matrix.os == 'windows-latest' }}
run: irm https://astral.sh/uv/install.ps1 | iex
shell: powershell

- name: Cache folder for uv
uses: actions/cache@v4
with:
python-version: ${{ matrix.python }}
- name: Create a virtualenv
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
working-directory: python
run: |
python -m venv .venv
run: uv sync --all-extras --dev --python ${{ matrix.python-version }}

- name: Build the wrapper
uses: PyO3/maturin-action@v1
with:
working-directory: python
command: develop
args: -E dev
sccache: 'true'

- name: Run linter and formatter
working-directory: python
run: |
source .venv/bin/activate
ruff check
ruff format --check
uv run ruff check
uv run ruff format --check
- name: Run tests
working-directory: python
run: |
source .venv/bin/activate
pytest
uv run pytest
1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ features = ["pyo3/extension-module"]
[tool.uv]
dev-dependencies = [
"mypy>=1.8.0",
"pip",
"pytest>=8.0.2",
"ruff>=0.3.0"
]
Expand Down
11 changes: 11 additions & 0 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5b3298

Please sign in to comment.