Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-11-17
00:19 • Ticket [695441ffff] tcl_findLibrary does not look in $::auto_path status sti... artifact: 363b76aa9e user: dgp
00:19 • Closed ticket [695441ffff]. artifact: 822d293036 user: dgp
2004-11-16
06:00 • Ticket [695441ffff]: 1 change artifact: a0e49490b9 user: dgp
2004-10-27
00:02 • Ticket [695441ffff]: 5 changes artifact: 00618f9e5a user: dgp
2004-08-24
00:40 • Ticket [695441ffff]: 5 changes artifact: 5870aef99b user: dgp
2004-08-19
23:56 • Ticket [695441ffff]: 4 changes artifact: c4dbe017f8 user: dgp
23:56 • Add attachment 695441.patch to ticket [695441ffff] artifact: 8ed5049932 user: dgp
23:18 • Ticket [695441ffff] tcl_findLibrary does not look in $::auto_path status sti... artifact: 44ff8ddc22 user: dgp
03:37 • Ticket [695441ffff]: 4 changes artifact: 67ca6394d6 user: dgp
03:37 • Ticket [695441ffff]: 4 changes artifact: 2e932da10d user: dgp
2003-10-07
00:14 • Ticket [695441ffff]: 1 change artifact: 7befd1319d user: dgp
2003-07-16
19:59 • Ticket [695441ffff]: 1 change artifact: 9e67d17d3a user: dgp
2003-07-04
06:21 • Ticket [695441ffff]: 4 changes artifact: ed3bae20ce user: dgp
06:02 • Ticket [695441ffff]: 4 changes artifact: a13dd2f921 user: andreas_kupries
05:55 • Ticket [695441ffff]: 4 changes artifact: afc1e72066 user: dgp
2003-04-17
04:03 • Ticket [695441ffff]: 4 changes artifact: 246fc4f6b5 user: dgp
2003-03-04
06:56 • Ticket [695441ffff]: 4 changes artifact: efc877cf33 user: jenglish
2003-03-03
09:01 • Ticket [695441ffff]: 4 changes artifact: 7edb53d31a user: dgp
2003-03-02
06:58 • Ticket [695441ffff]: 1 change artifact: 418e70add1 user: dgp
2003-03-01
11:20 • Ticket [695441ffff]: 5 changes artifact: 3cbf7db297 user: jenglish
04:09 • New ticket [695441ffff]. artifact: 04a01a49c7 user: jenglish

tcl_findLibrary does not look in $::auto_path

Closed / Accepted695441ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 22 years ago
Descriptionplain2003-03-01 04:09:33
The tcl_findLibrary procedure does not check the
directories listed in $::auto_path when looking for the
specified initialization script.

This means that a combined script/binary package which
calls tcl_findLibrary in its _Init() routine might not
be able to find its own library, even though Tcl's
package mechanism was able to find the binary library.
jenglishplain2003-03-01 11:20:57
Logged In: YES 
user_id=68433

An example is probably in order:

Suppose Foo 1.0 contains libFoo.so, fooInit.tcl, and
pkgIndex.tcl, where pkgIndex.tcl says:

package ifneeded Foo 1.0 [list load [file join $dir
libFoo[info sharedlibextension]]]

and Foo_Init() Tcl_Eval()s a startup script containing

tcl_findLibrary Foo 1.0 1.0 fooInit.tcl FOO_LIBRARY 
Foo_Library

If Foo1.0 is installed in one of the standard places
(according to tcl_findLibrary), this will work.  If it's
stored in a nondefault location, [tclPkgUnknown] can find
out about the package if $::auto_path is extended, but the
package will still fail to load since tcl_findLibrary
doesn't look in the same place(s) as [tclPkgUnknown].

Or is this an improper use of tcl_findLibrary?
dgp Ticket [695441ffff]: 1 change [History diff]2003-03-02 06:58:02
dgpplain2003-03-03 09:01:01
Logged In: YES 
user_id=80530

my strong preference is that no new package 
uses [tcl_findLibrary], and packages that
currently use [tcl_findLibrary] should try to
move away from it.

[tcl_findLibrary] exists to solve a problem that
packages are much better off just not
creating for themselves in the first place.

For your example, just be sure to install 
all files of Foo 1.0 [*] -- libFoo.so, fooInit.tcl,
and pkgIndex.tcl  -- all in the same installation
directory.  Then, pkgIndex.tcl should contain:

package ifneeded Foo 1.0 [list source [file join $dir
fooInit.tcl]]

And fooInit.tcl should contain:

load [file join [file dirname [info script]] libFoo[info
sharedlibextension]] Foo

Since your package includes binary files, it should
be installed only on an appropriate platform, either
under TCL_EXEC_PREFIX, or somewhere else
that will be placed on auto_path only on appropriate
platforms.

I believe this approach is what TEA2 recommends.

The older style of installing binary parts under
TCL_EXEC_PREFIX and cross-platform parts
under TCL_PREFIX is what led to the need
for [tcl_findLibrary] to allow the package to find
its missing half.  The only benefit of that scheme
was to save disk space on file servers serving
multi-platform clients, and that's largely an
optimization of a bygone era.  Much better for
runtime sanity and for uninstall capability to
put all parts of an installed package in just
one place.  

[*] FWIW, I'd rather you named the package
"foo" rather than "Foo".
jenglishplain2003-03-04 06:56:48
Logged In: YES 
user_id=68433

Calling tcl_findLibrary from the package _Init() routine is
useful since it works for statically loaded as well as
dynamically loaded packages.  Plus, it provides useful hooks
for overriding the library path from the environment (for
e.g., debugging) and from the application (for e.g.,
tclkits).

BTW, I agree that the script and binary parts should always
be installed in the same place.  However, for
statically-linked, statically-loaded packages there might
not be a separate binary part (or even a pkgIndex.tcl).

Basically: if the binary part loads the script part, the
package can work as a Tcl_StaticPackage() or be dynamically
loaded with no code changes.  The other way around, it
can't.
dgpplain2003-04-17 04:03:07
Logged In: YES 
user_id=80530


FWIW...

I notice that on Max OS X only, the ::tcl_pkgPath
is also searched.  This seems like a half-fulfillment
of this feature request on a single platform.
dgpplain2003-07-04 05:55:18
Logged In: YES 
user_id=80530

see also Tk Bug 765642
andreas_kupriesplain2003-07-04 06:02:02
Logged In: YES 
user_id=75003

IMHO. From my POV the script part of a package FOO should 
simply be another package, maybe named 'FOO-tcl' or some 
such. Then the binary part can simply 'package require' the 
thing and it does not matter there the script part is located. 
The package search mechanism will be enough and obviates 
the need for 'another' search algorithm to locate stuff.
dgpplain2003-07-04 06:21:28
Logged In: YES 
user_id=80530

Economy of search algorithms is
attractive, I agree.

I don't think the two package answer
really works though, because we really
don't have two packages.  Presumably
package FOO (in this case, Tk) needs
package FOO-tcl to work correctly, while
at the same time FOO-tcl makes use of
commands provided by FOO.

Circular dependency is immediate evidence
that there's really only one package here
(one unit of loading).
dgp Ticket [695441ffff]: 1 change [History diff]2003-07-16 19:59:33
dgp Ticket [695441ffff]: 1 change [History diff]2003-10-07 00:14:07
dgpplain2004-08-19 03:37:16
Logged In: YES 
user_id=80530


Attached patch changes the
search path to include directories
in the $::auto_path and the
scriptdir,runtime in the package's
configuration, if any.

Some obsolete directories that
should be included in auto_path
when relevant were also dropped.

Testing invited.
dgpplain2004-08-19 03:37:17
File Added - 98323: 695441.patch
dgpplain2004-08-19 23:18:55
Logged In: YES 
user_id=80530

Patch is incompatible with
Safe Base, which apparently
does not allow [file normalize]
in a safe interp.
dgpplain2004-08-19 23:56:54
File Deleted - 98323: 



File Added - 98426: 695441.patch

Logged In: YES 
user_id=80530

updated patch should
correct the safe interp glitch.
dgpplain2004-08-24 00:40:08
Logged In: YES 
user_id=80530

patch committed to HEAD.

Assigning to tclguy to judge
whether an 8.4 backport is
also appropriate.
dgpplain2004-10-27 00:02:52
Logged In: YES 
user_id=80530


what portion of this, if any,
should be backported, should
be sorted out before 8.4.8 release.
dgp Ticket [695441ffff]: 1 change [History diff]2004-11-16 06:00:14
dgp Closed ticket [695441ffff]. [History diff]2004-11-17 00:19:58
dgpplain2004-11-17 00:19:59
Logged In: YES 
user_id=80530


modified version backported for
Tcl 8.4.8.
Log in (anonymous is fine) to add a comment.

Attachments: