Skip to content

build(python): migrate samples to pyproject.toml and uv - #345

Open
harveymmaunders wants to merge 2 commits into
morganstanley:mainfrom
harveymmaunders:feature/python-uv-pyproject
Open

harveymmaunders wants to merge 2 commits into
morganstanley:mainfrom
harveymmaunders:feature/python-uv-pyproject

Conversation

@harveymmaunders

Copy link
Copy Markdown
Member

Summary

Moves the Python REST and WebSocket client samples from requirements.txt / dev-requirements.txt + pip to pyproject.toml + uv.lock, managed with uv.

Changes

  • pyproject.toml for both samples: runtime deps in [project.dependencies], test/lint tools in a dev dependency group (PEP 735). Versions are unchanged from the old requirements files. uv.lock and .python-version are committed.
  • WebSocket project name: the project is named python-websockets-client-sample because a project called websockets clashes with the websockets test dependency.
  • requires-python = ">=3.11" to match the CI matrix (3.11–3.15). The READMEs previously said both 3.9+ and 3.10+.
  • CI (python-base-ci.yml): uses astral-sh/setup-uv with the matrix Python version and caching, then uv sync --locked, uv run pytest and uv run black --check. There are no pip steps left.
  • Dependabot: the Python entries use the uv ecosystem instead of pip.
  • READMEs: uv is the main setup route (uv sync / uv run ...), with a plain pip fallback for people who don't use uv:
    python -m venv .venv && . .venv/bin/activate
    python -m pip install --upgrade pip   # needs pip >= 25.1 for --group
    pip install . --group dev

Testing

  • uv run pytest tests/ and uv run black --check . pass on Python 3.15 and 3.11 for both samples (REST: 7 tests, WebSockets: 4 tests).
  • In a fresh Python 3.11 venv with no uv, pip install . --group dev followed by pytest passes for both samples.

🤖 Generated with Claude Code

@harveymmaunders
harveymmaunders requested a review from a team as a code owner October 30, 2026 17:05
Harvey Maunders and others added 2 commits October 30, 2026 17:34
- Replace requirements.txt/dev-requirements.txt with pyproject.toml
  (dev tools in a dependency group) and a committed uv.lock for both
  the REST and WebSocket samples
- Rename the WebSocket project so it no longer clashes with the
  websockets test dependency; require Python >=3.11 to match CI
- Run CI through astral-sh/setup-uv (uv sync --locked, uv run)
- Switch Dependabot from the pip to the uv ecosystem
- Update READMEs to use uv, with a plain pip fallback
  (pip install . --group dev) for users who don't use uv

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
astral-sh/setup-uv does not publish a floating v10 tag, so @v10 fails to resolve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@harveymmaunders
harveymmaunders force-pushed the feature/python-uv-pyproject branch from 006ac82 to 92ca005 Compare October 30, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant