Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ANN] Tarvel v0.3

108 views
Skip to first unread message

Lawrence Woodman

unread,
Jul 1, 2015, 1:42:08 AM7/1/15
to

A Tcl Packaging Tool

Tarcel allows you to combine a number of files together to create a
single tarcel file that can be run by tclsh, wish, or can be sourced into
another Tcl script. This makes it easy to distribute your applications as
a single file. In addition it allows you to easily create Tcl modules
made up of several files including shared libraries, and then take
advantage of the extra benefits that Tcl modules provide such as faster
loading time.

Project page:
http://vlifesystems.com/projects/tarcel/
Github:
https://github.com/LawrenceWoodman/tarcel


Changes:
Tarvel v0.3 allows you to add a hashbang line to the resulting tarcel
package and corrects the use of the args variable passed in to another
tarcel.


Example:
As an example, if you have the following files that you would like to
put together to form a module called translator-0.1.tm:

translator.tcl
lib/deutsch.tcl
lib/english.tcl
lib/italiano.tcl



translator.tcl contains:

namespace eval translator {
variable translations [dict create]
}

proc translator::addTranslations {language _translations} {
variable translations
dict set translations $language $_translations
}

source lib/deutsch.tcl
source lib/english.tcl
source lib/italiano.tcl

proc translator::englishTo {language englishWord} {
variable translations
dict get $translations $language $englishWord
}



lib/deutsch.tcl contains:

translator::addTranslations deutsch {
welcome willkommen
}



lib/english.tcl contains:

translator::addTranslations english {
welcome welcome
}



lib/italiano.tcl contains:

translator::addTranslations italiano {
welcome benvenuti
}



You can create a module, translator-0.1.tm, from these files using the
following translator.tarcel file:

set files [list \
translator.tcl \
[file join lib deutsch.tcl] \
[file join lib english.tcl] \
[file join lib italiano.tcl]
]

set version 0.1
set baseDir translator-$version.vfs
set outputFilename translator-$version.tm

import [file join $baseDir app] $files

config set version $version
config set homepage "http://example.com/project/translator"

set initScript {
source [file join @baseDir app translator.tcl]
}

config set init [string map [list @baseDir $baseDir] $initScript]
config set outputFilename $outputFilename



Wrap the files into a module using the following:

$ tclsh tarcel.tcl wrap translator.tarcel



Now create a test file, translator.test.tcl:

package require tcltest
namespace import tcltest::*

::tcl::tm::path add [file normalize .]
package require translator

test englishTo-1 {Ensure translates from English to German} -body {
translator::englishTo deutsch welcome
} -result {willkommen}

test englishTo-2 {Ensure translates from English to Italian} -body {
translator::englishTo italiano welcome
} -result {benvenuti}

cleanupTests



Finally you can now run the test and see that it treats the module just
as if it was originally created as a single file:

$ tclsh translator.test.tcl


Feedback and contributions:
Both are very welcome and ideally should be made via GitHub or failing
that to me directly: lwoo...@vlifesystems.com


Licence:
The module is released under an MIT licence.


Best Wishes


Lorry




--
vLife Systems Ltd
Registered Office: The Apex, 2 Sheriffs Orchard, Coventry, CV1 3PP
Registered in England and Wales No. 06477649
http://vlifesystems.com

Colin Macleod

unread,
Jul 1, 2015, 4:30:29 AM7/1/15
to
On Wednesday, 1 July 2015 06:42:08 UTC+1, Lawrence Woodman wrote:
> A Tcl Packaging Tool
>
Can you explain how this differs from Starpacks ?

Thanks, Colin.

Lawrence Woodman

unread,
Jul 1, 2015, 8:22:09 AM7/1/15
to
The first big difference is that the resulting package, called a
tarcel, doesn't contain a Tcl interpreter and so relies on the
system having Tcl installed. But assuming it is installed on
the machine that you want to run on, then you can put everything
else such as Tclx or Tcllib packages in the tarcel. This works
well on operating systems that have a package manager, such as
on most Linux distributions, as you can easily create a package
for the distribution that has Tcl as a dependency.

Tarcel also lets you create a single file that will run on:
Windows; Mac; Linux; BSD, Solaris; Aix; OpenVMS, without the creator
having to create or download (if available) a Tclkit for each platform
and then create separate Starpacks.

Tarcel is particularly suited to making modules easier to create by
allowing you to create the module as separate files as you would a
normal Tcl package and then have Tarcel combine them into a single
module file. The resulting module could then be required as normal
via a Tcl script or included in another tarcel or a Starpack.

I see Starpacks and Tarcel's as having different uses. If I wanted
to create an application that users could download and run on their
Windows or Mac OS X machines, then Starpacks would be the right
choice as the starpacks would be executable and wouldn't require the
user to download anything else.

Tarcel's are more for creating modules from multiple files and for
distributing software, via a single download, where you know that
Tcl is already installed. Tarcel works great for creating
cross-platform plugins and I particularly like that you can query them,
so for example if I were to run the info command of Tarcel on itself
(once created as a tarcel) I get:

Information for tarcel: tarcel.tcl
Created with tarcel.tcl version: 0.3

Homepage: http://vlifesystems.com/projects/tarcel/
Version: 0.3
Files:
tarcel-0.3.vfs/app/lib/commands.tcl
tarcel-0.3.vfs/app/lib/compiler.tcl
tarcel-0.3.vfs/app/lib/config.tcl
tarcel-0.3.vfs/app/lib/embeddedchan.tcl
tarcel-0.3.vfs/app/lib/parameters.tcl
tarcel-0.3.vfs/app/lib/tar.tcl
tarcel-0.3.vfs/app/lib/tararchive.tcl
tarcel-0.3.vfs/app/lib/tvfs.tcl
tarcel-0.3.vfs/app/lib/xplatform.tcl
tarcel-0.3.vfs/app/tarcel.tcl
tarcel-0.3.vfs/modules/configurator-0.1.tm


I hope this helps. When I get a chance I will write a more in-depth
article.


Thanks

Colin Macleod

unread,
Jul 2, 2015, 4:07:33 AM7/2/15
to
On Wednesday, 1 July 2015 13:22:09 UTC+1, Lawrence Woodman wrote:
> On Wed, 01 Jul 2015 01:30:27 -0700, Colin Macleod wrote:
>
> > On Wednesday, 1 July 2015 06:42:08 UTC+1, Lawrence Woodman wrote:
> >> A Tcl Packaging Tool
> >>
> > Can you explain how this differs from Starpacks ?
>
> The first big difference is that the resulting package, called a
> tarcel, doesn't contain a Tcl interpreter and so relies on the
> system having Tcl installed. But assuming it is installed on

Sorry, I should have asked how Tarcels differ from Starkits not Starpacks. I still don't see much difference between these.

Thanks, Colin.

Lawrence Woodman

unread,
Jul 3, 2015, 2:11:14 AM7/3/15
to
I think Tarcel aids collaboration on a project as if I create a module
or an application using Tarcel, then people can use that module or
application directly from tclsh/wish. A tarcel is self-contained, it
doesn't need unpacking to run via tclsh/wish and there is no need for
them to use Tclkit.

Think of it like this: If a number of people were working on a module that
consisted of multiple-files. Using Tarcel we can all use our standard
tclsh/wish to work-on that module and we can distribute the module as
a single file that you can then 'package require' on your system without
having to download an appropriate tclkit. This also goes for applications
as I can distribute an application via a .deb or .rpm package under Linux
and only have to say that one of the requirements of the package is that
Tcl is installed, which would automatically get installed if not present
when a user installs my application's .deb or .rpm.

One of the reasons I created Tarcel is that if I create a project that
requires a user of that project to have Tclkit for Tcl v8.6 say, then
they have a number of choices which may not suite them:
1. Download a Tclkit from a source that they may know nothing
about and may not have confidence in the quality of that
build or the trustworthiness of it (I'm not saying that
these are in doubt for any source of Tclkit.)
2. Build a Tclkit themselves.
3. Buy Tcl Dev Kit at $295.

For many users these are barriers that will prevent them from using or
contributing to that project. On the other hand if they are interested
in contributing to the project then they probably already have Tcl
installed and can download the project and start hacking away.

As you can see my main interest is in making open source software
easier to collaborate on. However Tarcel does have further
benefits such as being able to easily interrogate applications created
with Tarcel to find their version number, which is ideal for doing site
audits and aiding tech support.


Best wishes
0 new messages