Skip to content

Commit d0cf68a

Browse files
committed
feat: Migrate build backend to UV (#163)
1 parent 7270225 commit d0cf68a

47 files changed

Lines changed: 182 additions & 182 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
version: 2
22

3-
# Currently, the "uv" ecosystem is in beta, so we need to enable beta ecosystems.
4-
# Reference: https://github.com/dependabot/dependabot-core/issues/10478#issuecomment-2691330949
5-
enable-beta-ecosystems: true
63
updates:
74
- package-ecosystem: "uv"
85
directory: "/"

.github/workflows/release-package.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ jobs:
2525
with:
2626
enable-cache: true
2727
cache-dependency-glob: "uv.lock"
28-
- name: Install build tools
29-
run: |
30-
uv venv
31-
uv pip install hatchling
28+
- name: Setup virtual environment
29+
run: uv venv
3230
- name: Set project version
33-
run: uv run hatchling version $(echo -n ${{ github.ref_name }} | grep -oP '\d+.\d+.\d+')
31+
run: uv version $(echo -n ${{ github.ref_name }} | grep -oP '\d+.\d+.\d+')
3432
- name: Build package
3533
run: uv build
3634
- name: Verify wheel package
@@ -40,12 +38,17 @@ jobs:
4038
uv pip install dist/meatie-*.whl
4139
uv pip install -r pyproject.toml --extra httpx --extra requests --extra aiohttp
4240
python -c "import meatie; import meatie_httpx; import meatie_requests; import meatie_aiohttp"
41+
deactivate
42+
rm -Rf .venv
4343
- name: Verify tar.gz package
4444
run: |
4545
uv venv
4646
source .venv/bin/activate
4747
uv pip install dist/meatie-*.tar.gz
4848
uv pip install -r pyproject.toml --extra httpx --extra requests --extra aiohttp
4949
python -c "import meatie; import meatie_httpx; import meatie_requests; import meatie_aiohttp"
50-
- name: Publish package
51-
run: uv publish --trusted-publishing always
50+
deactivate
51+
rm -Rf .venv
52+
53+
# - name: Publish package
54+
# run: uv publish --trusted-publishing always

pyproject.toml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "meatie"
3-
dynamic = ["version"]
3+
version = "0.0.0"
44
description = "Meatie is a Python typed REST client library that eliminates the need for boilerplate code when integrating with external APIs. The library generates code for calling a REST API based on method signatures annotated with type hints. Meatie abstracts away mechanics related to HTTP communication, such as building URLs, encoding query parameters, parsing, and dumping Pydantic models. With some modest additional configuration effort, generated HTTP clients offer rate limiting, retries, and caching."
55
readme = "README.md"
66
keywords = [
@@ -55,7 +55,7 @@ test = [
5555
]
5656
mypy = [
5757
"pip",
58-
"mypy>=1.11",
58+
"mypy>=1.17",
5959
"types-setuptools",
6060
"types-requests",
6161
"types-docutils",
@@ -67,20 +67,12 @@ managed = true
6767
package = true
6868
default-groups = [ "test" ]
6969

70-
[tool.hatch.version]
71-
path = "src/meatie/__init__.py"
72-
73-
[tool.hatch.build.targets.wheel]
74-
packages = ["src/meatie", "src/meatie_aiohttp", "src/meatie_requests", "src/meatie_httpx", "meatie", "meatie_aiohttp", "meatie_requests", "meatie_httpx"]
75-
# `uv run` requires ["src/meatie", "src/meatie_aiohttp", "src/meatie_requests", "src/meatie_httpx"]
76-
# `uv build` requires ["meatie", "meatie_aiohttp", "meatie_requests", "meatie_httpx"]
77-
78-
[tool.hatch.build.targets.sdist]
79-
packages = ["src/meatie", "src/meatie_aiohttp", "src/meatie_requests", "src/meatie_httpx"]
70+
[tool.uv.build-backend]
71+
module-name = ["meatie", "meatie_aiohttp", "meatie_httpx", "meatie_requests"]
8072

8173
[build-system]
82-
requires = ["hatchling"]
83-
build-backend = "hatchling.build"
74+
requires = ["uv_build>=0.8.10,<0.9.0"]
75+
build-backend = "uv_build"
8476

8577
[tool.ruff]
8678
line-length = 120

src/meatie/__init__.py

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,62 @@
33

44
"""Meatie is a metaprogramming library for building HTTP REST API clients based on methods annotated with type hints."""
55

6-
# isort:skip_file
7-
from .types import (
8-
Request,
9-
Response,
10-
AsyncResponse,
11-
Method,
12-
Duration,
13-
Time,
14-
INF,
15-
MINUTE,
16-
HOUR,
17-
DAY,
18-
)
6+
from .aio import AsyncContext, AsyncEndpointDescriptor, BaseAsyncClient
197
from .api_reference import api_ref
8+
from .client import BaseClient
9+
from .descriptor import Context, EndpointDescriptor
10+
from .endpoint import endpoint
2011
from .error import (
12+
HttpStatusError,
2113
MeatieError,
22-
RetryError,
23-
RequestError,
24-
RateLimitExceeded,
25-
TransportError,
14+
ParseResponseError,
2615
ProxyError,
16+
RateLimitExceeded,
17+
RequestError,
18+
ResponseError,
19+
RetryError,
2720
ServerError,
2821
Timeout,
29-
HttpStatusError,
30-
ResponseError,
31-
ParseResponseError,
22+
TransportError,
3223
)
24+
from .internal.cache import Cache
25+
from .internal.limit import Limiter, Rate
3326
from .internal.retry import (
34-
RetryContext,
3527
BaseCondition,
3628
Condition,
29+
RetryContext,
3730
after,
3831
after_attempt,
3932
always,
40-
never,
41-
has_status,
42-
has_exception_type,
43-
has_exception_cause_type,
44-
zero,
45-
uniform,
4633
exponential,
4734
fixed,
35+
has_exception_cause_type,
36+
has_exception_type,
37+
has_status,
4838
jit,
39+
never,
40+
uniform,
41+
zero,
4942
)
50-
from .internal.cache import Cache
51-
from .internal.limit import Limiter, Rate
52-
from .client import BaseClient
53-
from .descriptor import EndpointDescriptor, Context
54-
from .aio import BaseAsyncClient, AsyncEndpointDescriptor, AsyncContext
5543
from .option import (
56-
limit,
44+
body,
5745
cache,
58-
retry,
46+
limit,
5947
private,
60-
body,
48+
retry,
49+
)
50+
from .types import (
51+
DAY,
52+
HOUR,
53+
INF,
54+
MINUTE,
55+
AsyncResponse,
56+
Duration,
57+
Method,
58+
Request,
59+
Response,
60+
Time,
6161
)
62-
from .endpoint import endpoint
6362

6463
__all__ = [
6564
"Duration",
@@ -115,5 +114,3 @@
115114
"body",
116115
"endpoint",
117116
]
118-
119-
__version__ = "0.0.0" # This is a placeholder and will be replaced by the build system.

src/meatie/aio/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Copyright 2023 The Meatie Authors. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
33

4-
# isort:skip_file
5-
64
"""Meatie API for asynchronous clients."""
75

86
from .client import BaseAsyncClient
9-
from .descriptor import AsyncEndpointDescriptor, AsyncContext
7+
from .descriptor import AsyncContext, AsyncEndpointDescriptor
108

119
__all__ = [
1210
"BaseAsyncClient",

src/meatie/aio/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
from typing_extensions import Self
77

8-
from meatie import INF, Cache, Limiter, Rate, Request
8+
from meatie.internal.cache import Cache
9+
from meatie.internal.limit import Limiter, Rate
10+
from meatie.types import INF, Request
911

1012

1113
class BaseAsyncClient:

src/meatie/aio/descriptor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
from typing_extensions import Self
1515

16-
from meatie import AsyncResponse, Request
1716
from meatie.internal.adapter import TypeAdapter
1817
from meatie.internal.template import RequestTemplate, get_method
1918
from meatie.internal.types import PT, ResponseBodyType
19+
from meatie.types import AsyncResponse, Request
2020

21-
from . import BaseAsyncClient
21+
from .client import BaseAsyncClient
2222

2323
AsyncOperator = Callable[["AsyncContext[ResponseBodyType]"], Awaitable[ResponseBodyType]]
2424

src/meatie/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
from typing_extensions import Self
77

8-
from meatie import INF, Cache, Limiter, Rate, Request
8+
from meatie.internal.cache import Cache
9+
from meatie.internal.limit import Limiter, Rate
10+
from meatie.types import INF, Request
911

1012

1113
class BaseClient:

src/meatie/descriptor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
from typing_extensions import Self
1515

16-
from meatie import BaseClient, Request, Response
16+
from meatie.client import BaseClient
1717
from meatie.internal.adapter import TypeAdapter
1818
from meatie.internal.template import RequestTemplate, get_method
1919
from meatie.internal.types import PT, ResponseBodyType
20+
from meatie.types import Request, Response
2021

2122
Operator = Callable[["Context[ResponseBodyType]"], ResponseBodyType]
2223

src/meatie/endpoint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
get_type_hints,
1010
)
1111

12-
from meatie import AsyncEndpointDescriptor, EndpointDescriptor, Method
12+
from meatie.aio import AsyncEndpointDescriptor
13+
from meatie.descriptor import EndpointDescriptor
1314
from meatie.internal.adapter import TypeAdapter, get_adapter
1415
from meatie.internal.template import PathTemplate, RequestTemplate
1516
from meatie.internal.types import PT, T
17+
from meatie.types import Method
1618

1719

1820
def endpoint(

0 commit comments

Comments
 (0)