\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#191: Managing Tcl Packages and Modules in a Multi-Version Environment}
\date{March 24, 2004}
\author{Andreas Kupries, Joe English, Larry Virden}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#191}&\textbf{Managing Tcl Packages and Modules in a Multi-Version Environment}\\\hline
Author&

Andreas Kupries \tipmail{akupries}{shaw.ca}
\par
Joe English \tipmail{jenglish}{users.sourceforge.net}
\par
Larry Virden \tipmail{lvirden}{yahoo.com}
\\
Created&Wednesday, \(\text{24}^{\text{th}}\) March 2004\\
Type&Informative\\
State&Draft\\
Vote&Pending\\
Version&\tipversion$Revision: 1.3 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This document is an informational adjunct to \cite{tip189} ``Tcl Modules'', describing a number of choices for the management of Tcl Modules in environments with more than one version of the Tcl core installed. It lists these choices and then discusses their relative merits and problems.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Background and Motivation}

A regular package can perform checks in its ``pkgIndex.tcl'' file regarding the environment the package would be loaded into should it be requested, and make the creation of its ``provide script'' dependent on the result. In other words, it is able to prevent its registration, making it invisible to the Tcl interpreter in question if the environment is not right (for example, if the interpreter is too old a version of Tcl).

A Tcl module cannot do this as its ``provide script'' is generated by the module system.

In a controlled environment, like wrapped applications of any form this is a complete non-issue as we can assume that only those modules are installed which are not only required, but needed.

This is no problem either for installations with only one version of the Tcl core. It is believed that this is currently the majority of cases.

The change breaks only environments with several coexisting Tcl installations which share package directories among them and rely on the index scripts to prevent the registration of packages in unsuitable interpreters.

Another situation where the change can break things is an environment with a single version of the interpreter, and the version of that interpreter is changed, upgraded, or downgraded. Packages for one version may not work anymore with the new version, or a different version of the package has to be selected from among the installed versions. This situation can be viewed as having multiple version of Tcl, however over time instead of space.

For the environments with multiple versions of Tcl in space a number of possible solutions are explained in the next section.

\section{Choices}

All solutions are done outside of the Tcl interpreter, in the filesystem.
\begin{itemize}
\item{}
Each interpreter has its own part of the filesystem. Modules required in several of them are copied around. Modules not required are not copied. This is easy. It requires more disk space; however that is cheap.
\item{}
Same as above, but use hard- and/or soft-links instead of copying. Modules not eligible somewhere are not linked.

This schema can also be used to maintain a central repository, which is just a directory tree containing all module files in their proper locations. Then link the packages which should be visible to an interpreter into their respective directory trees.

This makes the creation of test environments with a known set of packages very easy as well.
\item{}
Keep the modules in several directory trees as wanted and/or needed by sharing requirements and then set the list of search paths used by an interpreter to exactly those trees which have the modules required/usable by it.
\end{itemize}

\subsection{Changes over Time}

Note that the default paths set down in \cite{tip189} ease the management, as each Tcl shell will not only have its own space, but also access to extensions for all minor versions which came before it. This means that placing an extension into the directory for the smallest version of Tcl supporting it will make this extension available to this minor version and all the versions which come after and share the major version. This is the right thing almost all of the time.

Only extensions using internal interfaces will have to be dealt with separately.

\section{Questions}

\section{Comments}

[ Add comments on the document here ]

According to Don Porter the given solutions will not scale.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#1}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#189]{tip189}
Andreas Kupries,
Jean-Claude Wippler,
Jeff Hobbs,
Don Porter,
Larry W. Virden,
Daniel A. Steffen,
Don Porter,
\emph{Tcl Modules},
on-line at \url{http://purl.org/tcl/tip/189.html}
\end{thebibliography}
\end{document}
