Skip to content

Commit

Permalink
Switch from Poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
henribru committed Sep 30, 2024
1 parent 5eb83e0 commit 6f91324
Show file tree
Hide file tree
Showing 6 changed files with 801 additions and 73 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 google-stubs
run: uv run ruff format --check google-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('pyproject.toml') }}
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 google-stubs
run: uv run ruff check --output-format github google-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('poetry.lock') }}
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 --namespace-packages --explicit-package-bases google-stubs
mv google-stubs google && uv run mypy --namespace-packages --explicit-package-bases google
20 changes: 10 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Build
run: uv build

- name: Install Poetry
run: pip install poetry

- 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 @@ -5,6 +5,7 @@
!/google-stubs/{__init__.pyi, py.typed}
!/google-stubs/ads/**
!/pyproject.toml
!/uv.lock
!/README.md
!/LICENSE
__pycache__
1 change: 1 addition & 0 deletions google-stubs/ads/googleads/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2139,3 +2139,4 @@ class GoogleAdsClient:
) -> v17.UserListServiceClient: ...
@overload
def get_service(self, name: str, version: _V = "v17") -> Any: ...

46 changes: 25 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
[tool.poetry]
[project]
name = "google-ads-stubs"
version = "19.0.0"
license = "Apache-2.0"
description = "Type stubs for google-ads"
authors = ["Henrik Bruåsdal <[email protected]>"]
authors = [
{ name = "Henrik Bruåsdal", email = "[email protected]" },
]
readme = "README.md"
repository = "https://github.com/henribru/google-ads-stubs"
packages = [
{ include = "google-stubs" },
]
classifiers = [
"Typing :: Stubs Only",
]
dependencies = [
"google-ads>=25.0.0",
"google-auth-stubs>=0.1.0",
"googleapis-common-protos-stubs>=2.0.0",
"grpc-stubs>=1.24.7",
"proto-plus-stubs>=0.5.0",
"types-protobuf>=3.18.0",
"typing-extensions>=3.10.0",
]
requires-python = ">=3.8"

[tool.poetry.dependencies]
python = ">=3.8,<3.13"
typing-extensions = ">=3.10.0"
googleapis-common-protos-stubs = ">=2.0.0"
google-ads = ">=25.0.0"
grpc-stubs = ">=1.24.7"
types-protobuf = ">=3.18.0"
proto-plus-stubs = ">=0.5.0"
google-auth-stubs = ">=0.1.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.9.0"
stubdefaulter = "^0.1.0"
ruff = "^0.3.3"
[tool.uv]
dev-dependencies = [
"mypy>=1.9.0",
"ruff>=0.3.3",
"stubdefaulter>=0.1.0",
]

[tool.ruff.lint]
select = ["UP", "I"]
Expand All @@ -35,6 +36,9 @@ select = ["UP", "I"]
combine-as-imports = true
known-first-party = ["google.ads.googleads"]

[tool.hatch.build.targets.wheel]
packages = ["google-stubs"]

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

0 comments on commit 6f91324

Please sign in to comment.