Q: auto_path extension by tcllib's/tklib's pkgIndex.tcl 
Author Message
 Q: auto_path extension by tcllib's/tklib's pkgIndex.tcl

Hi,

I've seen that tcllib's and tklib's installer scripts generate a
pkgIndex.tcl file on their installation directory. One of the first
commands in that pkgIndex.tcl file is to add this directory to
the auto_path variable - and that looks completely superfluous to
me, at least with default installation paths:

1. the installation directory with that pkgIndex.tcl file does not
    include any tclIndex file, so tcl_unknown cannot benefit from
    extending auto_path with that installation directory.

2. when this pkgIndex.tcl gets sourced (by tclPkgUnknown, the first
    time a "package require <Pkg>" command for an unknown package is
    given), obviously auto_path already leads to this installation
    directory, so adding it explicitly doesn't bring anything new.
    I.e. if tcllib/tklib are found, all subpackages contained therein
    will also be found (as each of them has its own pkgIndex.tcl at
    a lower level subdirectory).

I know that adding (innocent) directories to auto_path doesn't harm
- except maybe in terms of performance. But if one wants to keep
auto_path as lean and clean as possible, these additions should be
removed - or am I missing something?

Thanks,
Erik Allaert
European Southern Observatory, Munich



Sat, 06 Sep 2008 18:10:51 GMT  
 Q: auto_path extension by tcllib's/tklib's pkgIndex.tcl

Quote:

> Hi,

> I've seen that tcllib's and tklib's installer scripts generate a
> pkgIndex.tcl file on their installation directory. One of the first
> commands in that pkgIndex.tcl file is to add this directory to
> the auto_path variable - and that looks completely superfluous to
> me, at least with default installation paths:

> 1. the installation directory with that pkgIndex.tcl file does not
>    include any tclIndex file, so tcl_unknown cannot benefit from
>    extending auto_path with that installation directory.

> 2. when this pkgIndex.tcl gets sourced (by tclPkgUnknown, the first
>    time a "package require <Pkg>" command for an unknown package is
>    given), obviously auto_path already leads to this installation
>    directory, so adding it explicitly doesn't bring anything new.
>    I.e. if tcllib/tklib are found, all subpackages contained therein
>    will also be found (as each of them has its own pkgIndex.tcl at
>    a lower level subdirectory).

> I know that adding (innocent) directories to auto_path doesn't harm
> - except maybe in terms of performance. But if one wants to keep
> auto_path as lean and clean as possible, these additions should be
> removed - or am I missing something?

Your missing a tiny bit. pkgIndex.tcl files for packages are only
searched in the direct subdirs of the directories listed in auto_path,
so for a default tcllib install only the toplevel pkgIndex.tcl file will
be found, but the pkgIndex.tcl files for the individual packages will
not be found, as they are one level deeper in the directory hierarchy.

So adding the tcllib dir to the auto_path lets the package command look
one level deeper and the subdirs of tcllib are examined for pkgIndex.tcl
files.

Michael



Sat, 06 Sep 2008 18:29:47 GMT  
 Q: auto_path extension by tcllib's/tklib's pkgIndex.tcl
Quote:


>> Hi,

>> I've seen that tcllib's and tklib's installer scripts generate a
>> pkgIndex.tcl file on their installation directory. One of the first
>> commands in that pkgIndex.tcl file is to add this directory to
>> the auto_path variable - and that looks completely superfluous to
>> me, at least with default installation paths:

>> 1. the installation directory with that pkgIndex.tcl file does not
>>    include any tclIndex file, so tcl_unknown cannot benefit from
>>    extending auto_path with that installation directory.

>> 2. when this pkgIndex.tcl gets sourced (by tclPkgUnknown, the first
>>    time a "package require <Pkg>" command for an unknown package is
>>    given), obviously auto_path already leads to this installation
>>    directory, so adding it explicitly doesn't bring anything new.
>>    I.e. if tcllib/tklib are found, all subpackages contained therein
>>    will also be found (as each of them has its own pkgIndex.tcl at
>>    a lower level subdirectory).

>> I know that adding (innocent) directories to auto_path doesn't harm
>> - except maybe in terms of performance. But if one wants to keep
>> auto_path as lean and clean as possible, these additions should be
>> removed - or am I missing something?

> Your missing a tiny bit. pkgIndex.tcl files for packages are only
> searched in the direct subdirs of the directories listed in auto_path,
> so for a default tcllib install only the toplevel pkgIndex.tcl file will
> be found, but the pkgIndex.tcl files for the individual packages will
> not be found, as they are one level deeper in the directory hierarchy.

> So adding the tcllib dir to the auto_path lets the package command look
> one level deeper and the subdirs of tcllib are examined for pkgIndex.tcl
> files.

 >
 > Michael
 >
Thanks for pointing this out, Michael. I was convinced that this subdir
search for pkgIndex.tcl files was recursive, and it is apparently not.

Still, at the point I notice that auto_path has changed (after loading
the first unknown package), these additional entries have served their
purpose (i.e. the pkgIndex.tcl files of all tcllib and tklib packages
have been read), so I could still remove them from auto_path. Although
that would probably be a bit too diligent and could also confuse code
maintainers ...

Thanks again -
Erik



Sat, 06 Sep 2008 19:42:52 GMT  
 Q: auto_path extension by tcllib's/tklib's pkgIndex.tcl

Quote:

> Your missing a tiny bit. pkgIndex.tcl files for packages are only
> searched in the direct subdirs of the directories listed in auto_path,
> so for a default tcllib install only the toplevel pkgIndex.tcl file will
> be found, but the pkgIndex.tcl files for the individual packages will
> not be found, as they are one level deeper in the directory hierarchy.

This is why, IMHO, the tcllib installer ought to install each package
at the top level, and not corral them all into a tcllib subdirectory.

tcllib is a distribution of many packages.  Once the packages get
distributed, the fact that they rode in on the tcllib train doesn't
really matter any more.  They ought to just get installed like any
other package.

This feels like a legacy left over from the misguided days when code
was in place that made the tcllib distribution itself look like some
kind of package.

I suppose the one argument in favor of the existing install layout
is that it makes writing an uninstaller easier.

--
| Don Porter          Mathematical and Computational Sciences Division |

| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|



Sat, 06 Sep 2008 21:54:13 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. tcl 8.0.5 (Expect 5.28): Can't find pkgIndex.tcl (I think)

2. example of tcllib's mime extension

3. pkgIndex.tcl for Itcl doesn't load Itcl in vanilla wish

4. Qs re 'Write & 'Read

5. ANNOUNCE: New 'tklib' module in SF tcllib project

6. 'logger' package added to tcllib CVS

7. TclPro, tcllib's pop3, TclTidy, etc...what I'm up to

8. tcllib: missing subdir 'config'?

9. using SCO's Visual Tcl (Motif extension on Tcl toolkit)

10. Tklib's ctext Removes All Tags On Current Line

11. ANNOUNCE: New facilities in Tklib's plotchart module

12. y2k and Tcl '''extensions'''

 

 
Powered by phpBB® Forum Software