Did you know ... | Search Documentation: |
Creating and submitting extension packages for SWI-Prolog |
A pack is an archive (.zip
or .tgz
) file that (minimally) contains,
two items:
prolog
.pl
.pack.pl
Creating a pack that uses C or C++ code is described here
A pack is created by creating a directory with the name of the pack and filling it with the content described above. Next, create an archive, which is either a gzipped tar file or a zip file from the 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
The pack may be installed using pack_install/1 as illustrated below.
?- pack_install('mypack-1.0.tgz').
To make the pack available, it must be downloadable from a publicly available HTTP 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 http://www.example.com/swi-prolog/pack/mypack-1.0.tgz, fetching http://www.example.com/swi-prolog/pack/ must return an HTML document with links to available package files.
After uploading the package to e.g., http://www.example.com/swi-prolog/pack/mypack-1.0.tgz, it is made available to other users simply by installing it yourself:
?- pack_install('http://www.example.com/swi-prolog/pack/mypack-1.0.tgz').
After this, other people can install your package simply using
?- pack_install(mypack).
Packages can be downloaded from GitHub in two ways:
https://github.com/<owner>/<pack>.git
v
or V
.
https://github.com/<owner>/<pack>/archive/<tag>.zip
The advantage of using GitHub releases is that you decide when a new
version is ready for public use. Using GitHub releases requires
SWI-Prolog 7.1.22 or later. Automatic update checking can be enabled
by setting the download
attribute of the pack to:
https://github.com/<owner>/<pack>/releases/*.zip
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.pack.pl
matches the version encoded in the archive name.