Skip to content

[ci][deps] Pin virtualenv==20.29.1 to restore pkg_resources in runtime envs - #64739

Closed
elliot-barn wants to merge 5 commits into
masterfrom
elliot-barn-repin-virtualenv-pkg-resources
Closed

elliot-barn wants to merge 5 commits into
masterfrom
elliot-barn-repin-virtualenv-pkg-resources

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Why

Postmerge on master is failing //python/ray/tests:test_runtime_env_uv::test_uv_with_version_and_check (Windows py3.10) with:

ModuleNotFoundError: No module named 'pkg_resources'

Root cause

The unify-deps change (#64257) floated virtualenv from 20.29.1 → 21.2.4 in the compiled lock, because the source constraint in test-requirements.txt was the open-ended virtualenv>=20.29.

Ray's uv/pip runtime envs create their venv with virtualenv --no-download (python/ray/_private/runtime_env/virtualenv_utils.py), so they seed virtualenv's bundled setuptools wheel:

virtualenv bundled setuptools pkg_resources?
20.29.1 75.3.0 / 75.8.0 ✅ present
21.2.4 82.0.1 / 83.0.0 ❌ removed in setuptools 82.0.0

setuptools 82.0.0 removed the pkg_resources module. On Python <3.12 (3.12+ already skips seeding setuptools), the runtime-env venv therefore no longer has pkg_resources, so import pkg_resources fails — both in the test and for any real user whose runtime-env code (or a transitive dep) imports it.

The failure is deterministic (fails both --flaky_test_attempts), not flaky.

What

  • Pin virtualenv==20.29.1 in python/requirements/test-requirements.txt (with an explanatory comment).
  • Recompile requirements_compiled.txt.

The only lock changes are the virtualenv downgrade and dropping python-discovery (a dependency that virtualenv 21 introduced when it split out its discovery logic). No other pins move.

Follow-up

When we do intentionally move to virtualenv 21+, pair it with migrating the test off pkg_resources (→ importlib.metadata) and a release note, since seeded runtime envs will stop providing pkg_resources on Python <3.12.

🤖 Generated with Claude Code

…e envs

virtualenv 21.x bundles setuptools>=82, which removed the pkg_resources
module. Ray's uv/pip runtime envs seed virtualenv's bundled setuptools
(the venv is created with --no-download), so virtualenv>=21 breaks
`import pkg_resources` inside those envs on Python <3.12 -- e.g.
test_runtime_env_uv::test_uv_with_version_and_check fails deterministically
on postmerge.

Pin virtualenv==20.29.1 (bundles setuptools 75.x) and recompile the lock.
The only resulting lock changes are the virtualenv downgrade and dropping
the python-discovery dependency that virtualenv 21 introduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn
elliot-barn requested a review from a team as a code owner July 14, 2026 05:24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request pins the virtualenv dependency to version 20.29.1 in both test-requirements.txt and requirements_compiled.txt. This change prevents issues with pkg_resources being removed in setuptools>=82 (which is bundled in virtualenv 21.x) on Python versions older than 3.12. Additionally, the unused transitive dependency python-discovery has been removed. There are no review comments, so I have no feedback to provide.

Comment thread python/requirements_compiled.txt Resolved
@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Jul 14, 2026
@elliot-barn
elliot-barn requested a review from edoakes July 14, 2026 18:08
The virtualenv==20.29.1 pin changed requirements_compiled.txt but not the
parallel raydepsets lock files under python/deplocks/, so
`raydepsets build --all-configs --check` failed (postmerge job
'raydepsets: compile all dependencies').

Regenerate via 'bazel run //ci/raydepsets:raydepsets -- build --all-configs'.
Diff is limited to virtualenv 21.2.4 -> 20.29.1 and dropping python-discovery
(virtualenv 21's split-out dependency) across 66 core/ci/ml/data locks; no
other pins move. LLM and py3.14 locks float from separate requirement sets
and are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn
elliot-barn requested a review from a team as a code owner July 15, 2026 00:08
@elliot-barn elliot-barn added the go add ONLY when ready to merge, run all tests label Jul 18, 2026
elliot-barn added a commit that referenced this pull request Jul 18, 2026
Three independent Windows-only breaks, all verified against postmerge
builds 18675/18684:

- generator_waiter_test.cc: MSVC C2131 — a by-ref-captured constexpr
  local used as an array bound inside a lambda is not a constant
  expression to MSVC. Make the test constants static constexpr. Broken
  since #64383.

- test_streaming_generator: move from the medium to the large shard.
  Passing Windows runs take ~296s against the moderate 300s limit
  (build 18675: PASSED in 296.2s; build 18684: TIMEOUT at 300s in 2/2
  attempts, mid-suite at test 21-22 of 23) — it is slow, not hung.

- test_runtime_env_uv::test_uv_with_version_and_check: use
  importlib.metadata instead of pkg_resources. virtualenv >= 21 (bumped
  in #64257) no longer seeds setuptools into the venvs Ray creates, and
  setuptools >= 83 removed pkg_resources entirely, so the test must not
  depend on it regardless of the virtualenv pin decision in #64739.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
elliot-barn added a commit that referenced this pull request Jul 19, 2026
…ile error, streaming-generator timeout, uv test (#64865)

## Why are these changes needed?

Fixes all four Windows test failures on master postmerge (builds
18675/18684). Windows tests run only on release-automation-triggered
postmerge builds, so these landed silently.

### 1. `test_experimental_collective` — torch gloo broken on Windows
(pin torch 2.7.0)

Fails since #64257 bumped torch `2.7.0 → 2.9.0`:

```
RuntimeError: makeDeviceForHostname(): unsupported gloo device
```

torch 2.8/2.9 stock Windows wheels are built **without libuv**, and
gloo's TCP transport is Linux-only, so `torch.distributed`'s gloo
backend cannot initialize at all on Windows (pytorch/pytorch#150381).
Fixed upstream via pytorch/gloo#472, shipped in torch **2.10** and
explicitly not cherry-picked into 2.9.x. Ray's own postmerge bisection
(builds 18569–18574) confirmed #64257 as first-bad; Linux/macOS are
unaffected.

The windowsbuild image previously pip-installed its test deps
constrained by `requirements_compiled.txt` directly, so there was no
depset to override. This brings it under raydepsets
(`ci_windows.depsets.yaml`), mirroring the relax/expand pattern from
`ci_data.depsets.yaml`:

- `windows_tests_ci_depset_310` — compile `requirements.txt` +
`test-requirements.txt` + `dl-cpu-requirements.txt` for windows/py3.10
constrained by `requirements_compiled` (same inputs `build_base.sh`
used).
- `relaxed_windows_tests_ci_depset_310` — relax torch, torchvision, and
the ABI-coupled PyG binaries.
- `windows_tests_torch27_ci_depset_310` — expand with
`python/requirements/windows-requirements.txt`: `torch==2.7.0`,
`torchvision==0.22.0`, and the `+pt27cpu` PyG local builds (explicit
local tags because the relaxed lock still emits the torch-2.9.0
find-links and unsafe-best-match would otherwise re-pick `+pt29cpu`).

`build_base.sh` installs the final lock hash-stripped with `--no-deps`
(same pattern as `ci/ray_ci/macos/macos_ci.sh`). The wanda srcs now key
on the lock instead of the four requirements files. The final lock
differs from the base resolution by exactly the six torch packages.
Windows **wheel** builds are unaffected (hermetic `uv run` env in
`build-wheel-windows.sh`). Delete `windows-requirements.txt` and the
torch2.7 depsets once the repo-wide torch pin reaches ≥2.10.

### 2. `generator_waiter_test` — MSVC C2131 compile error (cpp tests
job)

Broken since #64383: a by-ref-captured `constexpr` local used as an
array bound inside a lambda is not a constant expression to MSVC. Make
the test constants `static constexpr`.

### 3. `test_streaming_generator` — timeout, moved to the large shard

Passing Windows runs take ~296s against the moderate (300s) limit (build
18675: PASSED in 296.2s; build 18684: TIMEOUT at 300s in 2/2 attempts,
dying mid-suite at test 21–22 of 23) — legitimately slow, not hung. The
Windows job selects `//python/ray/tests/...` by path, so the size-tag
move keeps Windows coverage.

### 4. `test_runtime_env_uv::test_uv_with_version_and_check` —
pkg_resources removed

Use `importlib.metadata` instead of `pkg_resources`: virtualenv ≥21
(bumped in #64257) no longer seeds setuptools into the venvs Ray
creates, and setuptools ≥83 removed `pkg_resources` entirely, so the
test must not depend on it regardless of the virtualenv pin decision in
#64739. Ray's non-test code has zero pkg_resources usage.

## Related issue number

Root causes: upstream pytorch/pytorch#150381 (item 1); regressions
introduced by #64257 (items 1, 4) and #64383 (item 2).

## Checks

- Not a duplicate: searched open PRs — none address the Windows
gloo/torch failure, the MSVC break, or the streaming-generator timeout.
#64739 (virtualenv pin) is complementary: item 4 here makes the test
independent of that decision.
- Tests run locally: `bazel run //ci/raydepsets:raydepsets -- build
ci/raydepsets/configs/ci_windows.depsets.yaml` (all depsets compile;
final lock pins `torch==2.7.0+cpu`, diff vs base is exactly the six
torch packages); `bazel query` confirms `test_streaming_generator` is a
unique target with `size = large`; `pre-commit` passed on all changed
files. Windows image build + test runs can only be validated in CI —
watch `windowsbuild` (cold rebuild expected) and the Windows cpp/python
test jobs on this PR.
- AI assistance was used for this change (diagnosis and implementation);
reviewed and submitted by a human.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0cb9fed. Configure here.

--hash=sha256:b294ef68192638004d72524ce7ef303e9d0cf5a44c95ce2e54a7500a6381cada
virtualenv==20.29.1 \
--hash=sha256:4e4cb403c0b0da39e13b46b1b2476e505cb0046b25f242bee80f62bf990b2779 \
--hash=sha256:b8b8970138d32fb606192cb97f6cd4bb644fa486be9308fb9b63f81091b5dc35

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Windows locks still on virtualenv 21

High Severity

The pin and most lock regenerations move virtualenv to 20.29.1, but the Windows CI depsets still resolve to virtualenv==21.2.4 (with python-discovery). Those locks are what Windows postmerge installs, so test_runtime_env_uv on Windows py3.10 will keep hitting ModuleNotFoundError: No module named 'pkg_resources'.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0cb9fed. Configure here.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 12, 2026
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ile error, streaming-generator timeout, uv test (ray-project#64865)

## Why are these changes needed?

Fixes all four Windows test failures on master postmerge (builds
18675/18684). Windows tests run only on release-automation-triggered
postmerge builds, so these landed silently.

### 1. `test_experimental_collective` — torch gloo broken on Windows
(pin torch 2.7.0)

Fails since ray-project#64257 bumped torch `2.7.0 → 2.9.0`:

```
RuntimeError: makeDeviceForHostname(): unsupported gloo device
```

torch 2.8/2.9 stock Windows wheels are built **without libuv**, and
gloo's TCP transport is Linux-only, so `torch.distributed`'s gloo
backend cannot initialize at all on Windows (pytorch/pytorch#150381).
Fixed upstream via pytorch/gloo#472, shipped in torch **2.10** and
explicitly not cherry-picked into 2.9.x. Ray's own postmerge bisection
(builds 18569–18574) confirmed ray-project#64257 as first-bad; Linux/macOS are
unaffected.

The windowsbuild image previously pip-installed its test deps
constrained by `requirements_compiled.txt` directly, so there was no
depset to override. This brings it under raydepsets
(`ci_windows.depsets.yaml`), mirroring the relax/expand pattern from
`ci_data.depsets.yaml`:

- `windows_tests_ci_depset_310` — compile `requirements.txt` +
`test-requirements.txt` + `dl-cpu-requirements.txt` for windows/py3.10
constrained by `requirements_compiled` (same inputs `build_base.sh`
used).
- `relaxed_windows_tests_ci_depset_310` — relax torch, torchvision, and
the ABI-coupled PyG binaries.
- `windows_tests_torch27_ci_depset_310` — expand with
`python/requirements/windows-requirements.txt`: `torch==2.7.0`,
`torchvision==0.22.0`, and the `+pt27cpu` PyG local builds (explicit
local tags because the relaxed lock still emits the torch-2.9.0
find-links and unsafe-best-match would otherwise re-pick `+pt29cpu`).

`build_base.sh` installs the final lock hash-stripped with `--no-deps`
(same pattern as `ci/ray_ci/macos/macos_ci.sh`). The wanda srcs now key
on the lock instead of the four requirements files. The final lock
differs from the base resolution by exactly the six torch packages.
Windows **wheel** builds are unaffected (hermetic `uv run` env in
`build-wheel-windows.sh`). Delete `windows-requirements.txt` and the
torch2.7 depsets once the repo-wide torch pin reaches ≥2.10.

### 2. `generator_waiter_test` — MSVC C2131 compile error (cpp tests
job)

Broken since ray-project#64383: a by-ref-captured `constexpr` local used as an
array bound inside a lambda is not a constant expression to MSVC. Make
the test constants `static constexpr`.

### 3. `test_streaming_generator` — timeout, moved to the large shard

Passing Windows runs take ~296s against the moderate (300s) limit (build
18675: PASSED in 296.2s; build 18684: TIMEOUT at 300s in 2/2 attempts,
dying mid-suite at test 21–22 of 23) — legitimately slow, not hung. The
Windows job selects `//python/ray/tests/...` by path, so the size-tag
move keeps Windows coverage.

### 4. `test_runtime_env_uv::test_uv_with_version_and_check` —
pkg_resources removed

Use `importlib.metadata` instead of `pkg_resources`: virtualenv ≥21
(bumped in ray-project#64257) no longer seeds setuptools into the venvs Ray
creates, and setuptools ≥83 removed `pkg_resources` entirely, so the
test must not depend on it regardless of the virtualenv pin decision in
ray-project#64739. Ray's non-test code has zero pkg_resources usage.

## Related issue number

Root causes: upstream pytorch/pytorch#150381 (item 1); regressions
introduced by ray-project#64257 (items 1, 4) and ray-project#64383 (item 2).

## Checks

- Not a duplicate: searched open PRs — none address the Windows
gloo/torch failure, the MSVC break, or the streaming-generator timeout.
ray-project#64739 (virtualenv pin) is complementary: item 4 here makes the test
independent of that decision.
- Tests run locally: `bazel run //ci/raydepsets:raydepsets -- build
ci/raydepsets/configs/ci_windows.depsets.yaml` (all depsets compile;
final lock pins `torch==2.7.0+cpu`, diff vs base is exactly the six
torch packages); `bazel query` confirms `test_streaming_generator` is a
unique target with `size = large`; `pre-commit` passed on all changed
files. Windows image build + test runs can only be validated in CI —
watch `windowsbuild` (cold rebuild expected) and the Windows cpp/python
test jobs on this PR.
- AI assistance was used for this change (diagnosis and implementation);
reviewed and submitted by a human.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Signed-off-by: 400Ping <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

@github-actions github-actions Bot closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant