Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uv instead of pip #564

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.autoSearchPaths": false,
"python.analysis.extraPaths": ["/home/vscode/.local/lib/python3.12/"],
"python.analysis.typeCheckingMode": "basic",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.pythonPath": "/usr/local/python/bin/python",
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"terminal.integrated.defaultProfile.linux": "zsh",
Expand All @@ -48,12 +44,16 @@
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"image": "mcr.microsoft.com/devcontainers/python:3",
"image": "mcr.microsoft.com/devcontainers/base:debian",
"name": "Deebot client",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postStartCommand": "pip install -r requirements-dev.txt && pre-commit install && pip install -e .",
"postCreateCommand": "curl -LsSf https://astral.sh/uv/install.sh | sh && uv sync --frozen --dev && pre-commit install",
"postStartCommand": "uv sync --dev",
"remoteEnv": {
"PATH": "/home/vscode/.cargo/bin:/workspaces/client.py/.venv/bin:${containerEnv:PATH}"
},
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"runArgs": ["-e", "GIT_EDITOR=code --wait"]
Expand Down
66 changes: 41 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,72 @@ on:
pull_request:

env:
DEFAULT_PYTHON: "3.12"
UV_CACHE_DIR: /tmp/.uv-cache

jobs:
code-quality:
runs-on: "ubuntu-latest"
name: Check code quality
steps:
- uses: "actions/checkout@v4"
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
- uses: actions/checkout@v4
- name: Set up uv
# Install latest uv version using the installer
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Restore uv cache
uses: actions/cache@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "pip"
cache-dependency-path: "requirements*"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
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
run: uv sync --locked --dev
# Following steps cannot run by pre-commit.ci as repo = local
- name: Run mypy
run: mypy deebot_client/
run: uv run mypy deebot_client/
- name: Pylint review
run: pylint deebot_client/
run: uv run pylint deebot_client/
- name: Verify no getLogger usages
run: scripts/check_getLogger.sh
- name: Minimize uv cache
run: uv cache prune --ci

tests:
runs-on: "ubuntu-latest"
name: Run tests
strategy:
matrix:
python-version: ["3.12"]
python-version:
- "3.12"
steps:
- uses: "actions/checkout@v4"
- name: Set up uv
# Install latest uv version using the installer
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/[email protected]
run: uv python install ${{ matrix.python-version }}
- name: Restore uv cache
uses: actions/cache@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements*"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ matrix.python-version }}
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --locked --dev
- name: Run pytest
run: pytest --cov=./ --cov-report=xml
run: uv run pytest tests --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Minimize uv cache
run: uv cache prune --ci
25 changes: 18 additions & 7 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@ jobs:
- name: 📥 Checkout the repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/[email protected]
- name: Set up uv
# Install latest uv version using the installer
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version-file: ".python-version"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q build
- name: Restore uv cache
uses: actions/cache@v4
with:
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
run: uv sync --locked

- name: 📦 Build package
run: python -m build
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ repos:
exclude_types:
- csv
- json
exclude: ^uv.lock$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -54,6 +55,7 @@ repos:
- [email protected]
exclude_types:
- python
exclude: ^uv.lock$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
54 changes: 36 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[build-system]
requires = ["setuptools>=60",
"setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "deebot-client"
Expand All @@ -21,28 +20,30 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.12.0"
dynamic = ["dependencies", "version"]
dependencies = [
"aiohttp~=3.10",
"aiomqtt>=2.0.0,<3.0",
"cachetools>=5.0.0,<6.0",
"defusedxml>=0.7.1",
"numpy>=1.23.2,<3.0",
"pillow>=10.0.1,<11.0",
"svg-py>=1.4.2",
]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://deebot.readthedocs.io/"
"Source Code" = "https://github.com/DeebotUniverse/client.py"
"Bug Reports" = "https://github.com/DeebotUniverse/client.py/issues"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools.packages.find]
include = ["deebot_client*"]

[tool.setuptools_scm]
[tool.black]
target-version = ['py311']
safe = true
[tool.hatch.build.targets.sdist]
include = [
"/deebot_client",
]


[tool.hatch.version]
source = "vcs"

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -173,4 +174,21 @@ expected-line-ending-format = "LF"
overgeneral-exceptions = [
"builtins.BaseException",
"builtins.Exception",
]
]

[tool.uv]
dev-dependencies = [
"mypy==1.11.2",
"pre-commit==3.8.0",
"pycountry==24.6.1",
"pylint==3.2.7",
"pytest-asyncio==0.24.0",
"pytest-cov==5.0.0",
"pytest-docker-fixtures==1.3.19",
"pytest-timeout==2.3.1",
"pytest==8.3.2",
"testfixtures==8.3.0",
"types-cachetools>=5.5.0.20240820",
"types-mock>=5.1.0.20240425",
"types-pillow>=10.2.0.20240822",
]
Loading