Skip to content

Commit f553908

Browse files
refactor(pkg): switch from rye to uv
1 parent 6b129f4 commit f553908

18 files changed

+1489
-312
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
33

44
USER vscode
55

6-
RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.44.0" RYE_INSTALL_OPTION="--yes" bash
7-
ENV PATH=/home/vscode/.rye/shims:$PATH
6+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
87

98
RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"context": ".."
88
},
99

10-
"postStartCommand": "rye sync --all-features",
10+
"postStartCommand": "uv sync --all-extras",
1111

1212
"customizations": {
1313
"vscode": {
@@ -20,7 +20,7 @@
2020
"python.defaultInterpreterPath": ".venv/bin/python",
2121
"python.typeChecking": "basic",
2222
"terminal.integrated.env.linux": {
23-
"PATH": "/home/vscode/.rye/shims:${env:PATH}"
23+
"PATH": "${env:PATH}"
2424
}
2525
}
2626
}

.github/workflows/ci.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Install Rye
20-
run: |
21-
curl -sSf https://rye.astral.sh/get | bash
22-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
23-
env:
24-
RYE_VERSION: '0.44.0'
25-
RYE_INSTALL_OPTION: '--yes'
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
with:
22+
version: '0.5.23'
2623

2724
- name: Install dependencies
28-
run: rye sync --all-features
25+
run: uv sync --all-extras
2926

3027
- name: Run lints
3128
run: ./scripts/lint
@@ -61,13 +58,10 @@ jobs:
6158
steps:
6259
- uses: actions/checkout@v4
6360

64-
- name: Install Rye
65-
run: |
66-
curl -sSf https://rye.astral.sh/get | bash
67-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
68-
env:
69-
RYE_VERSION: '0.44.0'
70-
RYE_INSTALL_OPTION: '--yes'
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v5
63+
with:
64+
version: '0.5.23'
7165

7266
- name: Bootstrap
7367
run: ./scripts/bootstrap

.github/workflows/create-releases.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ jobs:
2222
repo: ${{ github.event.repository.full_name }}
2323
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
2424

25-
- name: Install Rye
25+
- name: Install uv
2626
if: ${{ steps.release.outputs.releases_created }}
27-
run: |
28-
curl -sSf https://rye.astral.sh/get | bash
29-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
30-
env:
31-
RYE_VERSION: '0.44.0'
32-
RYE_INSTALL_OPTION: '--yes'
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
version: '0.5.23'
3330

3431
- name: Publish to PyPI
3532
if: ${{ steps.release.outputs.releases_created }}

.github/workflows/publish-pypi.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- name: Install Rye
17-
run: |
18-
curl -sSf https://rye.astral.sh/get | bash
19-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
20-
env:
21-
RYE_VERSION: '0.44.0'
22-
RYE_INSTALL_OPTION: '--yes'
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v5
18+
with:
19+
version: '0.5.23'
2320

2421
- name: Publish to PyPI
2522
run: |

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-1fdf23e8226430012c21819427e8d1ed16c08c0fb2d4abf69b8e318a42e99552.yml
33
openapi_spec_hash: 836bbb4ab7c33c37456d1842876d7aba
4-
config_hash: 7b17fe2f10f5942177ff51b0a13506fa
4+
config_hash: 91be78a9c3fd8dcdc0137a2cf6950153

Brewfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
brew "rye"
1+
brew "uv"
22

CONTRIBUTING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
## Setting up the environment
22

3-
### With Rye
3+
### With `uv`
44

5-
We use [Rye](https://rye.astral.sh/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:
5+
We use [uv](https://docs.astral.sh/uv/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:
66

77
```sh
88
$ ./scripts/bootstrap
99
```
1010

11-
Or [install Rye manually](https://rye.astral.sh/guide/installation/) and run:
11+
Or [install uv manually](https://docs.astral.sh/uv/getting-started/installation/) and run:
1212

1313
```sh
14-
$ rye sync --all-features
14+
$ uv sync
1515
```
1616

17-
You can then run scripts using `rye run python script.py` or by activating the virtual environment:
17+
You can then run scripts using `uv run python script.py` or by manually activating the virtual environment:
1818

1919
```sh
20-
# Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work
20+
# manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work
2121
$ source .venv/bin/activate
2222

23-
# now you can omit the `rye run` prefix
23+
# now you can omit the `uv run` prefix
2424
$ python script.py
2525
```
2626

27-
### Without Rye
27+
### Without `uv`
2828

29-
Alternatively if you don't want to install `Rye`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command:
29+
Alternatively if you don't want to install `uv`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command:
3030

3131
```sh
3232
$ pip install -r requirements-dev.lock
@@ -45,7 +45,7 @@ All files in the `examples/` directory are not modified by the generator and can
4545
```py
4646
# add an example to examples/<your-example>.py
4747

48-
#!/usr/bin/env -S rye run python
48+
#!/usr/bin/env -S uv run python
4949
5050
```
5151

@@ -72,7 +72,7 @@ Building this package will create two files in the `dist/` directory, a `.tar.gz
7272
To create a distributable version of the library, all you have to do is run this command:
7373

7474
```sh
75-
$ rye build
75+
$ uv build
7676
# or
7777
$ python -m build
7878
```

bin/publish-pypi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
set -eux
4+
rm -rf dist
45
mkdir -p dist
5-
rye build --clean
6-
rye publish --yes --token=$PYPI_TOKEN
6+
uv build
7+
uv publish --token=$PYPI_TOKEN

noxfile.py

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

pyproject.toml

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ Homepage = "https://github.com/anthropics/anthropic-sdk-python"
4343
Repository = "https://github.com/anthropics/anthropic-sdk-python"
4444

4545

46-
[tool.rye]
46+
[tool.uv]
4747
managed = true
48-
# version pins are in requirements-dev.lock
48+
required-version = ">=0.5.0"
49+
# version pins are in uv.lock
4950
dev-dependencies = [
5051
"pyright==1.1.399",
5152
"mypy",
@@ -54,43 +55,13 @@ dev-dependencies = [
5455
"pytest-asyncio",
5556
"ruff",
5657
"time-machine",
57-
"nox",
5858
"dirty-equals>=0.6.0",
5959
"importlib-metadata>=6.7.0",
6060
"boto3-stubs >= 1",
6161
"rich>=13.7.1",
6262
"nest_asyncio==1.6.0",
6363
]
6464

65-
[tool.rye.scripts]
66-
format = { chain = [
67-
"format:ruff",
68-
"format:docs",
69-
"fix:ruff",
70-
# run formatting again to fix any inconsistencies when imports are stripped
71-
"format:ruff",
72-
]}
73-
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
74-
"format:ruff" = "ruff format"
75-
76-
"lint" = { chain = [
77-
"check:ruff",
78-
"typecheck",
79-
"check:importable",
80-
]}
81-
"check:ruff" = "ruff check ."
82-
"fix:ruff" = "ruff check --fix ."
83-
84-
"check:importable" = "python -c 'import anthropic'"
85-
86-
typecheck = { chain = [
87-
"typecheck:pyright",
88-
"typecheck:mypy"
89-
]}
90-
"typecheck:pyright" = "pyright"
91-
"typecheck:verify-types" = "pyright --verifytypes anthropic --ignoreexternal"
92-
"typecheck:mypy" = "mypy ."
93-
9465
[build-system]
9566
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
9667
build-backend = "hatchling.build"

0 commit comments

Comments
 (0)