Skip to content

Use dependency groups for Python SDK tooling#27538

Merged
charliemarsh-oai merged 3 commits into
mainfrom
charlie/python-sdk-dependency-groups
Jun 12, 2026
Merged

Use dependency groups for Python SDK tooling#27538
charliemarsh-oai merged 3 commits into
mainfrom
charlie/python-sdk-dependency-groups

Conversation

@charliemarsh-oai

Copy link
Copy Markdown
Contributor

Summary

just fmt previously used uv run --with ruff to make Ruff available. Because --with creates an ephemeral overlay outside the project lockfile, uv periodically re-resolved Ruff (by default every 10 minutes) instead of using the version recorded in uv.lock.

Move the Python SDK tooling dependencies from the published dev extra into format, test, and composed dev dependency groups. The formatter now selects only the locked format group, contributor and CI setup explicitly sync the dev group, and CI and release commands reuse that environment with --frozen --no-sync. The scripts formatter also uses its project's locked Ruff dependency instead of an ephemeral overlay.

Validated the Python 3.12 SDK suite (119 passed, 38 skipped) and the repository formatter.

Comment thread .github/workflows/sdk.yml
/tmp/uv/bin/uv run --extra dev ruff format --check .
/tmp/uv/bin/uv run --extra dev pytest
/tmp/uv/bin/uv sync --group dev --frozen
/tmp/uv/bin/uv run --frozen --no-sync ruff check --output-format=github .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added --frozen --no-sync here since the intent seems to be to sync once upfront, then run in that environment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using an initial sync with subsequent --no-sync for performance here? It seems like we should just be using uv run --frozen without an initial sync. I think that's separate in intent from this change though.

Comment thread sdk/python/pyproject.toml
@@ -24,8 +24,17 @@ Repository = "https://github.com/openai/codex"
Issues = "https://github.com/openai/codex/issues"
Documentation = "https://github.com/openai/codex/tree/main/sdk/python/docs"

[project.optional-dependencies]
dev = ["pytest>=8.0", "datamodel-code-generator==0.31.2", "ruff>=0.15.8"]
[dependency-groups]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependency-groups have the crucial property that they can be installed without installing the project itself (which is, I think, the intent of the flow in the justfile: install Ruff, but not the project).

@charliemarsh-oai charliemarsh-oai marked this pull request as ready for review June 11, 2026 04:21
Comment thread scripts/format.py
"--frozen",
"--project",
"scripts",
"--no-sync",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also use --only-group?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts only defines this one dependency; we could move it to a group but I guess the project itself is dev-only.

"--frozen",
"--project",
"scripts",
"--no-sync",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread scripts/format.py
Comment on lines 57 to 66
sdk_format_args = [
*sdk_uv_run_args,
"ruff",
"format",
]
scripts_format_args = [
*scripts_uv_run_args,
"ruff",
"format",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these use uv format instead of the complex uv run thing?

@charliemarsh-oai charliemarsh-oai enabled auto-merge (squash) June 12, 2026 16:01
@charliemarsh-oai charliemarsh-oai merged commit c375dea into main Jun 12, 2026
31 checks passed
@charliemarsh-oai charliemarsh-oai deleted the charlie/python-sdk-dependency-groups branch June 12, 2026 16:10
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants