Skip to content

trigger rebuilds when virtualenv changes#6008

Merged
davidhewitt merged 2 commits intoPyO3:mainfrom
davidhewitt:rebuild-venv-cfg
Apr 30, 2026
Merged

trigger rebuilds when virtualenv changes#6008
davidhewitt merged 2 commits intoPyO3:mainfrom
davidhewitt:rebuild-venv-cfg

Conversation

@davidhewitt
Copy link
Copy Markdown
Member

@davidhewitt davidhewitt commented Apr 30, 2026

I realised that frequently I am attempting to test specific Python versions with commands like

UV_PYTHON=3.12 uv run cargo test --test test_compile_error

Unfortunately at the moment, even though uv recreates the venv, we don't reconfigure the build. (Full details of why are basically the same as #4882.)

I realised today that when the venv is recreated there will be a new pyvenv.cfg file created, and that will have a new mtime, so we should be able to reliably trigger a rebuild based on that.

@davidhewitt davidhewitt requested a review from ngoldbaum April 30, 2026 13:30
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will improve performance by 13.8%

⚡ 1 improved benchmark
✅ 104 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
bench_pyclass_create 4.6 µs 4 µs +13.8%

Comparing davidhewitt:rebuild-venv-cfg (9b42f6a) with main (9c734a1)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@davidhewitt davidhewitt added this pull request to the merge queue Apr 30, 2026
@ngoldbaum
Copy link
Copy Markdown
Contributor

I realised today that when the venv is recreated there will be a new pyvenv.cfg file created, and that will have a new mtime, so we should be able to reliably trigger a rebuild based on that.

Nice! This probably doesn't help my pyenv workflow which doesn't rely on virtualenvs but maybe there's similar metadata we can check for in a pyenv-managed install.

Glad to see there's a solution that will work for people who aren't doing atrocities with global Python environments like I am.

Merged via the queue into PyO3:main with commit cf4d883 Apr 30, 2026
47 checks passed
@davidhewitt davidhewitt deleted the rebuild-venv-cfg branch April 30, 2026 16:34
davidhewitt added a commit to davidhewitt/pyo3 that referenced this pull request May 1, 2026
* trigger rebuilds when virtualenv changes

* newsfragment
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.

3 participants