Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

USER vscode

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

RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"context": ".."
},

"postStartCommand": "rye sync --all-features",
"postStartCommand": "uv sync --all-extras",

"customizations": {
"vscode": {
Expand All @@ -20,7 +20,7 @@
"python.defaultInterpreterPath": ".venv/bin/python",
"python.typeChecking": "basic",
"terminal.integrated.env.linux": {
"PATH": "/home/vscode/.rye/shims:${env:PATH}"
"PATH": "${env:PATH}"
}
}
}
Expand Down
47 changes: 16 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
- "generated"
- "codegen/**"
- "integrated/**"
- "stl-preview-head/**"
- "stl-preview-base/**"
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'
- "stl-preview-head/**"
- "stl-preview-base/**"

jobs:
lint:
Expand All @@ -21,16 +21,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: rye sync --all-features
run: uv sync --all-extras

- name: Run lints
run: ./scripts/lint
Expand All @@ -46,19 +41,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: rye sync --all-features
run: uv sync --all-extras

- name: Run build
run: rye build
run: uv build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/replicate-client-python'
Expand All @@ -83,13 +73,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Bootstrap
run: ./scripts/bootstrap
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Publish to PyPI
run: |
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.0.0-beta.3"
".": "2.0.0-beta.4"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 37
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-7a537f433b0b71a42a3d53ce6182cc06790157bbb379461eed93cdb68659bc92.yml
openapi_spec_hash: 5c7633dce3ece58e21f74d826946914c
config_hash: 2d6c50f99a6e3ed5963885980a9e4425
config_hash: e879500b6a97f9096703a56044f1cb5f
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
brew "rye"
brew "uv"

21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 2.0.0-beta.4 (2025-11-27)

Full Changelog: [v2.0.0-beta.3...v2.0.0-beta.4](https://github.com/replicate/replicate-python-beta/compare/v2.0.0-beta.3...v2.0.0-beta.4)

### Features

* **api:** manual updates ([1a88ecc](https://github.com/replicate/replicate-python-beta/commit/1a88ecc6bb12b509f78662bcd23e46952ef745a0))


### Bug Fixes

* ensure streams are always closed ([88c596d](https://github.com/replicate/replicate-python-beta/commit/88c596dd9b09101b63f6c90862b6f7f144e0c54d))
* uv v0.8.11 only has python 3.14rc, which causes issues with pydantic 2 ([e7267be](https://github.com/replicate/replicate-python-beta/commit/e7267be73de9ccc5cc0a644a07a333538a6df8a3))


### Chores

* formatting ([6d6a349](https://github.com/replicate/replicate-python-beta/commit/6d6a349435fc178d8b4b788a25c96a0593c79288))
* **internal:** codegen related update ([ab0983f](https://github.com/replicate/replicate-python-beta/commit/ab0983f58f734a55f2c3cd55adfd4af564aec660))
* pin mypy to 1.17 due to regression ([19ac33c](https://github.com/replicate/replicate-python-beta/commit/19ac33cf0005ac99cd719e44cae6b5b27833fbbf))

## 2.0.0-beta.3 (2025-11-11)

Full Changelog: [v2.0.0-beta.2...v2.0.0-beta.3](https://github.com/replicate/replicate-python-beta/compare/v2.0.0-beta.2...v2.0.0-beta.3)
Expand Down
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
## Setting up the environment

### With Rye
### With `uv`

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:
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:

```sh
$ ./scripts/bootstrap
```

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

```sh
$ rye sync --all-features
$ uv sync --all-extras
```

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

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

# now you can omit the `rye run` prefix
# now you can omit the `uv run` prefix
$ python script.py
```

### Without Rye
### Without `uv`

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:
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:

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

#!/usr/bin/env -S rye run python
#!/usr/bin/env -S uv run python
```

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

```sh
$ rye build
$ uv build
# or
$ python -m build
```
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ seedream = replicate.use("bytedance/seedream-4")
veo = replicate.use("google/veo-3-fast")

# Enhance a simple prompt
image_prompt = claude(prompt="bananas wearing cowboy hats", system_prompt="turn prompts into image prompts")
image_prompt = claude(
prompt="bananas wearing cowboy hats", system_prompt="turn prompts into image prompts"
)

# Generate an image from the enhanced prompt
images = seedream(prompt=image_prompt)
Expand All @@ -59,9 +61,7 @@ The library uses the `REPLICATE_API_TOKEN` environment variable by default to im
import os
from replicate import Replicate

client = Replicate(
bearer_token=os.environ.get("REPLICATE_API_TOKEN")
)
client = Replicate(bearer_token=os.environ.get("REPLICATE_API_TOKEN"))
```

## Using `replicate.use()`
Expand Down
5 changes: 3 additions & 2 deletions bin/publish-pypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

set -eux
rm -rf dist
mkdir -p dist
rye build --clean
rye publish --yes --token=$PYPI_TOKEN
uv build
uv publish --token=$PYPI_TOKEN
9 changes: 0 additions & 9 deletions noxfile.py

This file was deleted.

57 changes: 22 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "replicate"
version = "2.0.0-beta.3"
version = "2.0.0-beta.4"
description = "The official Python library for the replicate API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -25,6 +25,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand All @@ -41,52 +42,38 @@ Repository = "https://github.com/replicate/replicate-python-beta"
[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]

[tool.rye]
[tool.uv]
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
required-version = ">=0.5.0"
conflicts = [
[
{ group = "pydantic-v1" },
{ group = "pydantic-v2" },
],
]

[dependency-groups]
# version pins are in uv.lock
dev = [
"pyright==1.1.399",
"mypy",
"mypy==1.17",
"respx",
"pytest",
"pytest-asyncio",
"ruff",
"time-machine",
"nox",
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"pytest-xdist>=3.6.1",
]

[tool.rye.scripts]
format = { chain = [
"format:ruff",
"format:docs",
"fix:ruff",
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:ruff" = "ruff format"

"lint" = { chain = [
"check:ruff",
"typecheck",
"check:importable",
]}
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."

"check:importable" = "python -c 'import replicate'"

typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes replicate --ignoreexternal"
"typecheck:mypy" = "mypy ."
pydantic-v1 = [
"pydantic>=1.9.0,<2",
]
pydantic-v2 = [
"pydantic~=2.0 ; python_full_version < '3.14'",
"pydantic~=2.12 ; python_full_version >= '3.14'",
]

[build-system]
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
Expand Down
Loading