Skip to content

Commit 2ce26d1

Browse files
sentry-junior[bot]sl0thentr0pyclaude
authored
ci(tox): migrate from pip to uv via tox-uv (#6390)
## Description * add `uv` and `tox-uv` to manage python envs and packages instead of `pip` * use `astral-sh/setup-uv` action in CI instead of `setup-python`, top-level `uv` always uses `python3.14` * except for 3.6 and 3.7, all python versions now go through `tox-uv` * 3.6 and 3.7 have their own containers which `uv` picks up through `UV_PYTHON_REFERENCE` * the SDK is now installed as part of `deps` and not via `package` so `uv` resolves all deps in a single pass, this was necessary since `uv` resolution is stricter than `pip` * `runtox.sh` also uses `uv run tox` * some other pins were necessary to make CI pass * pre-releases need a special `UV_PRERELEASE=ALL` for resolution to work, we do not relax this throughout because `uv` then fetches pre-releases for httpx and such breaking half the matrix ### Dev Flow Changes No need for `asdf` or `pyenv` now if you were using it before, just use `uv`, it will manage both `tox` and required python versions internally. New commands: - List tox envs: `uv run tox l` - Integration tests: `uv run tox -e py3.14-{integration}-v{version}` - Common tests: `uv run tox -e py3.14-common` - Run specific test file: `TESTPATH=tests/integrations/logging/test_logging.py uv run tox -e py3.14-common` - Run single test: `TESTPATH=tests/path/to/test_file.py uv run tox -e py3.14-common -- -k "test_name"` ### TODO * [ ] coverage (which is a mess anyway) * [x] dev flow with `uv` as well - linters, top level tox, test file generation all managed with `uv` * [x] ruff: #6430 * [x] mypy: #6436 * [x] scripts/dist/apidocs/aws: #6439 * [ ] dev flow docs (asdf) for python 3.6/3.7 since `uv` does not manage those --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Neel Shah <neel.shah@sentry.io> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8a4062b commit 2ce26d1

55 files changed

Lines changed: 2623 additions & 971 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"Bash(.tox/*/bin/ruff:*)",
3939
"Bash(ruff format:*)",
4040
"Bash(ruff check:*)",
41-
"Bash(mypy:*)"
41+
"Bash(mypy:*)",
42+
"Bash(uv run *)"
4243
],
4344
"deny": []
4445
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.jsonl -diff linguist-generated=true
2+
uv.lock -diff linguist-generated=true

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-->
99

