Skip to content

Conversation

@esafak
Copy link
Contributor

@esafak esafak commented Aug 3, 2025

  • Detect and set TCL_LIBRARY and TK_LIBRARY environment variables when creating virtual environments.
  • Update activation scripts for bash, batch, cshell, fish, nushell, and powershell to handle these variables.
  • Ensure proper restoration of these variables upon deactivation.
  • Add unit tests to verify the Tkinter support in various activation scripts.

Closes #93, closes #425

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

* Detect and set TCL_LIBRARY and TK_LIBRARY environment variables when creating virtual environments.
* Update activation scripts for bash, batch, cshell, fish, nushell, and powershell to handle these variables.
* Ensure proper restoration of these variables upon deactivation.
* Add unit tests to verify the Tkinter support in various activation scripts.

Closes pypa#93, closes pypa#425

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Assuming the CI passes 👍

@gaborbernat gaborbernat enabled auto-merge (squash) August 3, 2025 04:01
@gaborbernat gaborbernat merged commit 3d35fbb into pypa:main Aug 3, 2025
42 checks passed
@esafak esafak deleted the feature/425-tkinter-support branch August 3, 2025 04:22
zanieb pushed a commit to astral-sh/uv that referenced this pull request Sep 5, 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):
- #14888 
- #14914 
- #14917 

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

- 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 #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 #14917 from
#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)
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.

ensure tkinter works in virtualenv ensure tcl works within virtualenv

2 participants