ITADN

Pex isn't actually caching the wheels it builds

#3143Closedbenjyw 创建于 2026-04-05
in progress
B
benjywcommented
Consider ``` # NB: python-ldap has no wheels on pypi, just an sdist. $ pex -v python-ldap==3.4.5 --output-file python-ldap.pex $ pex -v python-ldap==3.4.5 --output-file python-ldap.pex ``` You can see in the timing of the BuildRequest in the debug logs that Pex rebuilds the wheel on every run. To the best of my understanding, this is because in `_categorize_build_requests()` the [BuildResult is created](https://github.com/pex-tool/pex/blob/v2.92.0/pex/resolver.py#L1052) without specifying a `source_path`, but in `_spawn_wheel_build` the BuildResult is passed a [(subdir of a) tmpdir](https://github.com/pex-tool/pex/blob/v2.92.0/pex/resolver.py#L692) as [`source_path`](https://github.com/pex-tool/pex/blob/v2.92.0/pex/resolver.py#L1074), which overrides `BuildRequest.source_path`. And since in `BuiltWheelDir` the `dist_dir` is a subdir of the `sdist_dir`, the build output goes under that tmpdir, and the permanent cache location for the BuildRequest is never finalized. That would imply that this issue was introduced in #2766 (and indeed this happens at that commit but not prior to it). Things seem to work as expected if I naively remove setting `source_path` on the BuildResult in `_spawn_wheel_build`, as the original. But presumably that's there for a reason, and a proper solution would be more involved.
关闭于 2026-04-06 5 条评论