1010
#### Reminders
11-
- Please add tests to validate your changes, and lint your code using `tox -e linters`.
11+
- Please add tests to validate your changes, and lint your code using `uv run ruff`.
1212
- Add GH Issue ID _&_ Linear ID (if applicable)
1313
- PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`)
1414
- For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)

.github/workflows/ci.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ concurrency:
1515
permissions:
1616
contents: read
1717

18-
env:
19-
BUILD_CACHE_KEY: ${{ github.sha }}
20-
CACHED_BUILD_PATHS: |
21-
${{ github.workspace }}/dist-serverless
22-
2318
jobs:
2419
lint:
2520
name: Lint Sources
@@ -28,13 +23,22 @@ jobs:
2823

2924
steps:
3025
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
3228
with:
3329
python-version: 3.14
3430

35-
- run: |
36-
pip install tox
37-
tox -e linters
31+
- name: Ruff check
32+
run: uv run ruff check tests sentry_sdk
33+
34+
- name: Ruff format
35+
run: uv run ruff format --check tests sentry_sdk
36+
37+
- name: Find raise from None
38+
run: uv run python scripts/find_raise_from_none.py
39+
40+
- name: Mypy
41+
run: uv run --group typing mypy sentry_sdk
3842

3943
build_lambda_layer:
4044
name: Build Package
@@ -43,20 +47,16 @@ jobs:
4347

4448
steps:
4549
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
47-
with:
48-
python-version: 3.12
49-
- name: Setup build cache
50-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
51-
id: build_cache
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
5252
with:
53-
path: ${{ env.CACHED_BUILD_PATHS }}
54-
key: ${{ env.BUILD_CACHE_KEY }}
53+
python-version: 3.14
5554
- name: Build Packages
5655
run: |
57-
echo "Creating directory containing Python SDK Lambda Layer"
58-
# This will also trigger "make dist" that creates the Python packages
59-
make aws-lambda-layer
56+
echo "Building SDK dist wheel and tar.gz"
57+
uv build
58+
echo "Building AWS Lambda Layer"
59+
uv run --group aws --with-editable . python scripts/build_aws_lambda_layer.py
6060
- name: Upload Python Packages
6161
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
6262
with:
@@ -72,12 +72,14 @@ jobs:
7272

7373
steps:
7474
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
75-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
7677
with:
77-
python-version: 3.12
78+
python-version: 3.14
7879

7980
- run: |
80-
make apidocs
81+
rm -rf docs/_build
82+
uv run --group docs sphinx-build -vv -W -b html docs/ docs/_build
8183
cd docs/_build && zip -r gh-pages ./
8284
8385
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7

.github/workflows/test-integrations-agents.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ permissions:
2020
actions: read
2121
pull-requests: write
2222
statuses: write
23-
env:
24-
BUILD_CACHE_KEY: ${{ github.sha }}
25-
CACHED_BUILD_PATHS: |
26-
${{ github.workspace }}/dist-serverless
2723
jobs:
2824
test-agents:
2925
name: Agents
@@ -33,26 +29,28 @@ jobs:
3329
fail-fast: false
3430
matrix:
3531
python-version: ["3.10","3.11","3.12","3.13","3.14","3.14t"]
36-
# python3.6 reached EOL and is no longer being supported on
37-
# new versions of hosted runners on Github Actions
38-
# ubuntu-20.04 is the last version that supported python3.6
39-
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
4032
os: [ubuntu-22.04]
41-
# Use Docker container only for Python 3.6
42-
container: ${{ matrix.python-version == '3.6' && 'python:3.6' || null }}
33+
env:
34+
# 3.6/3.7 run in the python:X.Y container; tell uv to use that system Python.
35+
TOX_UV_PYTHON_PREFERENCE: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && 'only-system' || 'managed' }}
36+
container: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && format('python:{0}', matrix.python-version) || null }}
4337
steps:
4438
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
46-
if: ${{ matrix.python-version != '3.6' }}
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4741
with:
48-
python-version: ${{ matrix.python-version }}
49-
allow-prereleases: true
42+
cache-suffix: ${{ github.workflow }}-${{ matrix.python-version }}
43+
- name: Mark workspace safe for git (3.6/3.7 container)
44+
# needed to make git rev-parse work in the containers
45+
# subprocesses (e.g. sentry_sdk.utils.get_git_revision) can run git.
46+
if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }}
47+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
5048
- name: Setup Test Env
5149
run: |
52-
pip install "coverage[toml]" tox
50+
uv sync
5351
- name: Erase coverage
5452
run: |
55-
coverage erase
53+
uv run coverage erase
5654
- name: Test openai_agents
5755
run: |
5856
set -x # print commands that are executed
@@ -61,17 +59,11 @@ jobs:
6159
run: |
6260
set -x # print commands that are executed
6361
./scripts/runtox.sh "py${{ matrix.python-version }}-pydantic_ai"
64-
- name: Generate coverage XML (Python 3.6)
65-
if: ${{ !cancelled() && matrix.python-version == '3.6' }}
66-
run: |
67-
export COVERAGE_RCFILE=.coveragerc36
68-
coverage combine .coverage-sentry-*
69-
coverage xml --ignore-errors
7062
- name: Generate coverage XML
71-
if: ${{ !cancelled() && matrix.python-version != '3.6' }}
63+
if: ${{ !cancelled() }}
7264
run: |
73-
coverage combine .coverage-sentry-*
74-
coverage xml
65+
uv run coverage combine .coverage-sentry-*
66+
uv run coverage xml
7567
- name: Parse and Upload Coverage
7668
if: ${{ !cancelled() }}
7769
uses: getsentry/codecov-action@d90e69cdf071dfbb0430159125321dc09c424d4c # main

.github/workflows/test-integrations-ai-workflow.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ permissions:
2020
actions: read
2121
pull-requests: write
2222
statuses: write
23-
env:
24-
BUILD_CACHE_KEY: ${{ github.sha }}
25-
CACHED_BUILD_PATHS: |
26-
${{ github.workspace }}/dist-serverless
2723
jobs:
2824
test-ai_workflow:
2925
name: AI Workflow
@@ -33,26 +29,28 @@ jobs:
3329
fail-fast: false
3430
matrix:
3531
python-version: ["3.9","3.10","3.11","3.12","3.13","3.14"]
36-
# python3.6 reached EOL and is no longer being supported on
37-
# new versions of hosted runners on Github Actions
38-
# ubuntu-20.04 is the last version that supported python3.6
39-
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
4032
os: [ubuntu-22.04]
41-
# Use Docker container only for Python 3.6
42-
container: ${{ matrix.python-version == '3.6' && 'python:3.6' || null }}
33+
env:
34+
# 3.6/3.7 run in the python:X.Y container; tell uv to use that system Python.
35+
TOX_UV_PYTHON_PREFERENCE: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && 'only-system' || 'managed' }}
36+
container: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && format('python:{0}', matrix.python-version) || null }}
4337
steps:
4438
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
46-
if: ${{ matrix.python-version != '3.6' }}
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4741
with:
48-
python-version: ${{ matrix.python-version }}
49-
allow-prereleases: true
42+
cache-suffix: ${{ github.workflow }}-${{ matrix.python-version }}
43+
- name: Mark workspace safe for git (3.6/3.7 container)
44+
# needed to make git rev-parse work in the containers
45+
# subprocesses (e.g. sentry_sdk.utils.get_git_revision) can run git.
46+
if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }}
47+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
5048
- name: Setup Test Env
5149
run: |
52-
pip install "coverage[toml]" tox
50+
uv sync
5351
- name: Erase coverage
5452
run: |
55-
coverage erase
53+
uv run coverage erase
5654
- name: Test langchain-base
5755
run: |
5856
set -x # print commands that are executed
@@ -65,17 +63,11 @@ jobs:
6563
run: |
6664
set -x # print commands that are executed
6765
./scripts/runtox.sh "py${{ matrix.python-version }}-langgraph"
68-
- name: Generate coverage XML (Python 3.6)
69-
if: ${{ !cancelled() && matrix.python-version == '3.6' }}
70-
run: |
71-
export COVERAGE_RCFILE=.coveragerc36
72-
coverage combine .coverage-sentry-*
73-
coverage xml --ignore-errors
7466
- name: Generate coverage XML
75-
if: ${{ !cancelled() && matrix.python-version != '3.6' }}
67+
if: ${{ !cancelled() }}
7668
run: |
77-
coverage combine .coverage-sentry-*
78-
coverage xml
69+
uv run coverage combine .coverage-sentry-*
70+
uv run coverage xml
7971
- name: Parse and Upload Coverage
8072
if: ${{ !cancelled() }}
8173
uses: getsentry/codecov-action@d90e69cdf071dfbb0430159125321dc09c424d4c # main

.github/workflows/test-integrations-ai.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ permissions:
2020
actions: read
2121
pull-requests: write
2222
statuses: write
23-
env:
24-
BUILD_CACHE_KEY: ${{ github.sha }}
25-
CACHED_BUILD_PATHS: |
26-
${{ github.workspace }}/dist-serverless
2723
jobs:
2824
test-ai:
2925
name: AI
@@ -33,26 +29,28 @@ jobs:
3329
fail-fast: false
3430
matrix:
3531
python-version: ["3.8","3.9","3.10","3.11","3.12","3.13","3.14","3.14t"]
36-
# python3.6 reached EOL and is no longer being supported on
37-
# new versions of hosted runners on Github Actions
38-
# ubuntu-20.04 is the last version that supported python3.6
39-
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
4032
os: [ubuntu-22.04]
41-
# Use Docker container only for Python 3.6
42-
container: ${{ matrix.python-version == '3.6' && 'python:3.6' || null }}
33+
env:
34+
# 3.6/3.7 run in the python:X.Y container; tell uv to use that system Python.
35+
TOX_UV_PYTHON_PREFERENCE: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && 'only-system' || 'managed' }}
36+
container: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && format('python:{0}', matrix.python-version) || null }}
4337
steps:
4438
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
46-
if: ${{ matrix.python-version != '3.6' }}
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4741
with:
48-
python-version: ${{ matrix.python-version }}
49-
allow-prereleases: true
42+
cache-suffix: ${{ github.workflow }}-${{ matrix.python-version }}
43+
- name: Mark workspace safe for git (3.6/3.7 container)
44+
# needed to make git rev-parse work in the containers
45+
# subprocesses (e.g. sentry_sdk.utils.get_git_revision) can run git.
46+
if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }}
47+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
5048
- name: Setup Test Env
5149
run: |
52-
pip install "coverage[toml]" tox
50+
uv sync
5351
- name: Erase coverage
5452
run: |
55-
coverage erase
53+
uv run coverage erase
5654
- name: Test anthropic
5755
run: |
5856
set -x # print commands that are executed
@@ -81,17 +79,11 @@ jobs:
8179
run: |
8280
set -x # print commands that are executed
8381
./scripts/runtox.sh "py${{ matrix.python-version }}-openai-notiktoken"
84-
- name: Generate coverage XML (Python 3.6)
85-
if: ${{ !cancelled() && matrix.python-version == '3.6' }}
86-
run: |
87-
export COVERAGE_RCFILE=.coveragerc36
88-
coverage combine .coverage-sentry-*
89-
coverage xml --ignore-errors
9082
- name: Generate coverage XML
91-
if: ${{ !cancelled() && matrix.python-version != '3.6' }}
83+
if: ${{ !cancelled() }}
9284
run: |
93-
coverage combine .coverage-sentry-*
94-
coverage xml
85+
uv run coverage combine .coverage-sentry-*
86+
uv run coverage xml
9587
- name: Parse and Upload Coverage
9688
if: ${{ !cancelled() }}
9789
uses: getsentry/codecov-action@d90e69cdf071dfbb0430159125321dc09c424d4c # main

0 commit comments

Comments
 (0)