xml package not found by dev kit tclapp?

Posted by stevebissell on 2010-04-26 06:43

Hi - when trying to build an exe from my files, all goes well until I try to run it, at which point it complains about "package require xml".

I then go to the TclApp packages tab, select scan for packages, it adds xml package - so far, so good.
Unfortunately, when I hit the Run / Wrap button, the dialog reports
"package 'xml -is redirect' is not known (Specified, Not recoverable)"

This is the first time I've tried running this tool, so I'm a complete newbie. Without the package, the built exe seems to do the right thing up to the point where it needs xml, by instrumenting the code, so I know I'm on the right lines.

Adding the xml source files from the lib directory as files (instead of adding the package) does not appear to fix the problem.

Command line generated by TclApp is as below:
Command line:
C:/TclDevKit/bin/tclapp.exe -prefix C:/Tcl/bin/base-tcl8.5-thread-win32-ix86.exe -out C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/Build/LogToCsv.exe -verbose -architecture win32-ix86 -pkgref xml C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/FS_utils.tcl C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/XML_FSM.tcl C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/XmlParser.tcl C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/FsLogToCsv.tcl -startup lib/application/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/FsLogToCsv.tcl C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/FsLogReader.tcl C:/TMSSoftwareDevelopmentHome/SteveB/MyFlatScriptVariants/FS4TMS/FsTgtUtils.tcl

Anybody have any clues about what I'm doing wrong? Do I need to make a package of xml itself in some way?

Update: the documentation suggests that although the scan of files finds a ref to the package, that's no guarantee it will be found, which seems to be my case. Very old web documentation suggests that either kitten starkit contains what I want; or that teacup can be used to do what I want, but no more details seem to be available.

andreas.kupries
ActiveState Staff
Mon, 2010-04-26 12:02

xml is one of the more weird packages. If you can rewrite your application to use 'tdom' instead, then I would recommend that you do so.

Even if not immediately, consider this a long-term option.

The problem is not that xml is not found by TclApp. It is. Otherwise you would get a wrap error.

The problem is that xml has a plugin architecture which we cannot model in the dependencies. The package 'xml' is _just_ the plugin manager, so to speak, without actual functionality. Let us look at its package index file:

if {[catch {package require xml::c 2.6}]} {
package require xml::tcl 2.6
package require xmldefs
# Only choice is tclparser
package require xml::tclparser 2.6
} else {
package require xmldefs
package require xml::tclparser 2.6
catch {package require xml::expat 2.6}
}
package provide xml 2.6

As you can see, you have to wrap a few other packages to make it usable, and you have two different possibilities here.

I would recommend to wrap the set

xml::c
xmldefs
xml::tclparser
and xml::expat
(and xml, of course).

stevebissell | Tue, 2010-05-04 01:14

Hi Andreas. I've been working on something else lately, hence the delay in response.
Right - first of all, I would say that the problem IS a "wrap" error, because if I put xml in the "packages" tab of TclApp, the "not found" error is seen at wrap time, and no executable is generated. This applies to other packages that Tcl finds whilst scanning the source, such as sgml and uri (as I found when devloping the workaround below).
So it appears that I cannot specify any packages within the "packages" tab.
After some tinkering and cursing based on your advice, the following rather ugly workaround DOES work - basically, I have to make my client code SOURCE / LOAD all the files in precisely the right order, and WRAP all the xml source that my source references, i.e wrap xml__tcl, xml-8.1, sgml-8.1 and sgmlparser tcl files, the tclxml and expat dlls, with the client code looking as below:

#the single line below replaces all lines in the TclApp "wrap" workaround section
#below if you are just running this interpreted. The TclApp "wrap" workaround
#is required if you are using TclApp to "wrap" this source into a deliverable
#standalone exe that does not require a Tcl installation (e.g. for mailing to
#customer sites)
#package require xml;#<-- this is all you need if not wrapping.
#
# --- Start of TclApp "wrap" workaround.
#the global below points (typically) to C:/Tcl/lib/TclX.Y where x.y is the version
#global tcl_library
#until we know better, hard code the path to the base of the libs, rather than
#relying on the above global and trying to work back from it.
set tclbase [file join c:/ Tcl lib]
source [file join $tclbase tcllib1.7 uri uri.tcl]
source [file join $tclbase tcllib1.7 uri urn-scheme.tcl]
set loadpath [file join $tclbase Tclxml2.6]
source [file join $loadpath sgml-8.1.tcl]
source [file join $loadpath xml-8.1.tcl]
source [file join $loadpath xml__tcl.tcl]
source [file join $loadpath sgmlparser.tcl]
load [file join $loadpath Tclxml26.dll]
set loadpath [file join $tclbase Tclexpat2.6]
load [file join $loadpath Tclexpat26.dll]
# --- End of TclApp "wrap" workaround.

If I do not source all of the files above, then a run time error is seend when running the generated exe whenever a package require forward reference is found - i.e. the source providing the package must already have been "source"d PRIOR to encountering the package require.

Is this the cleanest way to achieve what I'm doing? For the moment, it will do - it works :-)

andreas.kupries
ActiveState Staff
Tue, 2010-05-04 11:24

Lets start with "because if I put xml in the "packages" tab of TclApp, the "not found" error is seen at wrap time, and no executable is generated."

Please open the dialog [Edit -> Preferences], see the menubar for the 'Edit'. What are the contents of the "TEAPOT/TAB Search Path"s ?

If the TEAPOT Search Path is empty I recommend to open the dropdown list of the combo edit field and use it to add http://teapot.activestate.com, or simply type this directly into the field.

Note that this is the global setting. The toolbar of the "packages" tab has the button for the per-project setting of such archives. For the equivalent option on the command line see -archive in the packages section of http://docs.activestate.com/tdk/5.0/TclApp_cmdline.html

If you have ActiveTcl installed then you can use the path to the local repository of ActiveTcl in all these places. This however limits you to the packages you have locally installed, whereas http://teapot.activestate.com provides direct access to all the packages we provide.

How much of http://docs.activestate.com/tdk/5.0/TclApp.html have you read ? Note especially:

http://docs.activestate.com/tdk/5.0/TclApp.html#locating_custom_tap
http://docs.activestate.com/tdk/5.0/TclApp.html#wrap_packages

Further note the examples at

http://docs.activestate.com/tdk/5.0/TclApp.html#wrap_basic

Regarding your workaround note that this is _not_ wrapping the files into your executable. You are apparently source;ing and loading it directly from the hard disk, from a fixed path (c:/tcl/lib).

stevebissell | Wed, 2010-05-05 08:00

Is this a configuration problem with my installation?
Firstly, I tried your suggestion regarding the repository. I reverted my client source to simply "package require xml", since my workaround was not right.
I added the url to teapot.activestate.com to the TEAPOT REPOSITORIES tab of the preferences dialog, and also the local path c:\tcl\lib\tap.
I could NOT add the url to the TAP SEARCH PATHS tab of the preferences dialog - it was highlighted in red, so I added the above local path.
Attempts to wrap still failed with

package 'sgml -is redirect -require 1.8' is not known (Specified, Not recoverable)
    package 'xml -is redirect' is not known (Specified, Not recoverable)

and in the state tab of TclApp, I see

http://teapot.activestate.com: Retrieving remote INDEX status ...
http://teapot.activestate.com: Got   Status Failed
http://teapot.activestate.com: Got   Status = 0 (couldn't open socket: invalid argument)
http://teapot.activestate.com: Disabled local processing. No status

And when I first try to wrap after setting the local path to tcl/lib/tap in the preferences/search path, I see a lot of red messages of type (for example)

    Found C:/Tcl/lib/tap/tclxml.tap ...
        Unuseable base path "@TDK_LIBDIR@/Tclxml2.6"
        expansion was       "C:/Tcl/lib/tap/Tclxml2.6"

So I'm wondering if I have some problem with my installation, or maybe with missing/incorrect env var or OS settings.
I've attempted briefly to use the Package Editor, but it also seems "stuck" in the %USERPROFILE% windows directory, and so cannot find files anywhere else on the disk, even when I browse to them.

Finally, if I attempt to wrap a single file just containing the line "package require dom", this also fails to wrap, failing to find the dom package [package 'dom -is redirect' is not known (Specified, Not recoverable)]. I noticed that this project did NOT inherit the "global" settings you mentioned, and that I had to set the local settings from the packages tab in order for the command line to contain the -archive references to the teapot repositories. Again I saw the

http://teapot.activestate.com: Got   Status Failed
http://teapot.activestate.com: Disabled local processing. No status

message when attempting to wrap.

andreas.kupries
ActiveState Staff
Wed, 2010-05-05 12:41

Ok

Is this a configuration problem with my installation?

Maybe. From the remaining description I believe we are at a point where we should talk directly by email.

Do you have ActiveTcl installed? If yes, did you install it before or after Tcl Dev Kit ? It is better to install AT first, then TDK.

I could NOT add the url to the TAP SEARCH PATHS tab of the preferences dialog - it was highlighted in red, so I added the above local path.

That is expected. A TEApot repository is not a container for .tap files, and thus not a proper TAP search path.

The local path c:\tcl\lib\tap holds .tap files and thus is better placed in the TAP search paths. While we can access it as a teapot repository through an emulation, it is better accessed as TAP path proper. It might also be better to use c:\tcl\lib as we search subdirectories as well, bringing not only 'tap', but other packages as well.

Disabled local processing. No status

When we access teapot repositories we try to load their INDEX database to disk, so that we can do searches locally. The message above means that this failed and all searches will be sent to the server, forcing round-trips over the internet.

It is not clear where this comes from. I just tried "teacup list -v aes" from a machine outside of ActiveState's network and the results looked ok.

bluepeak:(504) ~ > teacup list -v aes
http://teapot.activestate.com: Retrieving remote INDEX status ...
http://teapot.activestate.com: Got Status Ok
http://teapot.activestate.com: Got Status = 200 (1270828457 1270828855 {1270807824 13403} {1270808771 20247} {c0ce0763348438a5ac895efd5d5c113c 8406016 98fb683ad0d6ffbbb75a6e25127e4fde 1852389})
http://teapot.activestate.com: Local Status = ()
http://teapot.activestate.com: No cached status, get INDEX
http://teapot.activestate.com: Retrieving remote INDEX ...
http://teapot.activestate.com: Storing received data in /var/tmp/klsNOFoXbj
http://teapot.activestate.com: Got Index: Ok ()
http://teapot.activestate.com: Expecting 1852389 bytes
http://teapot.activestate.com: Received 1852389 bytes OK
http://teapot.activestate.com: Expecting md5 checksum: 98fb683ad0d6ffbbb75a6e25127e4fde
http://teapot.activestate.com: Received md5 checksum: 98fb683ad0d6ffbbb75a6e25127e4fde OK
http://teapot.activestate.com: Unzip received data to /var/tmp/xlW9KGQffm
http://teapot.activestate.com: Expecting 8406016 bytes
http://teapot.activestate.com: Received 8406016 bytes OK
http://teapot.activestate.com: Expecting md5 checksum: c0ce0763348438a5ac895efd5d5c113c
http://teapot.activestate.com: Received md5 checksum: c0ce0763348438a5ac895efd5d5c113c OK
http://teapot.activestate.com: Save Status = (1270828457 1270828855 {1270807824 13403} {1270808771 20247} {c0ce0763348438a5ac895efd5d5c113c 8406016 98fb683ad0d6ffbbb75a6e25127e4fde 1852389})
http://teapot.activestate.com: New INDEX accepted, saved to ~/.teapot/%2fhome%2faku%2fopt%2fActiveTcl.linux-glibc2.5-ix86/indexcache/teapot.activestate.com/INDEX
http://teapot.activestate.com: Using locally cached INDEX
entity name version platform
------- ---- ------- --------
package aes 1.0.0 tcl
package aes 1.0.1 tcl
------- ---- ------- --------
2 entities found

As said, I believe it is time for me to ask for your project file, exact command lines used, verbose log, debug log and other stuff which will tell me what exactly (well, more detailed) you are doing.

That is however better done by mail, not via this forum. Simply send me a private message through the forum, or use the email address listed on my account page