Skip to content

fix: Use getattr for tcl/tk library paths #2945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2944.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced direct references to tcl/tk library paths with getattr. By :user:`esafak`
4 changes: 2 additions & 2 deletions src/virtualenv/activation/bash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def as_name(self, template):
def replacements(self, creator, dest):
data = super().replacements(creator, dest)
data.update({
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", ""),
Copy link
Contributor

Choose a reason for hiding this comment

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

How come these can be not present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, I asked the reporter for the logs.

Choose a reason for hiding this comment

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

I also don't understand why, but here is an example of a failing build: https://github.com/douwevandermeij/test-virtualenv/actions/runs/16797823289/job/47572059324

Choose a reason for hiding this comment

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

Looks like a Poetry problem

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a Poetry problem

Open an issue there please 🤔 and link it to this.

Copy link

Choose a reason for hiding this comment

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

This does not look like a poetry problem, PythonInfo is constructed and used only by virtualenv code, it is hard for me to guess how this would be anything but a virtualenv problem.

I expect you have some path that fails to populate the new fields. Probably the stuff that gets it from cache.

"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", ""),
})
return data

Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/activation/fish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def templates(self):
def replacements(self, creator, dest):
data = super().replacements(creator, dest)
data.update({
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", ""),
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", ""),
})
return data

Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/activation/nushell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def replacements(self, creator, dest_folder): # noqa: ARG002
"__VIRTUAL_ENV__": str(creator.dest),
"__VIRTUAL_NAME__": creator.env_name,
"__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", ""),
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", ""),
}


Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/activation/via_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def replacements(self, creator, dest_folder): # noqa: ARG002
"__VIRTUAL_NAME__": creator.env_name,
"__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
"__PATH_SEP__": os.pathsep,
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", ""),
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", ""),
}

def _generate(self, replacements, templates, to_folder, creator):
Expand Down
Loading