Google Ryhmät ei enää tue uusia Usenet-postauksia tai ‐tilauksia. Aiempi sisältö on edelleen nähtävissä.

finding path of currently used extensions

134 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

welle...@googlemail.com

lukematon,
25.3.2019 klo 18.51.2725.3.2019
vastaanottaja
Is there a way to find the path of a currently used extension? Reason: I have installed some new extensions but I want to make sure Tcl is not using the standard Tcl extensions shipped with the macOS (Tktable is shipped for example).

I am able to read the version:

package require tkdnd
package require Tktable

puts -nonewline "Tktable: "
puts [package require Tktable]
puts -nonewline "tkdnd: "
puts [package require tkdnd]

but I'd also like to get the path.
Thank you.
Welle

heinrichmartin

lukematon,
26.3.2019 klo 6.03.3926.3.2019
vastaanottaja
https://www.tcl.tk/man/tcl8.6/TclCmd/package.htm#M6

You can get [package versions]. (I often wished <version> was optional in [package ifneeded].)

HTH
Martin
Viesti on poistettu

gregor...@googlemail.com

lukematon,
27.3.2019 klo 16.09.3227.3.2019
vastaanottaja

gregor...@googlemail.com

lukematon,
27.3.2019 klo 17.03.1127.3.2019
vastaanottaja
package ifneeded Tktable [package provide Tktable]

heinrichmartin

lukematon,
24.4.2019 klo 7.21.2624.4.2019
vastaanottaja
On Wednesday, March 27, 2019 at 10:03:11 PM UTC+1, gregor...@googlemail.com wrote:
> Am Dienstag, 26. März 2019 11:03:39 UTC+1 schrieb heinrichmartin:
> > You can get [package versions]. (I often wished <version> was optional in [package ifneeded].)
>
> package ifneeded Tktable [package provide Tktable]

I kept this seemingly valuable input for later. Now is later, and it does not work.

My use case is to know "which package would be loaded if I package require without exact version or other requirements"?

package provide only returns the version if a package is already loaded. Is there a way to merely poll the version number?
Viesti on poistettu

gregor...@googlemail.com

lukematon,
24.4.2019 klo 16.30.1124.4.2019
vastaanottaja
a example with Tktable


lindex [lsort [package versions Tktable ]] end

or

package ifneeded Tktable [lindex [lsort [package versions Tktable ]] end]

gregor...@googlemail.com

lukematon,
24.4.2019 klo 16.35.4324.4.2019
vastaanottaja
Am Mittwoch, 24. April 2019 13:21:26 UTC+2 schrieb heinrichmartin:
package ifneeded Tktable [lindex [lsort -dictionary [package versions Tktable ]] end]

heinrichmartin

lukematon,
24.4.2019 klo 16.57.3724.4.2019
vastaanottaja
On Wednesday, April 24, 2019 at 10:35:43 PM UTC+2, gregor...@googlemail.com wrote:
> > My use case is to know "which package would be loaded if I package require without exact version or other requirements"?
> >
> > package provide only returns the version if a package is already loaded. Is there a way to merely poll the version number?
>
>
> package ifneeded Tktable [lindex [lsort -dictionary [package versions Tktable ]] end]

This cannot be it. Why would package vcompare and package prefer exist then? I understand that this code will fit in 80% of all cases, but it's not generic if I assume correctly.

gregor...@googlemail.com

lukematon,
25.4.2019 klo 3.39.2725.4.2019
vastaanottaja
example with Tktable


package versions Tktable
#Returns a list of all the version numbers of package
#https://www.tcl.tk/man/tcl8.6/TclCmd/package.htm#M14

lsort -dictionary [package versions Tktable ]
# sort the versions number
#https://www.tcl.tk/man/tcl8.6/TclCmd/lsort.htm#M6

lindex [lsort -dictionary [package versions Tktable ]] end
#find out the highest number

heinrichmartin

lukematon,
25.4.2019 klo 5.25.0025.4.2019
vastaanottaja
Thank you for your continued effort. Still, it looks like my point did not make it through.

What I implicitly noted is that:
* version sorting is more complex - even than dictionary sorting[1]
* package require has two possible preferences, namely latest and stable

It is not feasible to re-implement this decision making algorithm ... this could better be another subcommand (like package version) or a switch (like package require -dryrun).

[1]
set versions {1.0 2.2 2.11 2.12a2 2.12b1 2.12.0 2.13a1 3.42}
lsort $versions
lsort -dictionary $versions
lsort -command {package vcompare} $versions

# other than the code above, the following lines won't actually work
package require foo ;# loads and returns 3.42
package require foo 2 ;# loads and returns 2.12.0, but if
package prefer latest
package require foo 2 ;# then loads and returns 2.13a1

stefan

lukematon,
29.4.2019 klo 6.21.3229.4.2019
vastaanottaja
> It is not feasible to re-implement this decision making algorithm ...

Why not use a throw-away interp to do your dry run?

set sandbox [interp create]

set what [$sandbox eval {
package prefer latest
package require critcl 3
}]

interp delete $sandbox

puts $what

# decide sth. on value of "what" ...

this way you can also introspect on changes to auto_path, sources and loads, etc. w/o affecting your main interp.

HTH, Stefan




heinrichmartin

lukematon,
29.4.2019 klo 6.36.4529.4.2019
vastaanottaja
On Monday, April 29, 2019 at 12:21:32 PM UTC+2, stefan wrote:
> > It is not feasible to re-implement this decision making algorithm ...
>
> Why not use a throw-away interp to do your dry run?
>
> set sandbox [interp create]
>
> set what [$sandbox eval {
> package prefer latest
> package require critcl 3
> }]
>
> interp delete $sandbox

This is it. Thank you!
Actually, I thought about spawning another process, but which is quite expensive. I am not used to working with multiple interpreters ... one never stops discovering.
0 uutta viestiä