fix: refresh activation scripts from upstream virtualenv (#15272)

## 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):
- #14888 
- #14914 
- #14917 

I was careful to respect the git history going back to astral-sh/uv#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

- Retained license info at top of scripts
- Retained template vars (eg `{{ BIN_PATH }}`) to assure current support
toward relocatable venv
- Retained deviation from upstream in astral-sh/uv#5640. This seems to
be the only deviation that isn't in sync with upstream.

### Notable changes from upstream

- (omitted due to undesirable complexity) pypa/virtualenv#2928 and its
follow-up pypa/virtualenv#2940
- pypa/virtualenv#2910 (what prompted astral-sh/uv#14917 from
astral-sh/uv#14888)

## 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

- [x] nushell (v0.106.1)
- [x] cmd.exe (Microsoft Windows [Version 10.0.26100.4946])
- [x] bash in WSL (GNU bash, version 5.1.16(1)-release
(x86_64-pc-linux-gnu))
- [x] pwsh (PSVersion 5.1.26100.4768)
This commit is contained in:
Brendan
2025-09-05 14:12:37 -07:00
committed by GitHub
parent c59ead398d
commit cbcf51391f
8 changed files with 160 additions and 75 deletions
+48
View File
@@ -1011,6 +1011,54 @@ jobs:
run: |
(& ./uvx --generate-shell-completion powershell) | Out-String | Invoke-Expression
integration-test-nushell:
timeout-minutes: 10
needs: build-binary-linux-libc
name: "integration test | activate nushell venv"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install nushell
env:
# This token only needs read access to the GitHub repository nushell/nushell.
# This token is used (via gh-cli) to avoid hitting GitHub REST API rate limits.
GITHUB_TOKEN: ${{ github.token }}
run: |-
# get latest nushell tag name
nu_latest=$(gh release list --repo nushell/nushell --limit 1 --exclude-pre-releases --exclude-drafts --json "tagName" --jq '.[0].tagName')
# trim any trailing whitespace from output
nu_tag=${nu_latest%%[[:space:]]*}
# download binary for x86_64-unknown-linux-gnu target
gh release download ${nu_tag} --repo nushell/nushell --pattern "nu-${nu_tag}-x86_64-unknown-linux-gnu.tar.gz"
# extract nu binary from tar.gz
tar -xf "nu-${nu_tag}-x86_64-unknown-linux-gnu.tar.gz"
# make the binary executable
chmod +x "./nu-${nu_tag}-x86_64-unknown-linux-gnu/nu"
# add it to PATH
echo "${{ github.workspace }}/nu-${nu_tag}-x86_64-unknown-linux-gnu" >> "${GITHUB_PATH}"
- name: Download binary
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: uv-linux-libc-${{ github.sha }}
- name: Prepare binary
run: chmod +x ./uv
- name: Create venv
# The python version is arbitrary for this test.
# We only want to ensure the activation script behaves properly
run: ./uv venv
- name: Activate venv
shell: nu {0}
run: overlay use ${{ github.workspace }}/.venv/bin/activate.nu
integration-test-conda:
timeout-minutes: 10
needs: build-binary-linux-libc