Macaulay2 » Documentation
Packages » Macaulay2Doc > The Macaulay2 language > creating a package
next | previous | forward | backward | up | index | toc

creating a package

Creating a package is the most common way of contributing to Macaulay2. Packages can contain code for working with objects of a certain category, generating examples for testing a conjecture, or an implementation of algorithms introduced in the literature.

There are five parts to a Macaulay2 package

  • the preamble, initiated by newPackage
  • a list of exported functions and variables, set via export and exportMutable
  • the code that constitutes the package
  • the documentation for the package, which comes after beginDocumentation
  • a number of tests for the new package, added using TEST

See an example of a package for the basic template for new packages, or packageTemplate for a utility for generating the skeleton for a new package.

The name of the package must be the name of the file, without the .m2 suffix. Thus a package NewMath will be in a file named NewMath.m2. Other sources required by the package may be stored in a subdirectory named NewMath located in the same directory as the package.

Documenting and testing a package

The documentation and tests included in a package inform others about how to use your package and ensure that your package continues to work with future versions of Macaulay2. See writing documentation for more information.

Distributing a package

To add your package to the list of packages distributed with Macaulay2, authors can submit their package via a pull request to the GitHub repository for Macaulay2.

Before submitting your package, use the installPackage and check functions to ensure there are no errors in the package documentation and that all the tests pass.

See also


Components of a package