Skip to content

Commit f184ad5

Browse files
committed
chore(internal): switch over to uv
1 parent 6fd9ff3 commit f184ad5

File tree

17 files changed

+187
-241
lines changed

17 files changed

+187
-241
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: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- name: Install Rye
25-
run: |
26-
curl -sSf https://rye.astral.sh/get | bash
27-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
28-
env:
29-
RYE_VERSION: '0.44.0'
30-
RYE_INSTALL_OPTION: '--yes'
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
version: '0.8.11'
3128

3229
- name: Install dependencies
33-
run: rye sync --all-features
30+
run: uv sync --all-extras
3431

3532
- name: Run lints
3633
run: ./scripts/lint
@@ -46,19 +43,16 @@ jobs:
4643
steps:
4744
- uses: actions/checkout@v4
4845

49-
- name: Install Rye
50-
run: |
51-
curl -sSf https://rye.astral.sh/get | bash
52-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
53-
env:
54-
RYE_VERSION: '0.44.0'
55-
RYE_INSTALL_OPTION: '--yes'
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
with:
49+
version: '0.8.11'
5650

5751
- name: Install dependencies
58-
run: rye sync --all-features
52+
run: uv sync --all-extras
5953

6054
- name: Run build
61-
run: rye build
55+
run: uv build
6256

6357
- name: Get GitHub OIDC Token
6458
if: github.repository == 'stainless-sdks/replicate-client-python'
@@ -83,13 +77,10 @@ jobs:
8377
steps:
8478
- uses: actions/checkout@v4
8579

86-
- name: Install Rye
87-
run: |
88-
curl -sSf https://rye.astral.sh/get | bash
89-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
90-
env:
91-
RYE_VERSION: '0.44.0'
92-
RYE_INSTALL_OPTION: '--yes'
80+
- name: Install uv
81+
uses: astral-sh/setup-uv@v5
82+
with:
83+
version: '0.8.11'
9384

9485
- name: Bootstrap
9586
run: ./scripts/bootstrap
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Create releases
2+
on:
3+
schedule:
4+
- cron: '0 5 * * *' # every day at 5am UTC
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: release
12+
if: github.ref == 'refs/heads/main' && github.repository == 'replicate/replicate-python-beta'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: stainless-api/trigger-release-please@v1
19+
id: release
20+
with:
21+
repo: ${{ github.event.repository.full_name }}
22+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
23+
24+
- name: Install uv
25+
if: ${{ steps.release.outputs.releases_created }}
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
version: '0.8.11'
29+
30+
- name: Publish to PyPI
31+
if: ${{ steps.release.outputs.releases_created }}
32+
run: |
33+
bash ./bin/publish-pypi
34+
env:
35+
PYPI_TOKEN: ${{ secrets.REPLICATE_PYPI_TOKEN || secrets.PYPI_TOKEN }}

.github/workflows/publish-pypi.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# This workflow is triggered when a GitHub release is created.
2-
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
3-
# You can run this workflow by navigating to https://www.github.com/replicate/replicate-python-beta/actions/workflows/publish-pypi.yml
1+
# workflow for re-running publishing to PyPI in case it fails for some reason
2+
# you can run this workflow by navigating to https://www.github.com/replicate/replicate-python-beta/actions/workflows/publish-pypi.yml
43
name: Publish PyPI
54
on:
65
workflow_dispatch:
76

8-
release:
9-
types: [published]
10-
117
jobs:
128
publish:
139
name: publish
@@ -16,13 +12,10 @@ jobs:
1612
steps:
1713
- uses: actions/checkout@v4
1814

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'
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
17+
with:
18+
version: '0.8.11'
2619

2720
- name: Publish to PyPI
2821
run: |

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ jobs:
1818
run: |
1919
bash ./bin/check-release-environment
2020
env:
21+
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}
2122
PYPI_TOKEN: ${{ secrets.REPLICATE_PYPI_TOKEN || secrets.PYPI_TOKEN }}

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 --all-extras
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/check-release-environment

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
errors=()
44

5+
if [ -z "${STAINLESS_API_KEY}" ]; then
6+
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
7+
fi
8+
59
if [ -z "${PYPI_TOKEN}" ]; then
610
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
711
fi

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

0 commit comments

Comments
 (0)