TCL Package path 
Author Message
 TCL Package path

Hi,

I have two sets of libraries.  Aparently another team which is handling
regression needs to use older version but I need latest versions.  The
newer versions are not backward compatible.   So, when I put new
versions
there, tcl always gets the new version, even after changing the
diretory name.
Tried different methods like "package forget...", renaming directories
but nothing
worked.  Every time the latest packages are sourced.   Finally decided
to
keep only the copy required by regression team.  Now, it is working
fine
for them.

Now, I need to get the latest versions but on the same automation tree
path.
but now tcl loads old versions.  Did try setting auto_path and
tcl_pkgPath
but no use.

Please let me know how to set the package path so that I can the
latest packages gets loaded from user specified path.

Thanks,
N. Jinesh



Wed, 10 Dec 2008 06:57:30 GMT  
 TCL Package path

Quote:
> I have two sets of libraries.  Aparently another team which is handling
> regression needs to use older version but I need latest versions.  The
> newer versions are not backward compatible.  So, when I put new versions
> there, tcl always gets the new version, even after changing the diretory
> name.

Do the two versions happen to share the same major version number? (If
the newer one isn't backwards compatible it really ought to have a > major
version number than the old one.)

You can have both packages live happily together if you [package require]
a specific major version number, or if you know exactly what version you
want you can [package require -exact] the precise version number.

Here is some code to demonstrate this:

proc fake-package {name version} {
    package ifneeded $name $version [format "%s; %s" \
        [list puts "Pretending to load version $version of $name"] \
        [list package provide $name $version]]

Quote:
}

proc reset {} {
    package forget foo
    fake-package foo 1.0
    fake-package foo 1.3
    fake-package foo 1.5
    fake-package foo 2.0
    fake-package foo 2.1
    fake-package foo 2.2

Quote:
}

reset
package require foo 1   ;# loads 1.5
reset
package require foo 1.2 ;# loads 1.5
reset
package require -exact foo 1.3 ;# loads 1.3
reset
package require foo ;# loads 2.2
reset
package require foo 2 ;# loads 2.2

Michael



Wed, 10 Dec 2008 08:48:01 GMT  
 TCL Package path
Hi Michael,

Thx for the reply.  Actully I was missing "pkgIndex.tcl" in my new
path.
That was causing all the issue.  Once I put it in place, everything
started
working fine.

Thanks,
N. Jines

Quote:


> > I have two sets of libraries.  Aparently another team which is handling
> > regression needs to use older version but I need latest versions.  The
> > newer versions are not backward compatible.  So, when I put new versions
> > there, tcl always gets the new version, even after changing the diretory
> > name.

> Do the two versions happen to share the same major version number? (If
> the newer one isn't backwards compatible it really ought to have a > major
> version number than the old one.)

> You can have both packages live happily together if you [package require]
> a specific major version number, or if you know exactly what version you
> want you can [package require -exact] the precise version number.

> Here is some code to demonstrate this:

> proc fake-package {name version} {
>     package ifneeded $name $version [format "%s; %s" \
>         [list puts "Pretending to load version $version of $name"] \
>         [list package provide $name $version]]
> }

> proc reset {} {
>     package forget foo
>     fake-package foo 1.0
>     fake-package foo 1.3
>     fake-package foo 1.5
>     fake-package foo 2.0
>     fake-package foo 2.1
>     fake-package foo 2.2
> }

> reset
> package require foo 1   ;# loads 1.5
> reset
> package require foo 1.2 ;# loads 1.5
> reset
> package require -exact foo 1.3 ;# loads 1.3
> reset
> package require foo ;# loads 2.2
> reset
> package require foo 2 ;# loads 2.2

> Michael



Sat, 13 Dec 2008 03:50:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. tcl library directory/package path

2. REPOST: Re: import path, script path (was Re: module path)

3. dde package - buggy pkgIndex.tcl file in /Tcl/lib/tcl.8.4/dde1.1

4. Path to package

5. Path hacking and Packages

6. tk widget package search path

7. Packaging tcl packages.

8. Path & library package questions/problems

9. Find the path to a package?

10. Finding path to __init__.py in package

11. Tcl package not included after Tcl plugin installation

12. ASN.1 and Tcl / Tcl package status

 

 
Powered by phpBB® Forum Software