Finding Tcllib Module Package dependeciy tree 
Author Message
 Finding Tcllib Module Package dependeciy tree

Hi

Is there a piece of code available that given a Tcllib module package
name, can return the package dependency tree for that module, thus
enabling to prune down the modules to only those required.

The reason for asking is that I am wrapping some code in a StarKit, but
because Tcllib has grown so large, and I need a couple of modules from
it, I find I am adding a lot of unecessary files. Part of the reason for
using Starkit was to produce a small .exe , but this is pushing it up to
3 times the size. I can go through the files manually to find the
depencies, but if there is something available, that would save me a lot
of time.

Thanks

Lawrence



Fri, 04 May 2007 08:52:52 GMT  
 Finding Tcllib Module Package dependeciy tree

Quote:

> Hi

> Is there a piece of code available that given a Tcllib module package
> name, can return the package dependency tree for that module, thus
> enabling to prune down the modules to only those required.

There is no direct way, but you can do:

set pkg md5
interp create i
$i eval set somepackage $pkg
set dep [$i eval {
      package require foo
      set names [package names]
      foreach name $names {
         if {[catch {package present $name} val]} {
            set p($pkg) 0
         } else {
            set p($pkg) 1
         }
      }
      package require $somepackage
      foreach name [array names p] {
        set v [catch {package present $name}]
        if {!$p($name) && $v} {
                   # new, so either the provided package or a dependecy
            lappend depend $name
        }
      }
      set depend

Quote:
}]

interp delete $i
set idx [lsearch $dep $pkg]
if {$idx > -1} {set dep [lreplace $dep $idx $idx]}
puts "Dependecies for $pkg is: $dep"

Quote:

> The reason for asking is that I am wrapping some code in a StarKit, but
> because Tcllib has grown so large, and I need a couple of modules from
> it, I find I am adding a lot of unecessary files. Part of the reason for
> using Starkit was to produce a small .exe , but this is pushing it up to
> 3 times the size. I can go through the files manually to find the
> depencies, but if there is something available, that would save me a lot
> of time.

Michael


Fri, 04 May 2007 10:12:28 GMT  
 Finding Tcllib Module Package dependeciy tree

Quote:


>> Hi

>> Is there a piece of code available that given a Tcllib module package
>> name, can return the package dependency tree for that module, thus
>> enabling to prune down the modules to only those required.

should test my code....
Quote:
> set pkg md5
> interp create i
> i eval set somepackage $pkg
> set dep [i eval {
>      catch {package require foo}
>      set names [package names]
>      foreach name $names {
>         if {[catch {package present $name} val]} {
>            set p($name) 0
>         } else {
>            set p($name) 1
>         }
>      }
>      package require $somepackage
>      foreach name [array names p] {
>        set v [catch {package present $name}]
>        if {!$p($name) && !$v} {
>               # new, so either the provided package or a dependecy
>            lappend depend $name
>        }
>      }
>      set depend
> }]
> interp delete i
> set idx [lsearch $dep $pkg]
> if {$idx > -1} {set dep [lreplace $dep $idx $idx]}
> puts "Dependecies for $pkg is: $dep"



Fri, 04 May 2007 10:18:02 GMT  
 Finding Tcllib Module Package dependeciy tree

Quote:

> Is there a piece of code available that given a Tcllib module
> package name, can return the package dependency tree for
> that module, thus enabling to prune down the modules to
> only those required.

I'm pretty sure that the packages in tcllib are all loaded at [package
require] time.  (They don't use auto indexing to load code lazily
later.)  So when you [package require foo], it loads all of foo's
code, including dependent packages.  So this snippet should show you
which packages are actually loaded.

  % package require struct
  2.0
  % foreach p [package names] {
         if {[package provide $p] ne ""} {puts $p}
       }
    cmdline
    TclDevKit
    ActiveTcl
    struct
    Tcl

Bob
--

Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Fri, 04 May 2007 22:30:00 GMT  
 Finding Tcllib Module Package dependeciy tree

Quote:


>>Is there a piece of code available that given a Tcllib module
>>package name, can return the package dependency tree for
>>that module, thus enabling to prune down the modules to
>>only those required.

> I'm pretty sure that the packages in tcllib are all loaded at [package
> require] time.  (They don't use auto indexing to load code lazily
> later.)  So when you [package require foo], it loads all of foo's
> code, including dependent packages.  So this snippet should show you
> which packages are actually loaded.

>   % package require struct
>   2.0
>   % foreach p [package names] {
>          if {[package provide $p] ne ""} {puts $p}
>        }
>     cmdline
>     TclDevKit
>     ActiveTcl
>     struct
>     Tcl

> Bob

As simple as that :) . Just another reason to love Tcl

Thanks

Lawrence



Sat, 05 May 2007 03:24:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Proposal to add procs for typed options to cmdline module of tcllib package

2. Problems with DNS package in TCLLIB and the TCLUDP package

3. Searching for B-tree/B*-tree package...

4. Walking with Tree (tcllib)

5. Undocumented limitations in ::struct::tree (tcllib)

6. using tree data structure in tcllib

7. Tcllib: tree enhancement

8. Tcllib: Tree enhancement

9. htmlparse package in tcllib

10. Problems with ntp (time package at tcllib)

11. abort transfers in tcllib's ftp package?

12. The dns package in tcllib question

 

 
Powered by phpBB® Forum Software