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
4 changes: 1 addition & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
COPY --from=ghcr.io/astral-sh/uv:0.11.7 /uv /usr/local/bin/uv

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

RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc
7 changes: 2 additions & 5 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 --locked --all-extras --group dev",

"customizations": {
"vscode": {
Expand All @@ -18,10 +18,7 @@
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": ".venv/bin/python",
"python.defaultInterpreterPath": ".venv/bin/python",
"python.typeChecking": "basic",
"terminal.integrated.env.linux": {
"PATH": "/home/vscode/.rye/shims:${env:PATH}"
}
"python.typeChecking": "basic"
}
}
},
Expand Down
69 changes: 48 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
run: uv python install

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

- name: Run lints
run: ./scripts/lint
Expand All @@ -46,17 +49,20 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
run: uv python install

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

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

- name: Get GitHub OIDC Token
if: |-
Expand Down Expand Up @@ -85,14 +91,32 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up pnpm
uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # pnpm/action-setup v6.0.3
with:
run_install: false

- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # setup-node v6.4.0
with:
node-version-file: .node-version
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Bootstrap
run: ./scripts/bootstrap
- name: Set up Python
run: uv python install

- name: Install Python dependencies
run: uv sync --locked --all-extras --group dev

- name: Install steady CLI
run: pnpm install --frozen-lockfile

- name: Run tests
run: ./scripts/test
Expand All @@ -106,20 +130,23 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
run: uv python install

- name: Install dependencies
run: |
rye sync --all-features
run: uv sync --locked --all-extras --group dev

- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
rye run python examples/demo.py
uv run python examples/demo.py
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
rye run python examples/async_demo.py
uv run python examples/async_demo.py
19 changes: 13 additions & 6 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ jobs:
repo: ${{ github.event.repository.full_name }}
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}

- name: Set up Rye
- name: Set up uv
if: ${{ steps.release.outputs.releases_created }}
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
if: ${{ steps.release.outputs.releases_created }}
run: uv python install

- name: Build
if: ${{ steps.release.outputs.releases_created }}
run: uv build

- name: Publish to PyPI
if: ${{ steps.release.outputs.releases_created }}
run: |
bash ./bin/publish-pypi
run: uv publish
env:
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
33 changes: 19 additions & 14 deletions .github/workflows/detect-breaking-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ jobs:
# Ensure we can check out the pull request base in the script below.
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
run: uv python install

- name: Install dependencies
run: |
rye sync --all-features
run: uv sync --locked --all-extras --group dev
- name: Detect removed symbols
run: |
rye run python scripts/detect-breaking-changes.py "${{ github.event.pull_request.base.sha }}"
run: uv run python scripts/detect-breaking-changes.py "${{ github.event.pull_request.base.sha }}"

- name: Detect breaking changes
run: |
Expand All @@ -47,17 +49,19 @@ jobs:
with:
path: openai-python

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true
working-directory: openai-python

- name: Set up Python
working-directory: openai-python
run: uv python install

- name: Install dependencies
working-directory: openai-python
run: |
rye sync --all-features
run: uv sync --locked --all-extras --group dev

# Setup the agents lib
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Expand All @@ -66,9 +70,10 @@ jobs:
path: openai-agents-python

- name: Setup uv
uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
enable-cache: true
version: "0.11.7"

- name: Link to local SDK
working-directory: openai-agents-python
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.7
with:
version: '0.44.0'
version: "0.11.7"
enable-cache: true

- name: Set up Python
run: uv python install

- name: Build
run: uv build

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
run: uv publish
env:
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__
dist

.venv
node_modules
.idea

.env
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.15.0
4 changes: 2 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
brew "rye"

brew "uv"
brew "node"
23 changes: 12 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
## 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 and run:

```sh
$ rye sync --all-features
$ uv sync --locked --all-extras --group dev
```

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 activating the virtual environment:

```sh
# Activate the virtual environment - 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
### Compatibility install

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:
If you need a `requirements.txt`-style install path for compatibility tooling, create a virtual environment however you desire and then install dependencies using this command:

```sh
$ pip install -r requirements-dev.lock
$ uv pip install -r requirements-dev.lock
```

## Modifying/Adding code
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 All @@ -88,6 +88,7 @@ $ pip install ./path-to-wheel-file.whl
Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.

```sh
$ corepack pnpm install --frozen-lockfile
$ ./scripts/mock
```

Expand Down
Empty file modified bin/check-release-environment
100644 → 100755
Empty file.
5 changes: 3 additions & 2 deletions bin/publish-pypi
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

set -eux
mkdir -p dist
rye build --clean
rye publish --yes --token=$PYPI_TOKEN
rm -rf dist/*
uv build
uv publish --token="$PYPI_TOKEN"
2 changes: 1 addition & 1 deletion examples/audio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rye run python
#!/usr/bin/env -S uv run python

from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion examples/realtime/realtime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rye run python
#!/usr/bin/env -S uv run python
import asyncio

from openai import AsyncOpenAI
Expand Down
2 changes: 1 addition & 1 deletion examples/responses/background_streaming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S rye run python
#!/usr/bin/env -S uv run python
from typing import List

import rich
Expand Down
2 changes: 1 addition & 1 deletion examples/speech_to_text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rye run python
#!/usr/bin/env -S uv run python

import asyncio

Expand Down
2 changes: 1 addition & 1 deletion examples/text_to_speech.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rye run python
#!/usr/bin/env -S uv run python

import time
import asyncio
Expand Down
Loading
Loading