MG Slightly related, you can check which files were loaded/sourced by a package by using package ifneeded:
(User) 1 % package require Tk
8.4
(User) 2 % package ifneeded Tk 8.4
load {C:/Program Files/Tcl/lib/tk8.4/../../bin/tk84.dll} TkThanks to a pointer from DGP on Tcl chat about the use of package unknown, here is a proc to return the command that will be used to load a package without actually loading it. If you do not mind the package being loaded, you could just do package ifneeded foo [package require foo] instead.
proc get_package_load_command {name} {
# Get the command to load a package without actually loading the package
#
# package ifneeded can return us the command to load a package but
# it needs a version number. package versions will give us that
set versions [package versions $name]
if {[llength $versions] == 0} {
# We do not know about this package yet. Invoke package unknown
# to search
{*}[package unknown] $name
# Check again if we found anything
set versions [package versions $name]
if {[llength $versions] == 0} {
error "Could not find package $name"
}
}
return [package ifneeded $name [lindex $versions 0]]
}
