next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > packages > creating a package

creating a package

There are four parts to a Macaulay2 package: a preamble, which is initiated by the newPackage function, a section where one defines which variables will be exported to global variables, a section containing the actual coding that constitutes the package, and a section containing documentation and tests for the new package.

A basic template for new packages:

newPackage( ... )
  export{ ... }
  exportMutable{ ... }
  -- Macaulay2 code goes here
  document { ... }  -- several document's and TEST's, interspersed
  TEST " ... "
The name of the package must be the name of the file, without the '.m2' suffix. Thus a package 'PACKAGENAME' will be in a file named 'PACKAGENAME.m2'. If the package were more complex, then by convention, there should be a directory named 'PACKAGENAME' on the load path, and the file 'PACKAGENAME.m2' in this directory would load the necessary files.


Parts of a package

Documenting, testing, and distributing a package