Skip to content

Comments

fix: refresh activation scripts from upstream virtualenv#15272

Merged
zanieb merged 3 commits intoastral-sh:mainfrom
2bndy5:activations-scripts-from-upstream-virtualenv
Sep 5, 2025
Merged

fix: refresh activation scripts from upstream virtualenv#15272
zanieb merged 3 commits intoastral-sh:mainfrom
2bndy5:activations-scripts-from-upstream-virtualenv

Conversation

@2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Aug 14, 2025

Summary

This refreshes the venv activation scripts from upstream virtualenv project.
This was largely triggered by a problem in the activate.nu script (for nushell):

I was careful to respect the git history going back to #3376 (the last time this was done).
Actually I looked at the complete history from back when this uv-virtualenv crate was named after a Pokémon (⁉️), but I found nothing (about activation scripts) from back then that hasn't been overwritten since.

Some post-processing was involved

Notable changes from upstream

Test Plan

There was a request in #14917 to add unit tests to detect breakage or errors.
I have added a CI job that runs the nushell activation script.
But I think it is better to have the CI test all/most supported shells.
See also #15294

I have tested this locally using

  • nushell (v0.106.1)
  • cmd.exe (Microsoft Windows [Version 10.0.26100.4946])
  • bash in WSL (GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu))
  • pwsh (PSVersion 5.1.26100.4768)

@zanieb
Copy link
Member

zanieb commented Aug 14, 2025

Since you mentioned it in the issue, we could do another testing strategy within our test suite, e.g., we'd add a new test-nushell feature then assume nushell is available and add a snapshot test for the activation script that's gated by the feature. Then, we'd install nushell in the Linux cargo test run. I don't really have a strong preference for now, but that does make the test more robust. Given you have this CI setup working, it's probably best to just open an issue to track afterwards.

@zanieb zanieb added the bug Something isn't working label Aug 14, 2025
@zanieb zanieb self-assigned this Aug 14, 2025
@2bndy5
Copy link
Contributor Author

2bndy5 commented Aug 14, 2025

I would actually leverage cargo-nextest's DSL and profiles to filter tests instead of conditionally compiling certain tests.

No one should be running cargo test on this project. It didn't take me long to stumble across calls to env::remove_var() or env::set_var() - both of which are unsound in async contexts (eg. parallel running tests) and require unsafe blocks in rust 2024 edition.

@charliermarsh
Copy link
Member

Are you referring to uv? Which calls are you referring to? I don't see any calls to env::remove_var, and we only have a single call to env::set_var.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Aug 14, 2025

My bad, I mis-read some function calls in uv-virtualenv::virtualenv. Since you mentioned it, I did a search on the code base: No calls to env::remove_var(), but there are currently 3 calls to env::set_var() (1 in uv::self::main() and 2 in uv_trampoline::bounce::make_child_cmdline()), all of which are wrapped in unsafe blocks. Regardless, use of cargo-nextest ensures safety obligations are met about these invocations.

@zanieb
Copy link
Member

zanieb commented Aug 15, 2025

The trampoline is a distinct binary — it's never run in the same process as a test. Similarly, most of uv's tests are integration tests that spawn a subprocess and, for the ones that don't, we're just setting a variable to the path of the uv binary, which is always safe when running concurrent instances of the same uv binary.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Aug 15, 2025

@zanieb What are the requirements of the requested test(s)? I added a nushell activation test. Do you want more tests for all other supported shell(s)? I'm of the impression that nushell needed a test to detect breakages because nushell is still in v0.x. I have only ever used bash and pwsh (with much reluctance).

@zanieb
Copy link
Member

zanieb commented Aug 15, 2025

It'd be ideal to have test coverage for them all, but I don't think it's necessary to do here! Especially if you're reluctant :) We can open an issue to track it.

@2bndy5 2bndy5 marked this pull request as ready for review August 15, 2025 01:46
@2bndy5
Copy link
Contributor Author

2bndy5 commented Aug 15, 2025

I opened #15294 to summarize the effort towards properly testing venv activation scripts

@2bndy5

This comment was marked as resolved.

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@zanieb zanieb merged commit cbcf513 into astral-sh:main Sep 5, 2025
97 checks passed
@2bndy5 2bndy5 deleted the activations-scripts-from-upstream-virtualenv branch September 5, 2025 21:19
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Sep 12, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.8.15` -> `0.8.17` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.8.17`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0817)

[Compare Source](astral-sh/uv@0.8.16...0.8.17)

Released on 2025-09-10.

##### Enhancements

- Improve error message for HTTP validation in auth services ([#&#8203;15768](astral-sh/uv#15768))
- Respect `PYX_API_URL` when suggesting `uv auth login` on 401 ([#&#8203;15774](astral-sh/uv#15774))
- Add pyx as a supported PyTorch index URL ([#&#8203;15769](astral-sh/uv#15769))

##### Bug fixes

- Avoid initiating login flow for invalid API keys ([#&#8203;15773](astral-sh/uv#15773))
- Do not search for a password for requests with a token attached already ([#&#8203;15772](astral-sh/uv#15772))
- Filter pre-release Python versions in `uv init --script` ([#&#8203;15747](astral-sh/uv#15747))

### [`v0.8.16`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0816)

[Compare Source](astral-sh/uv@0.8.15...0.8.16)

##### Enhancements

- Allow `--editable` to override `editable = false` annotations ([#&#8203;15712](astral-sh/uv#15712))
- Allow `editable = false` for workspace sources ([#&#8203;15708](astral-sh/uv#15708))
- Show a dedicated error for virtual environments in source trees on build ([#&#8203;15748](astral-sh/uv#15748))
- Support Android platform tags ([#&#8203;15646](astral-sh/uv#15646))
- Support iOS platform tags ([#&#8203;15640](astral-sh/uv#15640))
- Support scripts with inline metadata in `--with-requirements` and `--requirements` ([#&#8203;12763](astral-sh/uv#12763))

##### Preview features

- Support `--no-project` in `uv format` ([#&#8203;15572](astral-sh/uv#15572))
- Allow `uv format` in unmanaged projects ([#&#8203;15553](astral-sh/uv#15553))

##### Bug fixes

- Avoid erroring when `match-runtime` target is optional ([#&#8203;15671](astral-sh/uv#15671))
- Ban empty usernames and passwords in `uv auth` ([#&#8203;15743](astral-sh/uv#15743))
- Error early for parent path in build backend ([#&#8203;15733](astral-sh/uv#15733))
- Retry on IO errors during HTTP/2 streaming ([#&#8203;15675](astral-sh/uv#15675))
- Support recursive requirements and constraints inclusion ([#&#8203;15657](astral-sh/uv#15657))
- Use token store credentials for `uv publish` ([#&#8203;15759](astral-sh/uv#15759))
- Fix virtual environment activation script compatibility with latest nushell ([#&#8203;15272](astral-sh/uv#15272))
- Skip Python interpreters that cannot be queried with permission errors ([#&#8203;15685](astral-sh/uv#15685))

##### Documentation

- Clarify that `uv auth` commands take a URL ([#&#8203;15664](astral-sh/uv#15664))
- Improve the CLI help for options that accept requirements files ([#&#8203;15706](astral-sh/uv#15706))
- Adds example for caching for managed Python downloads in Docker builds ([#&#8203;15689](astral-sh/uv#15689))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45OC4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTkuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants