Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1XA [33X[0;0YGuidelines for Writing a GAP Package[133X[101X23[33X[0;0YThis appendix explains the basics of how to write a [5XGAP[105X package so that it4interfaces properly to [5XGAP[105X. For the role of [5XGAP[105X packages and the ways to5load them, see Chapter [14X'Reference: Using GAP Packages'[114X.[133X67[33X[0;0YThere are two basic aspects of creating a [5XGAP[105X package.[133X89[33X[0;0YFirst, it is a convenient possibility to load additional functionality into10[5XGAP[105X including a smooth integration of the package documentation. Second, a11package is a way to make your code available to other [5XGAP[105X users.[133X1213[33X[0;0YMoreover, the [5XGAP[105X Group may provide some help with redistributing your14package via the web and ftp site of GAP itself after checking if the package15provides some new or improved functionality which looks interesting for16other users, if it contains reasonable documentation, and if it seems to17work smoothly with the GAP library and other distributed packages. In this18case the package can take part in the [5XGAP[105X distribution update mechanism and19becomes a [13Xdeposited[113X package.[133X2021[33X[0;0YFurthermore, package authors are encouraged to check if the package would be22appropriate for the refereeing process and [13Xsubmit[113X it. If the refereeing has23been successful, the package becomes an [13Xaccepted[113X package. Check out the [5XGAP[105X24Web site [7Xhttp://www.gap-system.org[107X for more details.[133X2526[33X[0;0YWe start this chapter with a description how the directory structure of a27[5XGAP[105X package should be constructed and then add remarks on certain aspects of28creating a package, some of these only apply to some packages. Finally, we29provide guidelines for the release preparation, wrapping and distribution.[133X303132[1XA.1 [33X[0;0YStructure of a GAP Package[133X[101X3334[33X[0;0YA [5XGAP[105X package should have an alphanumeric name ([3Xpackage-name[103X, say); mixed35case is fine, but there should be no whitespaces. All files of a [5XGAP[105X package36[3Xpackage-name[103X must be collected in a single directory [3Xpackage-dir[103X, where37[3Xpackage-dir[103X should be just [3Xpackage-name[103X preferably converted to lowercase38and optionally followed by the package version (with or without hyphen to39separate the version from [3Xpackage-name[103X). Let us call this directory the [13Xhome40directory[113X of the package.[133X4142[33X[0;0YTo use the package with [5XGAP[105X, the directory [3Xpackage-dir[103X must be a43subdirectory of a [11Xpkg[111X directory in (one of) the [5XGAP[105X root directories (see44[14X'Reference: GAP Root Directories'[114X). For example, if [5XGAP[105X is installed in45[11X/usr/local/gap4[111X then the files of the package [10XMyPack[110X may be placed in the46directory [11X/usr/local/gap4/pkg/mypack[111X. The directory [3Xpackage-dir[103X preferably47should have the following structure (below, a trailing [10X/[110X distinguishes48directories from ordinary files):[133X4950[4X[32X Example [32X[104X51[4X[28Xpackage-dir/[128X[104X52[4X[28X doc/[128X[104X53[4X[28X lib/[128X[104X54[4X[28X src/[128X[104X55[4X[28X tst/[128X[104X56[4X[28X README[128X[104X57[4X[28X CHANGES[128X[104X58[4X[28X configure[128X[104X59[4X[28X Makefile.in[128X[104X60[4X[28X PackageInfo.g[128X[104X61[4X[28X init.g[128X[104X62[4X[28X read.g[128X[104X63[4X[32X[104X6465[33X[0;0YThere are three file names with a special meaning in the home directory of a66package: [11XPackageInfo.g[111X and [11Xinit.g[111X which must be present, and [11Xread.g[111X which is67optional. We now describe the above files and directories:[133X6869[8X70[11XREADME[111X[108X71[33X[0;6YThis should contain [21Xhow to get it[121X (from the [5XGAP[105X [10Xftp[110X- and web-sites)72instructions, as well as installation instructions and names of the73package authors and their email addresses. The installation74instructions should be repeated in the package's documentation, which75should be in the [11Xdoc[111X directory (see [14XA.2[114X). Authors' names and addresses76should be repeated both in the package's documentation and in the77[11XPackageInfo.g[111X (see below).[133X7879[8X80[11XCHANGES[111X[108X81[33X[0;6YFor further versions of the package, it will be also useful to have a82[11XCHANGES[111X file that records the main changes between versions of the83package.[133X8485[8X[11Xconfigure[111X, [11XMakefile.in[111X[108X86[33X[0;6YThese files are only necessary if the package has a non-[5XGAP[105X component,87e.g. some C code (the files of which should be in the [11Xsrc[111X directory).88The [11Xconfigure[111X and [11XMakefile.in[111X files of the [5XExample[105X package provide89prototypes. The [11Xconfigure[111X file typically takes a path [3Xpath[103X to the [5XGAP[105X90root directory as argument and uses the value assigned to [10XGAParch[110X in91the file [11Xsysinfo.gap[111X, created when [5XGAP[105X was compiled to determine the92compilation architecture, inserts this in place of the string93[10X@GAPARCH@[110X in [11XMakefile.in[111X and creates a file [11XMakefile[111X. When [10Xmake[110X is run94(which, of course, reads the constructed [11XMakefile[111X), a directory [11Xbin[111X95(if necessary) and subdirectories of [11Xbin[111X with the path equal to the96string assigned to [10XGAParch[110X in the file [11Xsysinfo.gap[111X should be created;97any binaries constructed by compiling the code in [11Xsrc[111X should end up in98this subdirectory of [11Xbin[111X.[133X99100[8X[11XPackageInfo.g[111X[108X101[33X[0;6YSince [5XGAP[105X 4.4, a [5XGAP[105X package [13Xmust[113X have a [11XPackageInfo.g[111X file which102contains meta-information about the package (package name, version,103author(s), relations to other packages, homepage, download archives,104banner, ...). This information is used by the package loading105mechanism and also for the distribution of a package to other users.106The [5XExample[105X package's [11XPackageInfo.g[111X file is well-commented and should107be used as a prototype (see also [14XA.5[114X for further details).[133X108109[8X[11Xinit.g[111X, [11Xread.g[111X[108X110[33X[0;6YA [5XGAP[105X package [13Xmust[113X have a file [11Xinit.g[111X. As of [5XGAP[105X 4.4, the typical111[11Xinit.g[111X and [11Xread.g[111X files should normally consist entirely of112[2XReadPackage[102X ([14XReference: ReadPackage[114X) commands (and possibly also [2XRead[102X113([14XReference: Read[114X) commands) for reading further files of the package.114If the [21Xdeclaration[121X and [21Ximplementation[121X parts of the package are115separated (and this is recommended), there should be a [11Xread.g[111X file.116The [21Xdeclaration[121X part of a package consists of function and variable117[13Xname[113X declarations and these go in files with [10X.gd[110X extensions; these118files are read in via [10XReadPackage[110X commands in the [11Xinit.g[111X file. The119[21Ximplementation[121X part of a package consists of the actual definitions of120the functions and variables whose names were declared in the121[21Xdeclaration[121X part, and these go in files with [10X.gi[110X extensions; these122files are read in via [10XReadPackage[110X commands in the [11Xread.g[111X file. The123reason for following the above dichotomy is that the [11Xread.g[111X file is124read [13Xafter[113X the [11Xinit.g[111X file, thus enabling the possibility of a125function's implementation to refer to another function whose name is126known but is not actually defined yet (see [14XA.8[114X below for more127details).[133X128129[33X[0;6YThe [5XGAP[105X code (whether or not it is split into [21Xdeclaration[121X and130[21Ximplementation[121X parts) should go in the package's [11Xlib[111X directory (see131below).[133X132133[8X[11Xdoc[111X[108X134[33X[0;6YThis directory should contain the package's documentation. It is135strongly recommended to use an XML-based documentation format136supported by the [5XGAP[105X package [5XGAPDoc[105X (see [14X'GAPDoc: Introduction and137Example'[114X) which is used for the [5XGAP[105X documentation. An alternative is138to use the TeX-based system, formerly used for the [5XGAP[105X documentation139in [5XGAP[105X 4.4 and earlier releases. This system is described in the140document [21XThe gapmacro.tex Manual Format[121X (the file141[11Xgap4r5/doc/gapmacrodoc.pdf[111X included in the tools archive as described142in Section [14XA.2[114X) and is still used by some of the [5XGAP[105X packages whose143authors are encouraged to switch at some point to the [5XGAPDoc[105X-based144documenation. Please spend some time reading the documentation for145whichever system you decide to use for writing your package's146documentation. The [5XExample[105X package's documentation is written in the147XML format supported by the [5XGAPDoc[105X package. If you intend to use this148format, please use the [5XExample[105X package's [11Xdoc[111X directory as a prototype,149which as you will observe contains the master file [11Xmain.xml[111X, further150[11X.xml[111X files for manual chapters (included in the manual via [10XInclude[110X151directives in the master file) and the [5XGAP[105X input file [11X../makedocrel.g[111X152which generates the manuals. Generally, one should also provide a153[11Xmanual.bib[111X BibTeX database file or an [11Xxml[111X file in the BibXMLext format154(see [14X'GAPDoc: The BibXMLext Format'[114X). With [11Xgapmacro.tex[111X, it is also155possible to use a [11Xmanual.bbl[111X file.[133X156157[8X[11Xlib[111X[108X158[33X[0;6YThis is the preferred place for the [5XGAP[105X code, i.e. the [10X.g[110X, [10X.gd[110X and [10X.gi[110X159files (other than [11XPackageInfo.g[111X, [11Xinit.g[111X and [11Xread.g[111X). For some160packages, the directory [11Xgap[111X has been used instead of [11Xlib[111X; [11Xlib[111X has the161slight advantage that it is the default subdirectory of a package162directory searched for by the [2XDirectoriesPackageLibrary[102X ([14XReference:163DirectoriesPackageLibrary[114X) command.[133X164165[8X[11Xsrc[111X[108X166[33X[0;6YIf the package has non-[5XGAP[105X code, e.g. C code, then this [21Xsource[121X code167should go in the [11Xsrc[111X directory. If there are [10X.h[110X [21Xinclude[121X files you may168prefer to put these all together in a separate [10Xinclude[110X directory.169There is one further rule for the location of kernel library modules170or external programs which is explained in [14XA.10-1[114X below.[133X171172[8X[11Xtst[111X[108X173[33X[0;6YIf the package has test files, then they should go in the [11Xtst[111X174directory. For a deposited package, a test file with a basic test of175the package (for example, to check that it works as expected and/or176that the manual examples are correct) may be specified in the177[11XPackageInfo.g[111X to be included in the [5XGAP[105X standard test suite. More178specific and time consuming tests are not supposed to be a part of the179[5XGAP[105X standard test suite but may be placed in the [11Xtst[111X directory with180further instructions on how to run them. See Section [14XA.14[114X about the181requirements to the test files formats and further recommendations.[133X182183[33X[0;0YAll other files can be organized as you like. But we suggest that you have a184look at existing packages and use a similar scheme, for example, put185examples in the [11Xexamples[111X subdirectory, data libraries in extra186subdirectories, and so on.[133X187188[33X[0;0YSometimes there may be a need to include an empty directory in the package189distribution (for example, as a place to store some data that may appear at190runtime). In this case package authors are advised to put in this directory191a short [11XREADME[111X file describing its purpose to ensure that such directory192will be included in the redistribution.[133X193194[33X[0;0YConcerning the [5XGAP[105X code in packages, it is recommended to use only195documented [5XGAP[105X functions, see [14X'Reference: Undocumented Variables'[114X. In196particular if you want to make your package available to other [5XGAP[105X users it197is advisable to avoid using [21Xobsolescent[121X variables (see [14X'Reference: Replaced198and Removed Command Names'[114X). For that, you can set the [10XReadObsolete[110X199component in your [11Xgap.ini[111X file to [9Xfalse[109X, see [14X'Reference: The gap.ini and200gaprc files'[114X.[133X201202203[1XA.2 [33X[0;0YWriting Documentation and Tools Needed[133X[101X204205[33X[0;0YIf you intend to make your package available to other users it is essential206to include documentation explaining how to install and use your programs.[133X207208[33X[0;0YConcerning the installation you should produce a file [11XREADME[111X which gives a209short description of the purpose of the package and contains proper210instructions how to install your package. Again, check out some existing211packages to get an idea how this could look like.[133X212213[33X[0;0YConcerning the documentation of the use of the package there are currently214two recognised ways of producing [5XGAP[105X package documentation.[133X215216[33X[0;0YFirst, there is a recommended XML-based documentation format that is defined217in and can be used with the [5XGAPDoc[105X package (see [14X'GAPDoc: Introduction and218Example'[114X).[133X219220[33X[0;0YSecond, there is a method which requires the documentation to be written in221TeX according to the format described in the document [21XThe gapmacro.tex222Manual Format[121X.[133X223224[33X[0;0YIn principle it is also possible to use some completely different225documentation format. In that case you need to study the Chapter [14X'Reference:226Interface to the GAP Help System'[114X to learn how to make your documentation227available to the [5XGAP[105X help system. There should be at least a text version of228your documenation provided for use in the terminal running [5XGAP[105X and some229nicely printable version in [10X.pdf[110X format. Many [5XGAP[105X users like to browse the230documentation in HTML format via their Web browser. As a package author, you231are not obliged to provide an HTML version of your package manual, but if232you will either use the [5XGAPDoc[105X package or follow the guidelines in the233document [21XThe gapmacro.tex Manual Format[121X, (the file234[11Xgap4r5/doc/gapmacrodoc.pdf[111X included in the tools archive as described in235this Section below), you should have no trouble in producing one. Moreover,236using the [5XGAPDoc[105X package, it is also possible to produce HTML version of the237documentation supporting MathJax ([7Xhttp://www.mathjax.org/[107X) for the high238quality rendering of mathematical symbols while viewing it online. For239example, if you are viewing the HTML version of the manual, compare how this240formula will look with MathJax turned on/off:[133X241242243[33X[1;6Y[24X[33X[0;0Y[ χ, ψ ] = ( ∑_{g ∈ G} χ(g) ψ(g^{-1}) ) / |G|.[133X[124X[133X244245246[33X[0;0YThe manual of the [5XExample[105X package is written in the [5XGAPDoc[105X format, and247commands needed to build it are contained in the file [10Xmakedocrel.g[110X (you248don't need to re-build the manual since it is already included in the249package).[133X250251[33X[0;0YWhenever you use the [5XGAPDoc[105X or [11Xgapmacro.tex[111X TeX-based system, you need to252have certain TeX tools installed: to produce manuals in the [10X.pdf[110X format, you253need [10Xpdflatex[110X if the [5XGAPDoc[105X is used, and either [10Xpdftex[110X or [10Xgs[110X together with254[10Xps2pdf[110X if your package uses [11Xgapmacro.tex[111X. Note that using [10Xgs[110X and [10Xps2pdf[110X in255lieu of [10Xpdftex[110X or [10Xpdflatex[110X is a poor substitute unless your [10Xgs[110X is at least256version 6.[3Xxx[103X for some [3Xxx[103X. In addition, the [10Xgapmacro.tex[110X documentation system257requires some more tools described below. If you intend to use the [5XGAPDoc[105X258package for the documenation of your package, you may skip the rest of this259section and proceed to the next one to see a minimalistic example of a [5XGAP[105X260package.[133X261262[33X[0;0YOtherwise, to produce the [10X.pdf[110X manual formats, the following [5XGAP[105X tools263(supplied as a part of the [5XGAP[105X distribution in the archive [10Xtools.tar.gz[110X in264the in [5XGAP[105X's [11Xetc[111X directory and installed using the script [11Xinstall-tools.sh[111X265in the same directory) are needed: [11Xgapmacro.tex[111X (the macros file that266dictates the style and mark-up for the traditional TeX-based system of [5XGAP[105X267documentation), [10Xmanualindex[110X (an [10Xawk[110X script that adjusts the TeX-produced268index entries and calls [10Xmakeindex[110X to process them), and [11Xmrabbrev.bib[111X269(usually supplied with your TeX tools but nevertheless a copy of270[11Xmrabbrev.bib[111X should be located in [5XGAP[105X's main [11Xdoc[111X directory. To find it on271your system, try: [10Xkpsewhich mrabbrev.bib[110X or, if that doesn't work and you272can't otherwise find it check out a CTAN site, e.g. search for it at:273[7Xhttp://www.dante.de/cgi-bin/ctan-index[107X.[133X274275[33X[0;0YIf your manual cross-refers to [5XGAPDoc[105X- or [11Xgapmacro.tex[111X-produced manuals,276then [10Xmanual.lab[110X for each such other manual is needed. For packages using277[5XGAPDoc[105X-manuals since [5XGAP[105X 4.3, this is done by starting [5XGAP[105X and running[133X278279[33X[0;0Y [10Xgap> GapDocManualLab( "[3Xpackage[103X[10X" );[110X[133X280281[33X[0;0Yfor each such [3Xpackage[103X whose manual is cross-referred to (this includes the282[21Xmain[121X manuals, e.g. those in the [11Xdoc/ref[111X and [11Xdoc/tut[111X directories). For283packages using [11Xgapmacro.tex[111X-produced manuals, [10Xmanual.lab[110X is generated by284running [10Xtex manual[110X for each package whose manual is cross-referred to. In285most cases, packages from the [5XGAP[105X distribution will already have these files286since they will be created as a part of building their manuals (see e.g. the287last command of the [11Xexample/makedocrel.g[111X script) and included in their288distribution, so you will probably not need to create [10Xmanual.lab[110X files289yourself.[133X290291[33X[0;0YTo produce an HTML version of the manual one needs the Perl 5 program292[11Xconvert.pl[111X which is included in the tools archive [10Xtools.tar.gz[110X. This archive293is supplied as a part of the [5XGAP[105X distribution in the [5XGAP[105X's [11Xetc[111X directory and294should be installed using the script [11Xinstall-tools.sh[111X in the same directory.[133X295296[33X[0;0YFinally, to ensure the mathematical formulae are rendered as well as they297can be in the HTML version, one should also have the program [10Xtth[110X (TeX to298HTML converter); [11Xconvert.pl[111X calls [11Xtth[111X to translate mathmode formulae to HTML299(if it's available). The [11Xtth[111X program is easy to compile and can be obtained300from [7Xhttp://hutchinson.belmont.ma.us/tth/tth-noncom/download.html[107X.[133X301302303[1XA.3 [33X[0;0YAn Example of a GAP Package[133X[101X304305[33X[0;0YWe illustrate the creation of a [5XGAP[105X package by an example of a basic306package.[133X307308[33X[0;0YCreate the following directories in your home area: [11X.gap[111X, [11X.gap/pkg[111X and309[11X.gap/pkg/test[111X. Then inside the directory [11X.gap/pkg/test[111X create an empty file310[11Xinit.g[111X, and a file [11XPackageInfo.g[111X with the following contents:[133X311312[4X[32X Example [32X[104X313[4X[28XSetPackageInfo( rec([128X[104X314[4X[28X PackageName := "test",[128X[104X315[4X[28X Version := "1.0",[128X[104X316[4X[28X PackageDoc := rec([128X[104X317[4X[28X BookName := "test",[128X[104X318[4X[28X SixFile := "doc/manual.six",[128X[104X319[4X[28X Autoload := true ),[128X[104X320[4X[28X Dependencies := rec([128X[104X321[4X[28X GAP := "4.5",[128X[104X322[4X[28X NeededOtherPackages := [ ["GAPDoc", "1.3"] ],[128X[104X323[4X[28X SuggestedOtherPackages := [ ] ),[128X[104X324[4X[28X AvailabilityTest := ReturnTrue ) );[128X[104X325[4X[32X[104X326327[33X[0;0YThis file declares the [5XGAP[105X package with name [21Xtest[121X in version 1.0. The328package documentation consists of one autoloaded book; the [10XSixFile[110X component329is needed by the [5XGAP[105X help system. Package dependencies require at least330[5XGAP[105X 4.5 and [5XGAPDoc[105X package at version at least 1.3, and these conditions331will be checked when the package will be loaded (see [14XA.13[114X). Since there are332no requirements that have to be tested, [10XAvailabilityTest[110X just uses333[2XReturnTrue[102X ([14XReference: ReturnTrue[114X).[133X334335[33X[0;0YNow start [5XGAP[105X (without using the [10X-r[110X option) and the [11X.gap[111X directory will be336added to the [5XGAP[105X root directory to allow [5XGAP[105X to find the packages installed337there (see [14X'Reference: GAP Root Directories'[114X).[133X338339[4X[32X Example [32X[104X340[4X[25Xgap>[125X [27XLoadPackage("test");[127X[104X341[4X[28Xtrue[128X[104X342[4X[32X[104X343344[33X[0;0YThis [5XGAP[105X package is too simple to be useful, but we have succeeded in345loading it via [2XLoadPackage[102X ([14XReference: LoadPackage[114X), satisfying all346specified dependencies.[133X347348349[1XA.4 [33X[0;0YFile Structure[133X[101X350351[33X[0;0YPackage files may follow the style used for the [5XGAP[105X library. Every file in352the [5XGAP[105X library starts with a header that lists the filename, copyright, a353short description of the file contents and the original authors of this354file, and ends with a comment line [10X#E[110X. Indentation in functions and the use355of decorative spaces in the code are left to the decision of the authors of356each file. Global (i.e. re-used elsewhere) comments usually are indented by357two hash marks and two blanks, in particular, every declaration or method or358function installation which is not only of local scope is separated by a359header.[133X360361[33X[0;0YHistorically, when the [5XGAP[105X main manuals were based on the TeX macros362described in the document [21XThe gapmacro.tex Manual Format[121X (the file363[11Xgap4r5/doc/gapmacrodoc.pdf[111X included in the tools archive as described in364Section [14XA.2[114X) such headers were used for the manuals and have the type[133X365366[4X[32X Example [32X[104X367[4X[28X#############################################################################[128X[104X368[4X[28X##[128X[104X369[4X[28X#X ExampleFunction(<A>,<B>)[128X[104X370[4X[28X##[128X[104X371[4X[28X## This function does great things.[128X[104X372[4X[32X[104X373374[33X[0;0Ywhere [21XX[121X was one of the letters: [10XF[110X, [10XA[110X, [10XP[110X, [10XO[110X, [10XC[110X, [10XR[110X or [10XV[110X indicating whether the375object declared will be a function, attribute, property, operation,376category, representation or variable, respectively. Additionally [10XM[110X was used377in [10X.gi[110X files for method installations. Then a sample usage of the function378was given, followed by a comment which described the identifier. This379description was automatically be extracted to build the manual source, if380there is a [10X\Declaration[110X line in some [10X.msk[110X file together with an appropriate381configuration file.[133X382383[33X[0;0YNowadays, facilities to distribute a document over several files to allow384the documentation for parts of some code to be stored in the same file as385the code itself are provided by the [5XGAPDoc[105X package (see [14X'GAPDoc:386Distributing a Document into Several Files'[114X). The same approach is387demonstrated by the [5XExample[105X package. E.g. [11Xexample/doc/example.xml[111X has the388statement [10X<#Include Label="ListDirectory">[110X and [11Xexample/lib/files.gd[111X contains[133X389390[4X[32X Example [32X[104X391[4X[28X#############################################################################[128X[104X392[4X[28X##[128X[104X393[4X[28X#F ListDirectory([<dir>]) . . . . . . . . . . list the files in a directory[128X[104X394[4X[28X##[128X[104X395[4X[28X## <#GAPDoc Label="ListDirectory">[128X[104X396[4X[28X## <ManSection>[128X[104X397[4X[28X## <Func Name="ListDirectory" Arg="[dir]"/>[128X[104X398[4X[28X##[128X[104X399[4X[28X## <Description>[128X[104X400[4X[28X## lists the files in directory <A>dir</A> (a string) [128X[104X401[4X[28X## or the current directory if called with no arguments.[128X[104X402[4X[28X## </Description>[128X[104X403[4X[28X## </ManSection>[128X[104X404[4X[28X## <#/GAPDoc>[128X[104X405[4X[28XDeclareGlobalFunction( "ListDirectory" );[128X[104X406[4X[32X[104X407408[33X[0;0YThis is all put together in the file [11Xexample/makedocrel.g[111X which builds the409package documentation, calling [2XMakeGAPDocDoc[102X ([14XGAPDoc: MakeGAPDocDoc[114X) with410locations of library files containing parts of the documentation.[133X411412413[1XA.5 [33X[0;0YThe PackageInfo.g File[133X[101X414415[33X[0;0YAs a first step the example in [14XA.3[114X shows the information needed for the416package loading mechanism to load a simple package. However, if your package417depends on the functionality of other packages, the component [10XDependencies[110X418given in the [11XPackageInfo.g[111X file becomes important (see [14XA.7[114X below), and more419entries become relevant if you want to distribute your package: they contain420lists of authors and/or maintainers including contact information, URLs of421the package archives and README files, status information, text for a422package overview Web page, and so on.[133X423424[33X[0;0YWe suggest to create a [11XPackageInfo.g[111X file for your package by copying the425one in the [5XExample[105X package, distributed with [5XGAP[105X, and then adjusting it for426your package. Within [5XGAP[105X you can look at this template file for a list and427explanation of all recognized entries by[133X428429[4X[32X Example [32X[104X430[4X[28XPager(StringFile(Filename(DirectoriesLibrary(), [128X[104X431[4X[28X "../pkg/example/PackageInfo.g")));[128X[104X432[4X[32X[104X433434[33X[0;0YOnce you have created the [11XPackageInfo.g[111X file for your package, you can test435its validity with the function [2XValidatePackageInfo[102X ([14XReference:436ValidatePackageInfo[114X).[133X437438439[1XA.6 [33X[0;0YFunctions and Variables and Choices of Their Names[133X[101X440441[33X[0;0YIn writing the [5XGAP[105X code for your package you need to be a little careful on442just how you define your functions and variables.[133X443444[33X[0;0Y[13XFirstly[113X, in general one should avoid defining functions and variables via445assignment statements in the way you would interactively, e.g.[133X446447[4X[32X Example [32X[104X448[4X[25Xgap>[125X [27XSquared := x -> x^2;;[127X[104X449[4X[25Xgap>[125X [27XCubed := function(x) return x^3; end;;[127X[104X450[4X[32X[104X451452[33X[0;0YThe reason for this is that such functions and variables are [13Xeasily453overwritten[113X and what's more you are not warned about it when it happens.[133X454455[33X[0;0YTo protect a function or variable against overwriting there is the command456[2XBindGlobal[102X ([14XReference: BindGlobal[114X), or alternatively (and equivalently) you457may define a global function via a [2XDeclareGlobalFunction[102X ([14XReference:458DeclareGlobalFunction[114X) and [2XInstallGlobalFunction[102X ([14XReference:459InstallGlobalFunction[114X) pair or a global variable via a [2XDeclareGlobalVariable[102X460([14XReference: DeclareGlobalVariable[114X) and [2XInstallValue[102X ([14XReference:461InstallValue[114X) pair. There are also operations and their methods, and related462objects like attributes and filters which also have [10XDeclare...[110X and463[10XInstall...[110X pairs.[133X464465[33X[0;0Y[13XSecondly[113X, it's a good idea to reduce the chance of accidental overwriting by466choosing names for your functions and variables that begin with a string467that identifies it with the package, e.g. some of the undocumented functions468in the [5XExample[105X package begin with [10XEg[110X. This is especially important in cases469where you actually want the user to be able to change the value of a470function or variable defined by your package, for which you have used direct471assignments (for which the user will receive no warning if she accidentally472overwrites them). It's also important for functions and variables defined473via [10XBindGlobal[110X, [10XDeclareGlobalFunction[110X/[10XInstallGlobalFunction[110X and474[10XDeclareGlobalVariable[110X/[10XInstallValue[110X, in order to avoid name clashes that may475occur with (extensions of) the [5XGAP[105X library and other packages.[133X476477[33X[0;0YAdditionally, since [5XGAP[105X 4.5 a package may place global variables into a478local namespace as explained in [14X'Reference: Namespaces for GAP packages'[114X in479order to avoid name clashes and preserve compatibility. This new feature480allows you to define in your package global variables with the identifier481ending with the [10X@[110X symbol, e.g. [10XxYz@[110X. Such variables may be used in your482package code safely, as they may be accessed from outside the package only483by their full name, i.e. [10XxYz@YourPackageName[110X. This helps to prevent clashes484between different packages or between a package and the [5XGAP[105X library because485of the same variable names.[133X486487[33X[0;0YOn the other hand, operations and their methods (defined via488[2XDeclareOperation[102X ([14XReference: DeclareOperation[114X), [2XInstallMethod[102X ([14XReference:489InstallMethod[114X) etc. pairs) and their relatives do not need this490consideration, as they avoid name clashes by allowing for more than one491[21Xmethod[121X for the same-named object.[133X492493[33X[0;0YTo demonstrate the definition of a function via a494[10XDeclareOperation[110X/[10XInstallMethod[110X pair, the method [2XRecipe[102X ([14X1.1-8[114X) was included495in the [5XExample[105X package; [10XRecipe( FruitCake );[110X gives a [21Xmethod[121X for making a496fruit cake (forgive the pun).[133X497498[33X[0;0Y[13XThirdly[113X, functions or variables with [10XSet[3XXXX[103X[10X[110X or [10XHas[3XXXX[103X[10X[110X names (even if they499are defined as operations) should be avoided as these may clash with objects500associated with attributes or properties (attributes and properties [3XXXX[103X501declared via the [10XDeclareAttribute[110X and [10XDeclareProperty[110X commands have502associated with them testers of form [10XHas[3XXXX[103X[10X[110X and setters of form [10XSet[3XXXX[103X[10X[110X).[133X503504[33X[0;0Y[13XFourthly[113X, it is a good idea to have some convention for internal functions505and variables (i.e. the functions and variables you don't intend for the506user to use). For example, they might be entirely CAPITALISED.[133X507508[33X[0;0YAdditionally, there is a recommended naming convention that the [5XGAP[105X core509system and [5XGAP[105X packages should not use global variables starting in the510lowercase. This allows to reserve variables with names starting in lowecase511to the [5XGAP[105X user so they will never clash with the system. It is extremely512important to avoid using for package global variables very short names513started in lowercase. For example, such names like [10Xcs[110X, [10Xexp[110X, [10Xngens[110X, [10Xpc[110X, [10Xpow[110X514which are perfectly fine for local variables, should never be used for515globals. Additionally, the package must not have writable global variables516with very short names even if they are starting in uppercase, for example,517[10XC1[110X or [10XORB[110X, since they also could be easily overwritten by the user.[133X518519[33X[0;0YIt is a good practice to follow naming conventions used in [5XGAP[105X as explained520in [14X'Reference: Naming Conventions'[114X and [14X'Tutorial: Changing the Structure'[114X,521which might help users to memorize or even guess names of functions provided522by the package.[133X523524[33X[0;0Y[13XFinally[113X, note the advantage of using525[10XDeclareGlobalFunction[110X/[10XInstallGlobalFunction[110X,526[10XDeclareGlobalVariable[110X/[10XInstallValue[110X, etc. pairs (rather than [10XBindGlobal[110X) to527define functions and variables, which allow the package author to organise528her function- and variable- definitions in any order without worrying about529any interdependence. The [10XDeclare...[110X statements should go in files with [10X.gd[110X530extensions and be loaded by [10XReadPackage[110X statements in the package [11Xinit.g[111X531file, and the [10XInstall...[110X definitions should go in files with [10X.gi[110X extensions532and be loaded by [10XReadPackage[110X statements in the package [11Xread.g[111X file; this533ensures that the [10X.gi[110X files are read [13Xafter[113X the [10X.gd[110X files. All other package534code should go in [10X.g[110X files (other than the [11Xinit.g[111X and [11Xread.g[111X files535themselves) and be loaded via [10XReadPackage[110X statements in the [11Xinit.g[111X file.[133X536537[33X[0;0YIn conclusion, here is some practical advice on how to check which variables538are used by the package.[133X539540[33X[0;0YFirstly, there is a function [2XShowPackageVariables[102X ([14XReference:541ShowPackageVariables[114X). If the package [3Xpkgname[103X is available but not yet542loaded then [10XShowPackageVariables( pkgname )[110X prints a list of global543variables that become bound and of methods that become installed when the544package is loaded (for that, the package will be actually loaded, so545[10XShowPackageVariables[110X can be called only once for the same package in the546same [5XGAP[105X session.) The second optional argument [3Xversion[103X may specify a547particular package version to be loaded. An error message will be printed if548(the given version of) the package is not available or already loaded.[133X549550[33X[0;0YInfo lines for undocumented variables will be marked with an asterisk [10X*[110X.551Note that the [5XGAP[105X help system is case insensitive, so it is difficult to552document identifiers that differ only by case.[133X553554[33X[0;0YThe following entries are omitted from the list: default setter methods for555attributes and properties that are declared in the package, and [10XSet[3Xattr[103X[10X[110X and556[10XHas[3Xattr[103X[10X[110X type variables where [3Xattr[103X is an attribute or property.[133X557558[33X[0;0YFor example, for this package it currently produces the following output:[133X559560[4X[32X Example [32X[104X561[4X[25Xgap>[125X [27XShowPackageVariables("example");[127X[104X562[4X[28X----------------------------------------------------------------[128X[104X563[4X[28XLoading Example 3.3 (Example/Template of a GAP Package)[128X[104X564[4X[28Xby Werner Nickel (http://www.mathematik.tu-darmstadt.de/~nickel),[128X[104X565[4X[28X Greg Gamble (http://www.math.rwth-aachen.de/~Greg.Gamble), and[128X[104X566[4X[28X Alexander Konovalov (http://www.cs.st-andrews.ac.uk/~alexk/).[128X[104X567[4X[28X----------------------------------------------------------------[128X[104X568[4X[28Xnew global functions:[128X[104X569[4X[28X EgSeparatedString( str, c )*[128X[104X570[4X[28X FindFile( dir, file )[128X[104X571[4X[28X HelloWorld( )[128X[104X572[4X[28X ListDirectory( arg )[128X[104X573[4X[28X LoadedPackages( )[128X[104X574[4X[28X WhereIsPkgProgram( prg )[128X[104X575[4X[28X Which( prg )[128X[104X576[4X[28X[128X[104X577[4X[28Xnew global variables:[128X[104X578[4X[28X FruitCake[128X[104X579[4X[28X[128X[104X580[4X[28Xnew operations:[128X[104X581[4X[28X Recipe( arg )[128X[104X582[4X[28X[128X[104X583[4X[28Xnew methods:[128X[104X584[4X[28X Recipe( cake )[128X[104X585[4X[32X[104X586587[33X[0;0YAnother trick is to start [5XGAP[105X with [10X-r -A[110X options, immediately load your588package and then call [2XNamesUserGVars[102X ([14XReference: NamesUserGVars[114X) which589returns a list of the global variable names created since the library was590read, to which a value is currently bound. For example, for the [5XExample[105X it591produces[133X592593[4X[32X Example [32X[104X594[4X[25Xgap>[125X [27XNamesUserGVars();[127X[104X595[4X[28X[ "EgSeparatedString", "FindFile", "FruitCake", "HelloWorld", "ListDirectory",[128X[104X596[4X[28X "LoadedPackages", "Recipe", "WhereIsPkgProgram", "Which" ][128X[104X597[4X[32X[104X598599[33X[0;0Ybut for packages with dependencies it will also contain variables created by600other packages. Nevertheless, it may be a useful check to search for601unwanted variables appearing after package loading. A potentially dangerous602situation which should be avoided is when the package uses some simply named603temporary variables at the loading stage. Such [21Xphantom[121X variables may then604remain unnoticed and, as a result, there will be no warnings if the user605occasionally uses the same name as a local variable name in a function. Even606more dangerous is the case when the user variable with the same name already607exists before the package is loaded so it will be silently overwritten.[133X608609610[1XA.7 [33X[0;0YPackage Dependencies (Requesting one [5XGAP[105X[101X[1X Package from within Another)[133X[101X611612[33X[0;0YIt is possible for one [5XGAP[105X package [10XA[110X, say, to require another package [10XB[110X. For613that, one simply adds the name and the (least) version number of the package614[10XB[110X to the [10XNeededOtherPackages[110X component of the [10XDependencies[110X component of the615[11XPackageInfo.g[111X file of the package [10XA[110X. In this situation, loading the package616[10XA[110X forces that also the package [10XB[110X is loaded, and that [10XA[110X cannot be loaded if [10XB[110X617is not available.[133X618619[33X[0;0YIf [10XB[110X is not essential for [10XA[110X but should be loaded if it is available (for620example because [10XB[110X provides some improvements of the main system that are621useful for [10XA[110X) then the name and the (least) version number of [10XB[110X should be622added to the [10XSuggestedOtherPackages[110X component of the [10XDependencies[110X component623of the [11XPackageInfo.g[111X file of [10XA[110X. In this situation, loading [10XA[110X forces an624attempt to load also [10XB[110X, but [10XA[110X is loaded even if [10XB[110X is not available.[133X625626[33X[0;0YAlso the component [10XDependencies.OtherPackagesLoadedInAdvance[110X in627[11XPackageInfo.g[111X is supported, which describes needed packages that shall be628loaded before the current package is loaded. See [14XA.8[114X for details about this629and more generally about the order in which the files of the packages in630question are read.[133X631632[33X[0;0YAll package dependencies must be documented explicitly in the [11XPackageInfo.g[111X633file. It is important to properly identify package dependencies and make the634right decision whether the other package should be [21Xneeded[121X or [21Xsuggested[121X. For635example, declaring package as [21Xneeded[121X when [21Xsuggested[121X might be sufficient may636prevent loading of packages under Windows for no good reason.[133X637638[33X[0;0YIt is not appropriate to explicitly call [2XLoadPackage[102X ([14XReference:639LoadPackage[114X) [13Xwhen the package is loaded[113X, since this may distort the order of640package loading and result in warning messages. It is recommended to turn641such dependencies into needed or suggested packages. For example, a package642can be designed in such a way that it can be loaded with restricted643functionality if another package (or standalone program) is missing, and in644this case the missing package (or binary) is [13Xsuggested[113X. Alternatively, if645the package author decides that loading the package in this situation makes646no sense, then the missing component is [13Xneeded[113X.[133X647648[33X[0;0YOn the other hand, if [2XLoadPackage[102X ([14XReference: LoadPackage[114X) is called inside649functions of the package then there is no such problem, provided that these650functions are called only after the package has been loaded, so it is not651necessary to specify the other package as suggested. The same applies to652test files and manual examples, which may be simply extended by calls to653[2XLoadPackage[102X ([14XReference: LoadPackage[114X).[133X654655[33X[0;0YIt may happen that a package B that is listed as a suggested package of656package A is actually needed by A. If no explicit [2XLoadPackage[102X ([14XReference:657LoadPackage[114X) calls for B occur in A at loading time, this can now be658detected using the new possibility to load a package without loading its659suggested packages using the global option [10XOnlyNeeded[110X which can be used to660(recursively) suppress loading the suggested packages of the package in661question. Using this option, one can check whether errors or warnings appear662when B is not available (note that this option should be used only for such663checks to simulate the situation when package B is not available; it is not664supposed to be used in an actual [5XGAP[105X session when package B will be loaded665later, since this may cause problems). In case of any errors or warnings,666their consequence can then be either turning B into a needed package or667(since apparently B was not intended to become a needed package) changing668the code accordingly. Only if package A calls [2XLoadPackage[102X ([14XReference:669LoadPackage[114X) for B at loading time (see above) then package B needs to be670[13Xdeinstalled[113X (i.e. removed) to test loading of A without B.[133X671672[33X[0;0YFinally, if the package manual is in the [5XGAPDoc[105X format, then [5XGAPDoc[105X should673still be listed as [13Xneeded[113X for this package (not as [13Xsuggested[113X), even though674[5XGAPDoc[105X is now a needed package for [5XGAP[105X itself.[133X675676677[1XA.8 [33X[0;0YDeclaration and Implementation Part of a Package[133X[101X678679[33X[0;0YWhen [5XGAP[105X packages require each other in a circular way, a [21Xbootstrapping[121X680problem arises of defining functions before they are called. The same681problem occurs in the [5XGAP[105X library, and it is resolved there by separating682declarations (which define global variables such as filters and operations)683and implementations (which install global functions and methods) in684different files. Any implementation file may use global variables defined in685any declaration file. [5XGAP[105X initially reads all declaration files (in the686library they have a [10X.gd[110X suffix) and afterwards reads all implementation687files (which have a [10X.gi[110X suffix).[133X688689[33X[0;0YSomething similar is possible for [5XGAP[105X packages: if a file [11Xread.g[111X exists in690the home directory of the package, this file is read only [13Xafter[113X all the691[11Xinit.g[111X files of all (implicitly) required [5XGAP[105X packages are read. Thus one692can separate declaration and implementation for a [5XGAP[105X package in the same693way as is done for the [5XGAP[105X library, by creating a file [11Xread.g[111X, restricting694the [2XReadPackage[102X ([14XReference: ReadPackage[114X) statements in [11Xinit.g[111X to only read695those files of the package that provide declarations, and to read the696implementation files from [11Xread.g[111X.[133X697698[33X[0;0Y[13XExamples:[113X[133X699700[33X[0;0YSuppose that there are two packages [10XA[110X and [10XB[110X, each with files [11Xinit.g[111X and701[11Xread.g[111X.[133X702703[30X [33X[0;6YIf package [10XA[110X suggests or needs package [10XB[110X and package [10XB[110X does not need704or suggest any other package then first [11Xinit.g[111X of [10XB[110X is read, then705[11Xread.g[111X of [10XB[110X, then [11Xinit.g[111X of [10XA[110X, then [11Xread.g[111X of [10XA[110X.[133X706707[30X [33X[0;6YIf package [10XA[110X suggests or needs package [10XB[110X and package [10XB[110X (or a package708that is suggested or needed by [10XB[110X) suggests or needs package [10XA[110X then709first the files [11Xinit.g[111X of [10XA[110X and [10XB[110X are read (in an unspecified order)710and then the files [11Xread.g[111X of [10XA[110X and [10XB[110X (in the same order).[133X711712[33X[0;0YIn general, when [5XGAP[105X is asked to load a package then first the dependencies713between this packages and its needed and suggested packages are inspected714(recursively), and a list of package sets is computed such that no cyclic715dependencies occur between different package sets and such that no package716in any of the package sets needs any package in later package sets. Then [5XGAP[105X717runs through the package sets and reads for each set first all [11Xinit.g[111X files718and then all [11Xread.g[111X files of the packages in the set. (There is one719exception from this rule: Whenever packages are autoloaded before the720implementation part of the [5XGAP[105X library is read, only the [11Xinit.g[111X files of the721packages are read; as soon as the [5XGAP[105X library has been read, the [11Xread.g[111X722files of these packages are also read, and afterwards the above rule holds.)[133X723724[33X[0;0YIt can happen that some code of a package depends on the availability of725suggested packages, i.e., different initializations are performed depending726on whether a suggested package will eventually be loaded or not. One can727test this condition with the function [2XIsPackageMarkedForLoading[102X ([14XReference:728IsPackageMarkedForLoading[114X). In particular, one should [13Xnot[113X call (and use the729value returned by this call) the function [2XLoadPackage[102X ([14XReference:730LoadPackage[114X) inside package code that is read during package loading. Note731that for debugging purposes loading suggested packages may have been732deliberately disabled via the global option [10XOnlyNeeded[110X.[133X733734[33X[0;0YNote that the separation of the [5XGAP[105X code of packages into declaration part735and implementation part does in general [13Xnot[113X allow one to actually [13Xcall[113X736functions from a package when the implementation part is read. For example,737in the case of a [21Xcyclic dependency[121X as in the second example above, suppose738that [10XB[110X provides a new function [10Xf[110X or a new global record [10Xr[110X, say, which are739declared in the declaration part of [10XB[110X. Then the code in the implementation740part of [10XA[110X may contain calls to the functions defined in the declaration part741of [10XB[110X. However, the implementation part of [10XA[110X may be read [13Xbefore[113X the742implementation part of [10XB[110X. So one can in general not assume that during the743loading of [10XA[110X, the function [10Xf[110X can be called, or that one can access744components of the record [10Xr[110X.[133X745746[33X[0;0YIf one wants to call the function [10Xf[110X or to access components of the record [10Xr[110X747in the code of the package [10XA[110X then the problem is that it may be not possible748to determine a cyclic dependency between [10XA[110X and [10XB[110X from the packages [10XA[110X and [10XB[110X749alone. A safe solution is then to add the name of [10XB[110X to the component750[10XDependencies.OtherPackagesLoadedInAdvance[110X of the [11XPackageInfo.g[111X file of [10XA[110X.751The effect is that package [10XB[110X is completely loaded before the file [11Xread.g[111X of752[10XA[110X is read, provided that there is no cyclic dependency between [10XA[110X and [10XB[110X, and753that package [10XA[110X is regarded as not available in the case that such a cyclic754dependency between [10XA[110X and [10XB[110X exists.[133X755756[33X[0;0YA special case where [10XDependencies.OtherPackagesLoadedInAdvance[110X can be useful757is that a package wants to force the complete [5XGAP[105X library to be read before758the file [11Xread.g[111X of the package [10XA[110X is read. In this situation, the [21Xpackage759name[121X [10X"gap"[110X should be added to this component in the [11XPackageInfo.g[111X file of [10XA[110X.[133X760761[33X[0;0YIn the case of cyclic dependencies, one solution for the above problem might762be to delay those computations (typically initializations) in package [10XA[110X that763require package [10XB[110X to be loaded until all required packages are completely764loaded. This can be done by moving the declaration and implementation of the765variables that are created in the initialization into a separate file and to766declare these variables in the [11Xinit.g[111X file of the package, via a call to767[2XDeclareAutoreadableVariables[102X ([14XReference: DeclareAutoreadableVariables[114X) (see768also [14XA.9[114X).[133X769770771[1XA.9 [33X[0;0YAutoreadable Variables[133X[101X772773[33X[0;0YPackage files containing method installations must be read when the package774is loaded. For package files [13Xnot[113X containing method installations (this775applies, for example, to many data files) another mechanism allows one to776delay reading such files until the data are actually accessed. See777[14XReference: DeclareAutoreadableVariables[114X for further details.[133X778779780[1XA.10 [33X[0;0YStandalone Programs in a [5XGAP[105X[101X[1X Package[133X[101X781782[33X[0;0Y[5XGAP[105X packages that involve stand-alone programs are fundamentally different783from [5XGAP[105X packages that consist entirely of [5XGAP[105X code.[133X784785[33X[0;0YThis difference is threefold: A user who installs the [5XGAP[105X package must also786compile (or install) the package's binaries, the package must check whether787the binaries are indeed available, and finally the [5XGAP[105X code of the package788has to start the external binary and to communicate with it. We will cover789these three points in the following sections.[133X790791[33X[0;0YIf the package does not solely consist of an interface to an external binary792and if the external program called is not just special-purpose code, but a793generally available program, chances are high that sooner or later other [5XGAP[105X794packages might also require this program. We therefore strongly recommend795the provision of a documented [5XGAP[105X function that will call the external796binary. We also suggest to create actually two [5XGAP[105X packages; the first797providing only the binary and the interface and the second (requiring the798first, see [14XA.7[114X) being the actual [5XGAP[105X package.[133X799800801[1XA.10-1 [33X[0;0YInstallation of [5XGAP[105X[101X[1X Package Binaries[133X[101X802803[33X[0;0YThe scheme for the installation of package binaries which is described804further on is intended to permit the installation on different architectures805which share a common file system (and share the architecture independent806file).[133X807808[33X[0;0YA [5XGAP[105X package which includes external binaries contains a [11Xbin[111X subdirectory.809This subdirectory in turn contains subdirectories for the different810architectures on which the [5XGAP[105X package binaries are installed. The names of811these directories must be the same as the names of the architecture812dependent subdirectories of the main [11Xbin[111X directory. Unless you use a tool813like [10Xautoconf[110X yourself, you must obtain the correct name of the binary814directory from the main [5XGAP[105X branch. To help with this, the main [5XGAP[105X815directory contains a file [11Xsysinfo.gap[111X which assigns the shell variable816[10XGAParch[110X to the proper name as determined by [5XGAP[105X's [10Xconfigure[110X process. For817example on a Linux system, the file [11Xsysinfo.gap[111X may look like this:[133X818819[4X[32X Example [32X[104X820[4X[28XGAParch=i586-unknown-linux2.0.31-gcc[128X[104X821[4X[32X[104X822823[33X[0;0YWe suggest that your [5XGAP[105X package contains a file [11Xconfigure[111X which is called824with the path of the [5XGAP[105X root directory as parameter. This file then will825read [11Xsysinfo.gap[111X and set up everything for compiling under the given826architecture (for example creating a [11XMakefile[111X from [11XMakefile.in[111X). As initial827templates, you may use installation scripts of the [5XExample[105X package.[133X828829830[1XA.10-2 [33X[0;0YTest for the Existence of GAP Package Binaries[133X[101X831832[33X[0;0YIf an external binary is essential for the workings of a [5XGAP[105X package, the833function stored in the component [10XAvailabilityTest[110X of the [11XPackageInfo.g[111X file834of the package should test whether the program has been compiled on the835architecture (and inhibit package loading if this is not the case). This is836especially important if the package is loaded automatically.[133X837838[33X[0;0YThe easiest way to accomplish this is to use [2XFilename[102X ([14XReference: Filename839(for a directory and a string)[114X) for checking for the actual binaries in the840path given by [2XDirectoriesPackagePrograms[102X ([14XReference:841DirectoriesPackagePrograms[114X) for the respective package. For example the842[5Xexample[105X [5XGAP[105X package could use the following function to test whether the843binary [11Xhello[111X has been compiled; it will issue a warning if not, and will844only load the package if the binary is indeed available:[133X845846[4X[32X Example [32X[104X847[4X[28X...[128X[104X848[4X[28XAvailabilityTest := function()[128X[104X849[4X[28X local path,file;[128X[104X850[4X[28X # test for existence of the compiled binary[128X[104X851[4X[28X path:= DirectoriesPackagePrograms( "example" );[128X[104X852[4X[28X file:= Filename( path, "hello" );[128X[104X853[4X[28X if file = fail then[128X[104X854[4X[28X LogPackageLoadingMessage( PACKAGE_WARNING,[128X[104X855[4X[28X [ "The program `hello' is not compiled,",[128X[104X856[4X[28X "`HelloWorld()' is thus unavailable.",[128X[104X857[4X[28X "See the installation instructions;",[128X[104X858[4X[28X "type: ?Installing the Example package" ] );[128X[104X859[4X[28X fi;[128X[104X860[4X[28X return file <> fail;[128X[104X861[4X[28X end,[128X[104X862[4X[28X...[128X[104X863[4X[32X[104X864865[33X[0;0YHowever, if you look at the actual [11XPackageInfo.g[111X file of the [5Xexample[105X866package, you will see that its [10XAvailabilityTest[110X function always returns867[9Xtrue[109X, and just logs the warning if the binary is not available (which may be868later viewed with [2XDisplayPackageLoadingLog[102X ([14XReference:869DisplayPackageLoadingLog[114X)). This means that the binary is not regarded as870essential for this package.[133X871872[33X[0;0YYou might also have to cope with the situation that external binaries will873only run under UNIX (and not, say, under Windows), or may not compile with874some compilers or default compiler options. See [14X'Reference: Testing for the875System Architecture'[114X for information on how to test for the architecture.[133X876877[33X[0;0YLast but not least: do not print anything in the [10XAvailabilityTest[110X function878of the package via [10XPrint[110X or [10XInfo[110X. Instead one should call879[2XLogPackageLoadingMessage[102X ([14XReference: LogPackageLoadingMessage[114X) to store a880message which may be viewed later with [2XDisplayPackageLoadingLog[102X ([14XReference:881DisplayPackageLoadingLog[114X) (the latter two functions are introduced in882[5XGAP[105X 4.5)[133X883884885[1XA.10-3 [33X[0;0YCalling of and Communication with External Binaries[133X[101X886887[33X[0;0YThere are two reasons for this: the input data has to be passed on to the888stand-alone program and the stand-alone program has to be started from889within [5XGAP[105X.[133X890891[33X[0;0YThere are two principal ways of doing this.[133X892893[33X[0;0YThe first possibility is to write all the data for the stand-alone to one or894several files, then start the stand-alone with [2XProcess[102X ([14XReference: Process[114X)895or [2XExec[102X ([14XReference: Exec[114X) which then writes the output data to file, and896finally read in the standalone's output file.[133X897898[33X[0;0YThe second way is interfacing via input-output streams, see899Section [14X'Reference: Input-Output Streams'[114X.[133X900901[33X[0;0YSome [5XGAP[105X packages use kernel modules (see [14X'Reference: Kernel modules in GAP902packages'[114X) instead of external binaries. A kernel module is implemented in C903and follows certain conventions to comply with the [5XGAP[105X kernel interface,904which we plan to document later. In the meantime, we advise you to look at905existing examples of such packages and get in touch with [5XGAP[105X developers if906you plan to develop such a package.[133X907908909[1XA.11 [33X[0;0YHaving an InfoClass[133X[101X910911[33X[0;0YIt is a good idea to declare an [10XInfoClass[110X for your package. This gives the912package user the opportunity to control the verbosity of output and/or the913possibility of receiving debugging information (see [14X'Reference: Info914Functions'[114X). Below, we give a quick overview of its utility.[133X915916[33X[0;0YAn [10XInfoClass[110X is defined with a [10XDeclareInfoClass( [3XInfoPkgname[103X[10X );[110X statement917and may be set to have an initial [10XInfoLevel[110X other than the zero default918(which means no [10XInfo[110X statement is to output information) via a [10XSetInfoLevel(919[3XInfoPkgname[103X[10X, [3Xlevel[103X[10X );[110X statement. An initial [10XInfoLevel[110X of 1 is typical.[133X920921[33X[0;0Y[10XInfo[110X statements have the form: [10XInfo( [3XInfoPkgname[103X[10X, [3Xlevel[103X[10X, [3Xexpr1[103X[10X, [3Xexpr2[103X[10X, ...);[110X922where the expression list [10X[3Xexpr1[103X[10X, [3Xexpr2[103X[10X, ...[110X appears just like it would in a923[10XPrint[110X statement. The only difference is that the expression list is only924printed (or even executed) if the [10XInfoLevel[110X of [3XInfoPkgname[103X is at least925[3Xlevel[103X.[133X926927928[1XA.12 [33X[0;0YThe Banner[133X[101X929930[33X[0;0YSince [5XGAP[105X 4.4, the package banner, if one is desired, should be provided by931assigning a string to the [10XBannerString[110X field of the record argument of932[10XSetPackageInfo[110X in the [11XPackageInfo.g[111X file.[133X933934[33X[0;0YIt is a good idea to have a hook into your package documentation from your935banner. The banner of the [5XExample[105X package suggests to the [5XGAP[105X user:[133X936937[4X[32X Example [32X[104X938[4X[28XFor help, type: ?Example package[128X[104X939[4X[32X[104X940941[33X[0;0YIn order for this to display the introduction of the [5XExample[105X package the942index-entry [10X<Index>Example package</Index>[110X was added just before the first943paragraph of the introductory section in the file [11Xexample.xml[111X. The [5XExample[105X944package uses [5XGAPDoc[105X (see Section [14XA.2[114X) for documentation (you will need some945different scheme to achieve this using the [11Xgapmacro.tex[111X system).[133X946947948[1XA.13 [33X[0;0YVersion Numbers[133X[101X949950[33X[0;0YVersion numbers are strings containing nonnegative integers separated by951non-numeric characters. They are compared by [2XCompareVersionNumbers[102X952([14XReference: CompareVersionNumbers[114X) which first splits them at non-digit953characters and then lexicographically compares the resulting integer lists.954Thus version [10X"2-3"[110X is larger than version [10X"2-2-5"[110X but smaller than [10X"4r2p3"[110X955or [10X"11.0"[110X.[133X956957[33X[0;0YIt is possible for code to require [5XGAP[105X packages in certain versions. In this958case, all versions, whose number is equal or larger than the requested959number are acceptable. It is the task of the package author to provide960upwards compatibility.[133X961962[33X[0;0YLoading a specific version of a package (that is, [13Xnot[113X one with a larger963version number) can be achieved by prepending [10X=[110X to the desired version964number. For example, [10XLoadPackage( "example", "=1.0" )[110X will load version965[10X"1.0"[110X of the package [10X"example"[110X, even if version [10X"1.1"[110X is available. As a966consequence, version numbers must not start with [10X=[110X, so [10X"=1.0"[110X is not a valid967version number.[133X968969[33X[0;0YPackage authors should choose a version numbering scheme that admits a new970version number even after tiny changes to the package, and ensure that971version numbers of successive package versions increase. The automatic972update of package archives in the [5XGAP[105X distribution will only work if a973package has a new version number.[133X974975[33X[0;0YIt is a well-established custom to name package archives like976[11Xname-version.tar.gz[111X, [11Xname-version.tar.bz2[111X etc., where [10Xname[110X is the lower case977name, and [10Xversion[110X is the version (another custom is that the archive then978should extract to a directory that has exactly the name [11Xname-version[111X).[133X979980[33X[0;0YIt is very important that there should not ever be, for a given [5XGAP[105X package,981two different archives with the same package version number. If you make982changes to your package and place a new archive of the package onto the983public server, please ensure that a new archive has a new version number.984This should be done even for very minor changes.[133X985986[33X[0;0YFor most of the packages it will be inappropriate to re-use the date of the987release as a version number. It's much more obvious how big are the changes988between versions "4.4.12", "4.5.1" and "4.5.2" than between versions989"2008.12.17", "2011.04.15" and "2011.09.14".[133X990991[33X[0;0YSince version information is duplicated in several places throughout the992package documentation, for [5XGAPDoc[105X-based manuals you may define the version993and the release manual in the comments in [11XPackageInfo.g[111X file close to the994place where you specified its [10XVersion[110X and [10XDate[110X components, for example[133X995996[4X[32X Example [32X[104X997[4X[28X## <#GAPDoc Label="PKGVERSIONDATA">[128X[104X998[4X[28X## <!ENTITY VERSION "3.3">[128X[104X999[4X[28X## <!ENTITY RELEASEDATE "11/11/2011">[128X[104X1000[4X[28X## <#/GAPDoc>[128X[104X1001[4X[32X[104X10021003[33X[0;0Ynotify [2XMakeGAPDocDoc[102X ([14XGAPDoc: MakeGAPDocDoc[114X) that a part of the document is1004stored in [11XPackageInfo.g[111X (see [11Xexample/makedocrel.g[111X), read this data into the1005header of the main document via [10X<#Include Label="PKGVERSIONDATA">[110X directive1006and then use them via &VERSION; and &RELEASEDATE; entities almost everywhere1007where you need to refer to them (most commonly, in the title page and1008installation instructions).[133X100910101011[1XA.14 [33X[0;0YTesting a [5XGAP[105X[101X[1X package[133X[101X101210131014[1XA.14-1 [33X[0;0YTests files for a GAP package[133X[101X10151016[33X[0;0YThe (optional) [11Xtst[111X directory of your package may contain as many tests of1017the package functionality as appears appropriate. These tests should be1018organised into test files similarly to those in the [11Xtst[111X directory of the [5XGAP[105X1019distribution as documented in [14X'Reference: Test Files'[114X.[133X10201021[33X[0;0YFor a deposited package, a test file with a basic test of the package (for1022example, to check that it works as expected and/or that the manual examples1023are correct) may be specified in the component [10XTestFile[110X in the [11XPackageInfo.g[111X1024to be included in the GAP standard test suite. This file can either consist1025of [2XTest[102X ([14XReference: Test[114X) calls (in this case, it is common to call it1026[11Xtestall.g[111X) or be itself a test file having an extension [11X.tst[111X and supposed to1027be read via [2XTest[102X ([14XReference: Test[114X). It is assumed that the latter case1028occurs if and only if the file contains the substring[133X10291030[33X[0;0Y [10X"gap> START_TEST("[110X[133X10311032[33X[0;0Y(with exactly one space after the [5XGAP[105X prompt).[133X10331034[33X[0;0YFor deposited packages, these tests are run by the [5XGAP[105X Group regularly, as a1035part of the standard [5XGAP[105X test suite. For the efficient testing it is1036important that the test specified in the [11XPackageInfo.g[111X file does not display1037any output (e.g. no test progress indicators) except reporting discrepancies1038if such occur and the completion report as in the example below:[133X10391040[4X[32X Example [32X[104X1041[4X[25Xgap>[125X [27XTest("tst/testall.tst");[127X[104X1042[4X[28XExample package: testall.tst[128X[104X1043[4X[28XGAP4stones: 3333[128X[104X1044[4X[28Xtrue[128X[104X1045[4X[32X[104X10461047[33X[0;0YTests which produce extended output and/or requires substantial runtime are1048not supposed to be a part of the [5XGAP[105X standard test suite but may be placed1049in the [11Xtst[111X directory of the packages with further instructions on how to run1050them elsewhere.[133X105110521053[1XA.14-2 [33X[0;0YTesting [5XGAP[105X[101X[1X package loading[133X[101X10541055[33X[0;0YTo test that your package may be loaded into [5XGAP[105X without any problems and1056conflicts with other packages, test that it may be loaded in various1057configurations:[133X10581059[30X [33X[0;6Ystarting [5XGAP[105X with no packages (except needed for [5XGAP[105X) using [10X-r -A[110X1060options and calling [10XLoadPackage("your-package-name");[110X[133X10611062[30X [33X[0;6Ystarting [5XGAP[105X with no packages (except needed for [5XGAP[105X) using [10X-r -A[110X1063options and calling [10XLoadPackage("your-package-name" : OnlyNeeded );[110X[133X10641065[30X [33X[0;6Ystarting [5XGAP[105X in the default configuration (with no options) and1066calling [10XLoadPackage("your-package-name");[110X[133X10671068[30X [33X[0;6Ystarting [5XGAP[105X in the default configuration (with no options) and1069calling [10XLoadPackage("your-package-name" : OnlyNeeded );[110X[133X10701071[30X [33X[0;6Yfinally, together with all other packages using [2XLoadAllPackages[102X1072([14XA.14-3[114X) (see below) in four possible combinations of starting [5XGAP[105X1073with/without [10X-r -A[110X options and calling [2XLoadAllPackages[102X ([14XA.14-3[114X)1074with/without [10XReversed[110X option.[133X10751076[33X[0;0YThe test of loading all packages is the most subtle one. Quite often it1077reveals problems which do not occur in the default configuration but may1078cause difficulties to the users of specialised packages.[133X10791080[33X[0;0YFor your convenience, [10Xmake testpackagesload[110X called in the [5XGAP[105X root directory1081will run all package loading tests listed in this subsection and write their1082output in its [10Xdev/log[110X directory.[133X10831084[33X[0;0YIt will produce four files with test logs, corresponding to the four cases1085above (the letter [10XN[110X in the filename stands for [21Xneeded[121X, [10XA[110X stands for1086[21Xautoloaded[121X):[133X10871088[30X [33X[0;6Y[11Xdev/log/testpackagesload1_...[111X[133X10891090[30X [33X[0;6Y[11Xdev/log/testpackagesloadN1_...[111X[133X10911092[30X [33X[0;6Y[11Xdev/log/testpackagesloadA_...[111X[133X10931094[30X [33X[0;6Y[11Xdev/log/testpackagesloadNA_...[111X[133X10951096[33X[0;0YEach file contains small sections for loading individual packages: among1097those, you need to find the section related to your package and may ignore1098all other sections. For example, the section for the [5XExample[105X package looks1099like[133X11001101[4X[32X Example [32X[104X1102[4X[28X%%% Loading example 3.3.3[128X[104X1103[4X[28X[ ][128X[104X1104[4X[28X### Loaded example 3.3.3[128X[104X1105[4X[32X[104X11061107[33X[0;0Yso it has clearly passed the test. If there are any error messages displayed1108between [10XLoading ...[110X and [10XLoaded ...[110X lines, they will signal on errors during1109loading of your package.[133X11101111[33X[0;0YAdditionally, this test collects information about variables created since1112the library was read (obtained using [2XNamesUserGVars[102X ([14XReference:1113NamesUserGVars[114X)) with either short names (no more than three characters) or1114names breaking a recommended naming convention that the [5XGAP[105X core system and1115[5XGAP[105X packages should not use global variables starting in the lowercase (see1116Section [14XA.6[114X). Their list will be displayed in the test log (in the example1117above, [5XExample[105X packages does not create any such variables, so an empty list1118is displayed). It may be hard to attribute a particular identifier to a1119package, since it may be created by another package loaded because of1120dependencies, so when a more detailed and precise report on package1121variables is needed, it may be obtained using [2XShowPackageVariables[102X1122([14XReference: ShowPackageVariables[114X) (also, [10Xmake testpackagesvars[110X called in the1123[5XGAP[105X root directory produces such reports for each package and writes them to1124a file [11Xdev/log/testpackagesvars_...[111X).[133X11251126[33X[0;0YFinally, each log file finishes with two large sections for loading all1127packages in the alphabetical and reverse aplhabetical order (to check more1128combinations of loading one package after another). We are aiming at1129releasing only collections of package which do not break [2XLoadAllPackages[102X1130([14XA.14-3[114X) in any of the four configurations, so if it is broken when you plug1131in the development version of your package into the released version of [5XGAP[105X,1132it is likely that your package triggers this error. If you observe that1133[2XLoadAllPackages[102X ([14XA.14-3[114X) is broken and suspect that this is not the fault of1134your package, please contact the [5XGAP[105X Support.[133X11351136[1XA.14-3 LoadAllPackages[101X11371138[29X[2XLoadAllPackages[102X( [3X:[103X [3XReversed[103X ) [32X function11391140[33X[0;0Yloads all [5XGAP[105X packages from their list sorted in alphabetical order (needed1141and suggested packages will be loaded when required). This is a technical1142function to check packages compatibility, so it should NOT be used to run1143anything except tests; it is known that [5XGAP[105X performance is slower if all1144packages are loaded. To introduce some variations of the order in which1145packages will be loaded for testing purposes, [2XLoadAllPackages[102X accepts1146version [10XReversed[110X to load packages from their list sorted in the reverse1147alphabetical order.[133X114811491150[1XA.14-4 [33X[0;0YTesting a [5XGAP[105X[101X[1X package with the [5XGAP[105X[101X[1X standard test suite[133X[101X11511152[33X[0;0YThe [11Xtst[111X directory of the [5XGAP[105X installation contains a selection of test files1153and two scripts, [11Xtestinstall.g[111X and [11Xtestall.g[111X which are a part of the [5XGAP[105X1154standard test suite.[133X11551156[33X[0;0YIt is important to check that your package does not break [5XGAP[105X standard1157tests. To perform a clean test and avoid interfering with other packages,1158first you must start a new [5XGAP[105X session with the following command (assuming1159that [10Xgap[110X starts [5XGAP[105X in your system):[133X11601161[4X[32X Example [32X[104X1162[4X[28Xgap -N -A -x 80 -r -m 100m -o 512m[128X[104X1163[4X[32X[104X11641165[33X[0;0YAfter that load your package and run either [11Xtestinstall.g[111X or [11Xtestall.g[111X as1166demonstrated below.[133X11671168[33X[0;0YThe quicker test, [11Xtestinstall.g[111X, requires about 512MB of memory and runs for1169about one minute on an Intel Core 2 Duo / 2.53 GHz machine. It may be1170started with the command[133X11711172[4X[32X Example [32X[104X1173[4X[25Xgap>[125X [27XRead( Filename( DirectoriesLibrary( "tst" ), "testinstall.g" ) );[127X[104X1174[4X[32X[104X11751176[33X[0;0YYou will get a large number of lines with output about the progress of the1177tests.[133X11781179[4X[32X Example [32X[104X1180[4X[28Xtest file GAP4stones time(msec)[128X[104X1181[4X[28X-------------------------------------------[128X[104X1182[4X[28Xtesting: .../gap4r5/tst/zlattice.tst[128X[104X1183[4X[28Xzlattice.tst 0 0[128X[104X1184[4X[28Xtesting: .../gap4r5/tst/gaussian.tst[128X[104X1185[4X[28Xgaussian.tst 0 10[128X[104X1186[4X[28X... further lines deleted ...[128X[104X1187[4X[32X[104X11881189[33X[0;0YThe more thorough test is [11Xtestall.g[111X which exercises more of [5XGAP[105X's1190capabilities, containing all test files from [11Xtestinstall.g[111X as a subset. It1191requires about 512MB of memory, runs for about one hour on an Intel Core 21192Duo / 2.53 GHz machine, and produces an output similar to the testinstall.g1193test. To run it, also start a new [5XGAP[105X session with [10Xgap -N -A -x 80 -r -m1194100m -o 512m[110X and then call[133X11951196[4X[32X Example [32X[104X1197[4X[25Xgap>[125X [27XRead( Filename( DirectoriesLibrary( "tst" ), "testall.g" ) );[127X[104X1198[4X[32X[104X11991200[33X[0;0YYou may repeat the same check loading your package with [10XOnlyNeeded[110X option.1201Remember to perform each subsequent test in a new [5XGAP[105X session.[133X12021203[33X[0;0YAlso you may perform individual tests from the [11Xtst[111X directory of the [5XGAP[105X1204installation loading them with [2XTest[102X ([14XReference: Test[114X), for example, the file1205[11Xbugfix.tst[111X.[133X120612071208[1XA.15 [33X[0;0YAccess to the [5XGAP[105X[101X[1X Development Version[133X[101X12091210[33X[0;0YWe are aiming at providing a stable platform for package development and1211testing with official [5XGAP[105X releases. However, when it may be of benefit to1212obtain access to the [5XGAP[105X development version, please contact the [5XGAP[105X team by1213mailing to [7Xmailto:[email protected][107X.[133X121412151216[1XA.16 [33X[0;0YSelecting a license for a [5XGAP[105X[101X[1X Package[133X[101X12171218[33X[0;0YIt is advised to make clear in the documentation of the package the basis on1219which it is being distributed to users. GAP itself is distributed under the1220GNU Public License version 2 (version 2 or later). We would encourage you to1221consider the GPL for your packages, but you might wish to be more1222restrictive (for instance forbidding redistribution for profit) or less1223restrictive (allowing your software to be incorporated into commercial1224software). See [21XChoosing a License for the Distribution of Your Package[121X from1225[7Xhttp://www.gap-system.org/Packages/Authors/authors.html[107X for further details.[133X12261227[33X[0;0YIn the past many [5XGAP[105X packages used the text [21XWe adopt the copyright1228regulations of GAP as detailed in the copyright notice in the [5XGAP[105X manual[121X or1229a similar statement. We now advise to be more explicit and make the exact1230reference to the GPL license, for example:[133X12311232[33X[0;0Y[13X [5Xpackage-name[105X is free software; you can redistribute it and/or modify it1233under the terms of the GNU General Public License1234([7Xhttp://www.fsf.org/licenses/gpl.html[107X) as published by the Free Software1235Foundation; either version 2 of the License, or (at your option) any later1236version. [113X[133X123712381239[1XA.17 [33X[0;0YWrapping up a [5XGAP[105X[101X[1X Package[133X[101X12401241[33X[0;0YCurrently, the [5XGAP[105X distribution provides archives in four different formats.[133X12421243[8X[11X.tar.gz[111X[108X1244[33X[0;6Ya standard UNIX [10Xtar[110X archive, compressed with [10Xgzip[110X[133X12451246[8X[11X.tar.bz2[111X[108X1247[33X[0;6Ya standard UNIX [10Xtar[110X archive, compressed with [10Xbzip2[110X[133X12481249[8X[11X.zip[111X[108X1250[33X[0;6Yan archive in [10Xzip[110X format, where text files should have UNIX style line1251breaks[133X12521253[8X[11X-win.zip[111X[108X1254[33X[0;6Yan archive in [10Xzip[110X format, where text files should have DOS/Windows1255style line breaks[133X12561257[33X[0;0YFor convenience of possible users it is sensible that you provide an archive1258of your package in at least one of these formats.[133X12591260[33X[0;0YFor example, if you wish to supply a [11X.tar.gz[111X archive, you may create it with1261the command[133X12621263[33X[0;0Y [10Xtar -cvzf package-name-version.tar.gz package-name[110X[133X12641265[33X[0;0YThe [11Xetc[111X directory obtained from [10Xtools.tar.gz[110X (described above in1266Section [14XA.2[114X) contains a file [11Xpackpack[111X which provides a more versatile1267packing-up script.[133X12681269[33X[0;0YBecause the release of the [5XGAP[105X package is independent of the version of [5XGAP[105X,1270a [5XGAP[105X package should be wrapped up in separate file that can be installed1271onto any version of [5XGAP[105X. In this way, a package can be upgraded any time1272without the need to wait for new [5XGAP[105X releases. To ensure this, the package1273should be archived from the [5XGAP[105X [11Xpkg[111X directory, that is all files are1274archived with the path starting at the package's name.[133X12751276[33X[0;0YThe archive of a [5XGAP[105X package should contain all files necessary for the1277package to work. In particular there should be a compiled documentation,1278which includes the [11Xmanual.six[111X, [11Xmanual.toc[111X and [11Xmanual.lab[111X file in the1279documentation subdirectory which are created by TeXing the documentation, if1280you use [5XGAPDoc[105X or the [11Xgapmacro.tex[111X document formats. (The first two files1281are needed by the [5XGAP[105X help system, and the [11Xmanual.lab[111X file is needed if the1282main manuals or another package is referring to your package. Use the1283command [10XGAPDocManualLab( packagename );[110X to create this file for your help1284books if you use [5XGAPDoc[105X.)[133X12851286[33X[0;0YFor packages which are redistributed via the [5XGAP[105X Web site, we offer an1287automatic conversion of any of the formats listed above to all the others1288(note that this, as well as wrapping the [5XGAP[105X distribution as a single1289archive containing the core system and all currently redistributed packages,1290will change file timestamps, so one should not rely on them anywhere in the1291package).[133X12921293[33X[0;0YTo use the conversion and repackaging service, you can provide any of the1294four archive formats or even more than one, however you should adhere to the1295following rule: text files in [11X.tar.gz[111X and [11X.tar.bz2[111X archives must have UNIX1296style line breaks, while text files in [11X-win.zip[111X archives must have1297DOS/Windows line breaks.[133X12981299[33X[0;0YThe package wrapping tools for the [5XGAP[105X distribution and web pages then will1300use a sensible list of file extensions to decide if a file is a text file1301(being conservative, it may miss a few text files). These rules may be1302prepended by the application of rules from the [11XPackageInfo.g[111X file:[133X13031304[30X [33X[0;6Yif it has a [10X.TextFiles[110X component, then consider the given files as1305text files before [5XGAP[105X defaults will be applied;[133X13061307[30X [33X[0;6Yif it has a [10X.BinaryFiles[110X component, then consider given files as1308binary files before [5XGAP[105X defaults will be applied;[133X13091310[30X [33X[0;6Yif it has a [10X.TextBinaryFilesPatterns[110X component, then apply it before1311[5XGAP[105X defaults will be applied;[133X13121313[33X[0;0YThe [11Xetc[111X directory obtained from [10Xtools.tar.gz[110X (described above in1314Section [14XA.2[114X) contains a file [11Xclassifyfiles.py[111X and two files1315[11Xpatternscolor.txt[111X and [11Xpatternstextbinary.txt[111X implementing [5XGAP[105X default rules1316used to classify files in packages. For most of the packages these default1317rules perfecty detect binary and text files, so there is no need for them to1318use any of the three optional components. However, [10X.TextBinaryFilesPatterns[110X,1319or [10X.TextFiles[110X, or [10X.BinaryFiles[110X will become useful if the package has e.g.1320data files which are recognised as binary files by the default rules, or if1321the package uses standard extensions in a non-standard way (this is not1322recommended, of course). If things will go wrong, it is possible that one1323(or indeed all) created archives have wrong line breaks.[133X13241325[33X[0;0YUtility functions available in [11Xgap4r7/lib/lbutil.g[111X, namely1326[10XDosUnixLinebreaks[110X, [10XUnixDosLinebreaks[110X, [10XMacUnixLinebreaks[110X may be helpful. They1327are described in the comments to their source code.[133X132813291330[1XA.18 [33X[0;0YThe WWW Homepage of a Package[133X[101X13311332[33X[0;0YIf you want to distribute your package you should create a WWW homepage1333containing some basic information, archives for download, the [11XREADME[111X file1334with installation instructions, and a copy of the package's [11XPackageInfo.g[111X1335file.[133X13361337[33X[0;0YThe responsibility for this WWW homepage is with the package1338authors/maintainers.[133X13391340[33X[0;0YIf you tell us about your package (say, by mail to1341[7Xmailto:[email protected][107X) we may consider either[133X13421343[30X [33X[0;6Yadding a link to your package homepage from the [5XGAP[105X website (thus, the1344package will be an [13Xundeposited contribution[113X);[133X13451346[30X [33X[0;6Yor redistributing the current version of your package as a part of the1347[5XGAP[105X distribution (this, the package will be [13Xdeposited[113X), also ;[133X13481349[33X[0;0YIn the latter case we can also provide some services for producing several1350archive formats from the archive you provide (e.g., you produce a [10X.tar.gz[110X1351version of your archive and we produce also a [10X.tar.bz2[110X and a [10X-win.zip[110X1352version from it).[133X13531354[33X[0;0YPlease also consider submitting your package to the [5XGAP[105X package refereeing1355process (see [7Xhttp://www.gap-system.org/Contacts/submit.html[107X for further1356information).[133X135713581359[1XA.19 [33X[0;0YUpgrading the package to work with [5XGAP[105X[101X[1X 4.5[133X[101X136013611362[1XA.19-1 [33X[0;0YChanges in [5XGAP[105X[101X[1X 4.5 from the packages perspective[133X[101X13631364[33X[0;0YHere we list only those changes which may have some implications for the1365packages.[133X13661367[30X [33X[0;6YChanging the distribution format providing one archive with the core1368system and all currently redistributed packages.[133X13691370[30X [33X[0;6YThe [5XGAP[105X kernel is now compiled by default to use the GMP large integer1371arithmetic library, speeding up arithmetic by a factor of 4 or more in1372many cases. This slightly changes the build process, affecting mainly1373packages with dynamically loaded modules (see1374[7Xhttp://www.gap-system.org/Download/[107X for [5XGAP[105X installation1375instructions).[133X13761377[30X [33X[0;6YThe [5XGAP[105X documentation has been converted to the [5XGAPDoc[105X format and1378extensively reviewed. Now it has only two books: the Tutorial and the1379Reference Manual. The two other books, [21XExtending [5XGAP[105X[121X and [21XProgramming1380Tutorial[121X became parts of the Reference Manual. Packages that refer to1381parts of the [5XGAP[105X documentation may need to rebuild their manuals to1382update references.[133X13831384[33X[0;6YSome packages still use the old [21Xgapmacro[121X format for their manuals, for1385which support may be discontinued in the future. There is no urgent1386need to convert such manuals into the [5XGAPDoc[105X format before [5XGAP[105X 4.51387release, but we encourage you very much to consider doing this at some1388later point.[133X13891390[30X [33X[0;6YThe old concept of an autoloaded package has been integrated with the1391[13Xneeded[113X and [13Xsuggested[113X mechanism that already exists between packages.1392[5XGAP[105X itself now [21Xneeds[121X certain packages (for instance [5XGAPDoc[105X) and1393[21Xsuggests[121X others (typically the packages that were autoloaded). The1394decisions which packages [5XGAP[105X should need or suggest are made by1395developers based on technical criteria. They can be easily overridden1396by a user using the new [11Xgap.ini[111X (see [14X'Reference: The gap.ini and gaprc1397files'[114X). The default file ensures that all previously autoloaded1398packages are still loaded if present.[133X13991400[30X [33X[0;6YOptional [11X~/.gap[111X directory for user's customisations which may contain1401e.g. locally installed packages (see [14X'Reference: GAP Root1402Directories'[114X). If package installation instructions explain how to1403install the package in a non-standard location, they may need an1404update. This is intended to replace [11X.gaprc[111X files, but those are still1405supported for backwards compatibility (see [14X'Reference: The former1406.gaprc file'[114X).[133X14071408[30X [33X[0;6YVarious improvements in the packages loading mechanism make it more1409informative, while avoiding confusing the user with warning and error1410messages for packages they didn't know they were loading. For example,1411many messages are stored but not displayed using the function1412[2XLogPackageLoadingMessage[102X ([14XReference: LogPackageLoadingMessage[114X) and1413there is a function [2XDisplayPackageLoadingLog[102X ([14XReference:1414DisplayPackageLoadingLog[114X) to show log messages that occur during1415package loading. Packages are encouraged to use these mechanisms to1416report problems in loading (e.g. binaries not compiled), rather than1417printing messages directly.[133X14181419[30X [33X[0;6YSince [5XGAP[105X 4.5 a package may place global variables into a local1420namespace as explained in [14X'Reference: Namespaces for GAP packages'[114X in1421order to avoid name clashes and preserve compatibility.[133X14221423[30X [33X[0;6YIn [5XGAP[105X 4.5 the internal representation of a record has changed, as1424well as some of the basic functions to manipulate records. This speeds1425up considerably the creation of and access to records with many1426components. Record components are now internally stored in the order1427in which they were used first, and this means that the internal1428ordering of components (returned by [2XRecNames[102X ([14XReference: RecNames[114X) and1429so the ordering of records, depends on the GAP session. Therefore,1430within each session everything is consistent, so one can efficiently1431remove duplicates with [2XSet[102X ([14XReference: Set[114X), sort lists of records,1432find records with binary search, etc., but a care should be taken not1433to rely on [2XRecNames[102X ([14XReference: RecNames[114X) always returning names of1434components in the same order.[133X143514361437[1XA.20 [33X[0;0YChecklists[133X[101X143814391440[1XA.20-1 [33X[0;0YPackage release checklist[133X[101X14411442[33X[0;0YThe following checklist may be used by package authors, members of the [5XGAP[105X1443team responsible for package updates, package editors and referees.[133X14441445[30X [33X[0;6YTest that the package:[133X14461447[30X [33X[0;12Ydoes not break [11Xtestinstall.g[111X and [11Xtestall.g[111X and does not slow1448them down noticeably (see [14XA.14-4[114X);[133X14491450[30X [33X[0;12Ymay be loaded in various configurations (see [14XA.14-2[114X);[133X14511452[30X [33X[0;12Yfollows the guidelines of Section [14XA.6[114X about names of functions1453and variables;[133X14541455[30X [33X[0;6YPackage documentation:[133X14561457[30X [33X[0;12Yis built and included in the package archive together with its1458source files;[133X14591460[30X [33X[0;12Ystates the version, release date and package authors;[133X14611462[30X [33X[0;12Yhas the same version, release date and package authors details1463as stated in the [11XPackageInfo.g[111X file;[133X14641465[30X [33X[0;12Yis searchable using the [5XGAP[105X help system;[133X14661467[30X [33X[0;12Yis clear about the license under which the package is1468distributed;[133X14691470[30X [33X[0;6Y[11XPackageInfo.g[111X file:[133X14711472[30X [33X[0;12Yhas the same version, release date and package authors details1473as stated in the package manual;[133X14741475[30X [33X[0;12Yhas all mandatory components and also optional components where1476appropriate;[133X14771478[30X [33X[0;12Yin particular, contains hints to distinguish binary and text1479files in case of non-standard file names and extensions;[133X14801481[30X [33X[0;12Yis validated using [2XValidatePackageInfo[102X ([14XReference:1482ValidatePackageInfo[114X);[133X14831484[30X [33X[0;6YPackage archive(s):[133X14851486[30X [33X[0;12Yhave correct permisisons for all files and directories after1487their unpacking (755 for directories and executables, if any;1488644 for other files);[133X14891490[30X [33X[0;12Ycontain files with correct line breaks for the given format (see1491[14XA.17[114X);[133X14921493[30X [33X[0;12Ycontain no hidden system files and directories that are not1494supposed to be included in the package, e.g. [11X.cvsignore[111X, [11X.git[111X1495etc.;[133X14961497[30X [33X[0;6YPackage availability:[133X14981499[30X [33X[0;12Ynot only the package archive(s), but also the [11XPackageInfo.g[111X and1500[11XREADME[111X files are available online;[133X15011502[30X [33X[0;12Ythe URL of the [11XPackageInfo.g[111X file is validated using the online1503tool available from1504[7Xhttp://www.gap-system.org/Packages/Authors/authors.html[107X;[133X150515061507[1XA.20-2 [33X[0;0YChecklist for package upgrade to work with [5XGAP[105X[101X[1X 4.5[133X[101X15081509[33X[0;0YThe following checklist will help you to check how well your package is1510ready to work with [5XGAP[105X 4.5.[133X15111512[30X [33X[0;6YMandatory changes needed for package upgrade to work with [5XGAP[105X 4.5:[133X15131514[8X1515Check that the package works as expected:1516[108X1517[30X [33X[0;18Yverify that the package functionality works as required,1518that examples in the manual are correct and that test1519files show no discrepancies;[133X15201521[30X [33X[0;18Yif necessary, update manual examples and test files1522because the order in which record components are printed1523has changed (but now it will be more consistent and less1524dependent on how the record was created);[133X15251526[30X [33X[0;18Ycheck the usage of names of record components in the code:1527take care not to rely on [2XRecNames[102X ([14XReference: RecNames[114X)1528always returning names of components in the same order1529(see [14XA.19[114X)[133X15301531[8X1532Revise package dependencies:1533[108X1534[33X[0;12YCheck the the [11XPackageInfo.g[111X has the correct list of needed and1535suggested packages (see [14XA.7[114X).[133X15361537[8X1538Revise licensing information:1539[108X1540[33X[0;12YCheck that the package states clearly under which conditions it1541is distributed (see [14XA.16[114X).[133X15421543[8X1544Rebuild the package documentation:1545[108X1546[33X[0;12Ywhenever your package documentation is [5XGAPDoc[105X or1547[10Xgapmacro.tex[110X-based, [5XGAP[105X 4.5 contains new versions of both tools.1548This will ensure that cross-references from the package manual1549to the main [5XGAP[105X manuals are correct and that the [5XGAP[105X help system1550will be able to navigate to the more precise location in the1551package manual. This will also improve the layout of the package1552documentation. In particular, [5XGAPDoc[105X has a better [11X.css[111X file and1553is capable of producing the HTML version with MathJax support to1554display nicely mathematical formulae.[133X15551556[33X[0;12YNote that it's not possible for a package to have an HTML manual1557which contains correct links to both [5XGAP[105X 4.4 and [5XGAP[105X 4.5 main1558manuals.[133X15591560[30X [33X[0;6YOptional changes recommended for package upgrade to work with [5XGAP[105X 4.5:[133X15611562[30X [33X[0;12YWhen the [10XAvailabilityTest[110X component in [11XPackageInfo.g[111X differs1563from [2XReturnTrue[102X ([14XReference: ReturnTrue[114X), use1564[2XLogPackageLoadingMessage[102X ([14XReference: LogPackageLoadingMessage[114X)1565to store a message which may be viewed later with1566[2XDisplayPackageLoadingLog[102X ([14XReference: DisplayPackageLoadingLog[114X)1567instead of calling [10XPrint[110X or [10XInfo[110X directly (see [14XA.10-2[114X).[133X15681569[30X [33X[0;12YIt is recommended not to call [2XLoadPackage[102X ([14XReference:1570LoadPackage[114X) from a package file while this file is read:1571instead one should list the package in question in the lists of1572needed or suggested packages. To verify whether such calls occur1573in the package first load it and then call1574[10XDisplayPackageLoadingLog( PACKAGE_WARNING );[110X. If there is a1575genuine need to decide whether some package will be available at1576runtime, use the function [2XIsPackageMarkedForLoading[102X ([14XReference:1577IsPackageMarkedForLoading[114X) introduced in [5XGAP[105X 4.5.[133X15781579[30X [33X[0;12YCheck if the package still relies on some obsolete variables1580(see [14X'Reference: Replaced and Removed Command Names'[114X) and try to1581get rid of their usage.[133X1582158315841585