Skip to content

Commit

Permalink
Update uv setup (#130)
Browse files Browse the repository at this point in the history
* Update uv setup

* Update tests.yml

* Call uv run explicitly

* Update tests.yml

* Override dependencies for Python 3.8

* Update pyproject.toml

* Fix typing

* Revert "Fix typing"

This reverts commit 46ac2f5.

* Update pyproject.toml
  • Loading branch information
dustalov authored Jan 13, 2025
1 parent 6f47e4d commit 6916103
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [ published ]

env:
UV_SYSTEM_PYTHON: 1

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -14,12 +17,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: false
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system -e '.[dev,docs,learning]'
run: uv sync --all-extras
- name: Build
run: python3 -m build --sdist --wheel .
run: uv run python3 -m build --sdist --wheel .
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
33 changes: 19 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,57 @@ name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: |
**/pyproject.toml
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system -e '.[dev,docs,learning]'
run: uv sync --all-extras
# NumPy 2.0 is not available for Python 3.8 and older versions, which leads to broken tests
- name: Lint with Mypy (Python 3.8)
run: mypy crowdkit
run: uv run mypy crowdkit
if: matrix.python-version == '3.8'
- name: Lint with Mypy
run: mypy crowdkit tests
run: uv run mypy crowdkit tests
if: matrix.python-version != '3.8'
# pyupgrade is incompatible with Python 3.8 and older versions
- name: Pre-Commit Check
uses: pre-commit/[email protected]
if: matrix.python-version != '3.8'
- name: Test with pytest
run: coverage run --source crowdkit -m pytest
run: uv run coverage run --source crowdkit -m pytest
- name: Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: codecov
if: matrix.python-version == '3.12'
run: uv run codecov
if: matrix.python-version == '3.13'
- name: Run MkDocs
run: mkdocs build --strict
run: uv run mkdocs build --strict
- name: Build wheel
run: |
python3 -m build --sdist --wheel .
twine check --strict dist/*
uv run python3 -m build --sdist --wheel .
uv run twine check --strict dist/*
- name: Validate CITATION.cff
uses: citation-file-format/[email protected]
with:
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.19.1
hooks:
- id: pyupgrade
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
rev: 1.9.1
hooks:
- id: nbqa-black
additional_dependencies: [black==24.8.0]
additional_dependencies: [black==24.10.0]
- id: nbqa-isort
additional_dependencies: [isort==5.13.2]
- id: nbqa-flake8
additional_dependencies: [flake8==7.0.0]
additional_dependencies: [flake8==7.1.1]
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==3.17.0]
additional_dependencies: [pyupgrade==3.19.1]
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords = ["crowdsourcing", "data labeling", "answer aggregation", "truth infer
license = {text = "Apache 2.0"}
authors = [{name = "Toloka"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Development Status :: 6 - Mature",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
Expand All @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
Expand Down Expand Up @@ -103,3 +104,9 @@ src_paths = ["crowdkit", "tests"]

[tool.pyupgrade]
py38-plus = true

[tool.uv]
override-dependencies = [
"torch < 2.5.0; python_version < '3.9'",
"torch >= 2.5.0; python_version >= '3.9'"
]

0 comments on commit 6916103

Please sign in to comment.