Skip to content

Commit

Permalink
Switch from Poetry to uv (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
henribru authored Sep 28, 2024
1 parent d38a36b commit 00e10dc
Show file tree
Hide file tree
Showing 5 changed files with 663 additions and 68 deletions.
57 changes: 15 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
run: pip install poetry

- name: Cache dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
enable-cache: true

- name: Install dependencies
run: poetry install
run: uv sync

- name: Register problem matcher
run: echo "::add-matcher::.github/workflows/matchers/ruff.json"
Expand All @@ -39,7 +30,7 @@ jobs:
run: rm .gitignore

- name: Run ruff format
run: poetry run ruff format --check googleapiclient-stubs apiclient-stubs
run: uv run ruff format --check googleapiclient-stubs apiclient-stubs

ruff-check:
runs-on: ubuntu-latest
Expand All @@ -49,28 +40,19 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
run: pip install poetry

- name: Cache dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
enable-cache: true

- name: Install dependencies
run: poetry install
run: uv sync

- name: Delete .gitignore (https://github.com/astral-sh/ruff/issues/8753)
run: rm .gitignore

- name: Run ruff check
run: poetry run ruff check --output-format github googleapiclient-stubs apiclient-stubs
run: uv run ruff check --output-format github googleapiclient-stubs apiclient-stubs

mypy:
runs-on: ubuntu-latest
Expand All @@ -80,26 +62,17 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
run: pip install poetry

- name: Cache dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
enable-cache: true

- name: Install dependencies
run: poetry install
run: uv sync

- name: Register problem matchers
run: echo "::add-matcher::.github/workflows/matchers/mypy.json"

- name: Run Mypy
run: |
poetry run mypy googleapiclient-stubs apiclient-stubs
uv run mypy googleapiclient-stubs apiclient-stubs
19 changes: 11 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
# - name: Set up Python
# uses: actions/setup-python@v5

- name: Install Poetry
run: pip install poetry
- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Build
run: uv build

- name: Build and publish
run: poetry publish --build --username __token__ --password "$PYPI_TOKEN"
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Publish
run: uv publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
!/apiclient-stubs/
!/apiclient-stubs/**
!/pyproject.toml
!/uv.lock
!/README.md
!/LICENSE
39 changes: 21 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[tool.poetry]
[project]
name = "google-api-python-client-stubs"
version = "1.27.0"
description = "Type stubs for google-api-python-client"
authors = ["Henrik Bruådal <[email protected]>"]
authors = [
{ name = "Henrik Bruådal", email = "[email protected]" },
]
readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/henribru/google-api-python-client-stubs"
packages = [
{ include = "googleapiclient-stubs" },
{ include = "apiclient-stubs" },
]
classifiers = [
"Typing :: Stubs Only",
]
dependencies = [
"google-api-python-client>=2.141.0",
"types-httplib2>=0.22.0.2",
"typing-extensions>=3.10.0",
]
requires-python = ">=3.7"

[tool.poetry.dependencies]
python = "^3.7"
google-api-python-client = ">=2.141.0"
typing-extensions = ">=3.10.0"
types-httplib2 = ">=0.22.0.2"

[tool.poetry.group.dev.dependencies]
mypy = {version = "^1.9.0", python = "^3.8"}
stubdefaulter = "^0.1.0"
ruff = "^0.3.3"
[tool.uv]
dev-dependencies = [
"mypy>=1.11.2 ; python_full_version >= '3.8'",
"ruff>=0.6.8",
"stubdefaulter>=0.1.0",
]

[tool.ruff.lint]
select = ["UP", "I"]
Expand All @@ -38,6 +38,9 @@ known-first-party = [
[tool.mypy]
warn_unused_ignores = true

[tool.hatch.build.targets.wheel]
packages = ["googleapiclient-stubs", "apiclient-stubs"]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
Loading

0 comments on commit 00e10dc

Please sign in to comment.