Did you know ... | Search Documentation: |
Creating and submitting extension packages for SWI-Prolog |
A pack is a community contributed extension. Packs provide additional
Prolog libraries, often including foreign (C,C++) libraries. A pack
can be installed system-wide, user-wide or as part of a specific
application. SWI-Prolog searches for packs in sub-directories of
directories in the file search path (see file_search_path/2) pack
.
Each pack is a directory that (minimally) contains, two items:
prolog
.pl
.pack.pl
Packs that use foreign code (C,C++) is described here.
After finding a suitable pack, usually from SWI-Prolog web site
listed here, it may be installed
from the command line using the pack
app:
swipl pack install <pack>
The pack
app provides many commands for managing packs. Use
the command below for help
swipl pack --help
A few common commands are:
swipl pack search <pattern>
swipl pack install <from>
swipl pack remove <pack>
swipl pack list --installed
swipl pack info <pack>
All these commands are also available as Prolog predicates from the library(prolog_pack). See for example pack_install/1,2
A pack is created by creating a directory with the name of the pack and filling it with the content described above. For local testing, the pack can be installed from the directory using the command below. On systems that support it, this creates a symbolic link. On other systems the directory is copied to one of the directories where packs are searched. After that, possible foreign extensions are built and the pack is made available.
swipl pack install .
A pack can be published in two ways: as a link to a GIT repository or
by creating an archive file. We recommend using a GIT
repository on e.g., github or
gitlab. Using a git repository provides a
stable download location as well as easy tracking of changes and
releasing versions. swipl pack install
can be asked to install at
a specific tag or commit hash, providing precise version control
to the user.
When using an archive file, this file is either a gzipped tar file or a zip file that must be named <pack>-<version>.tgz or <pack>-<version>.zip, where version is a list of digits, separated by dots (.). For example:
% tar zcvf mypack-1.0.tgz mypack
or
% zip -r mypack-1.0.zip mypack
For downloading from their registered name, the pack must be hosted on a public web server. To support package upgrading, the HTTP server must have enabled fetching an index of the directory. I.e., if the pack is located at https://www.example.com/swi-prolog/pack/mypack-1.0.tgz, fetching https://www.example.com/swi-prolog/pack/ must return an HTML document with links to available package files. Although not yet enforced, we strongly advice to use https for security.
Once the pack is available from a public location, it may registered with the package list using
swipl pack publish <url>
This will
To update a pack
pack.pl
meta datagit tag
). It is strongly recommended to sign the version tag.swipl pack publish <url>
swipl pack publish <url>
Once registered, packs cannot be moved to a different location. This implies that if you have exclusive control of the git repository or directory holding the archives, nobody can hijack your pack. If there is a need to move the pack anyway, contact the site administrator.
To make packages work smoothly, package submitters need to take care of some rules:
prolog
directory must be Prolog module files.
Use names for the module files that are not likely to conflict with
others. For example, do not use util
as file or module name.pack.pl
matches the version encoded in the archive name.