Skip to content

Commit c6b6ac3

Browse files
vlaciqkaiser
andauthored
Migrate from Poetry to uv (#50)
* chore: run migrate-to-uv * chore: adapt CI to uv * chore: ignore .venv directory * chore: black -> ruff * chore: support testing publish workflow to test.pypi.org * chore: onboard renovate * chore: fix ruff format and linting violations * chore: remove test matrix We don't have tests besides linting, which does not depend on the installed Python version --------- Co-authored-by: Quentin Kaiser <569494+qkaiser@users.noreply.github.com>
1 parent b66e19d commit c6b6ac3

10 files changed

Lines changed: 527 additions & 676 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ name: PyPI Publish
33
on:
44
release:
55
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
test_release:
9+
description: If true, publish to test.pypi.org
10+
required: true
11+
default: true
12+
type: boolean
613

714
jobs:
815
publish:
916
runs-on: ubuntu-latest
1017
steps:
1118
- uses: actions/checkout@v4
12-
- name: Set up Python
13-
uses: actions/setup-python@v5
19+
- name: Install uv & Python
20+
uses: astral-sh/setup-uv@v6
1421
with:
15-
python-version: '3.x'
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
pip install poetry
20-
poetry install
21-
- run: poetry publish --build
22+
enable-cache: true
23+
cache-dependency-glob: "uv.lock"
24+
- run: uv build
25+
- run: uv publish
2226
env:
23-
POETRY_PYPI_TOKEN_PYPI: ${{secrets.POETRY_PYPI_TOKEN_PYPI}}
27+
UV_PUBLISH_TOKEN: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.test_release && secrets.TEST_PYPI_API_TOKEN || secrets.POETRY_PYPI_TOKEN_PYPI }}
28+
UV_PUBLISH_URL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.test_release && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}

.github/workflows/test.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Check
52

63
on: [push, pull_request]
74

85
jobs:
96
build:
10-
117
runs-on: ubuntu-latest
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16-
178
steps:
189
- uses: actions/checkout@v4
19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v5
10+
- name: Install uv & Python
11+
uses: astral-sh/setup-uv@v6
2112
with:
22-
python-version: ${{ matrix.python-version }}
23-
- name: Install dependencies
13+
enable-cache: true
14+
cache-dependency-glob: "uv.lock"
15+
- name: Ruff format
2416
run: |
25-
python -m pip install --upgrade pip
26-
pip install poetry
27-
poetry install
28-
- name: Black source code formating check
17+
uv run ruff format --diff --exit-non-zero-on-format
18+
- name: Ruff check
2919
run: |
30-
poetry run black --check .
20+
uv run ruff check

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
coverage.xml
33
__pycache__
44
.idea
5-
venv
5+
.venv/
66
htmlcov/
77
dist/

onekey_client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .client import Client
2-
from .models import Tenant, FirmwareMetadata
1+
from .client import Client as Client
2+
from .models import Tenant as Tenant, FirmwareMetadata as FirmwareMetadata

onekey_client/cli/ci.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def create_new_cve_testcase(self, cve):
205205
message="New CVE",
206206
output=f"""New CVE detected
207207
URL: {url}
208-
CVE ID: {cve['id']}
209-
Severity: {cve['severity']}
210-
Description: {cve['description']}
208+
CVE ID: {cve["id"]}
209+
Severity: {cve["severity"]}
210+
Description: {cve["description"]}
211211
""",
212212
)
213213
return test_case

onekey_client/queries/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .utils import load_query
1+
from .utils import load_query as load_query

poetry.lock

Lines changed: 0 additions & 614 deletions
This file was deleted.

pyproject.toml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
[tool.poetry]
1+
[project]
22
name = "onekey_client"
33
version = "2.3.0"
44
description = "ONEKEY API client"
5-
homepage = "https://www.onekey.com/"
6-
authors = ["ONEKEY <support@onekey.com>"]
7-
license = "MIT"
5+
authors = [{ name = "ONEKEY", email = "support@onekey.com" }]
6+
requires-python = ">=3.9"
87
readme = "README.md"
8+
license = "MIT"
99
keywords = ["iot", "security", "firmware", "analysis"]
1010
classifiers = [
11-
"Development Status :: 4 - Beta",
12-
"Environment :: Console",
13-
"License :: OSI Approved :: MIT License",
14-
"Operating System :: OS Independent",
15-
"Programming Language :: Python :: 3 :: Only",
16-
"Topic :: Security"]
11+
"Development Status :: 4 - Beta",
12+
"Environment :: Console",
13+
"License :: OSI Approved :: MIT License",
14+
"Operating System :: OS Independent",
15+
"Programming Language :: Python :: 3 :: Only",
16+
"Topic :: Security",
17+
]
18+
dependencies = [
19+
"httpx==0.28.1",
20+
"pydantic==2.10.6",
21+
"Authlib>=1.4.1,<2.0.0",
22+
"importlib-resources>=6.0.0,<7",
23+
"click>=8.1.3,<9",
24+
"junit-xml>=1.9,<2",
25+
]
1726

18-
[tool.poetry.urls]
19-
"GitHub" = "https://github.com/onekey-sec/python-client"
27+
[project.urls]
28+
Homepage = "https://www.onekey.com/"
29+
GitHub = "https://github.com/onekey-sec/python-client"
2030
"Bug Tracker" = "https://github.com/onekey-sec/python-client/issues"
2131

22-
[tool.poetry.dependencies]
23-
python = "^3.9.0"
24-
httpx = "0.28.1"
25-
pydantic = "2.10.6"
26-
Authlib = ">=1.4.1,<2.0.0"
27-
importlib-resources = "^6.0.0"
28-
click = "^8.1.3"
29-
junit-xml = "^1.9"
32+
[project.scripts]
33+
onekey = "onekey_client.cli.cli:main"
3034

31-
[tool.poetry.dev-dependencies]
32-
black = "^25.0.0"
35+
[dependency-groups]
36+
dev = ["ruff==0.14.9"]
3337

3438
[build-system]
35-
requires = ["poetry-core>=1.0.0"]
36-
build-backend = "poetry.core.masonry.api"
37-
38-
[tool.poetry.scripts]
39-
onekey = "onekey_client.cli.cli:main"
39+
requires = ["hatchling"]
40+
build-backend = "hatchling.build"

renovate.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:recommended", "schedule:earlyMondays"],
4+
"labels": ["dependencies"],
5+
"packageRules": [
6+
{
7+
"matchUpdateTypes": ["minor", "patch"],
8+
"autoApprove": true,
9+
"automerge": true
10+
}
11+
],
12+
"lockFileMaintenance": {
13+
"enabled": true,
14+
"branchTopic": "lock-file-maintenance-{{packageFile}}",
15+
"commitMessageExtra": "({{packageFile}})",
16+
"extends": ["schedule:monthly"]
17+
}
18+
}

0 commit comments

Comments
 (0)