Sage package management commands¶
A Sage package has the extension .spkg. It is a tarball that is (usually) bzip2 compressed that contains arbitrary data and an spkg-install file. An Sage package typically has the following components:
- spkg-install - shell script that is run to install the package
- Sage.txt - file that describes how the package was made, who maintains it, etc.
- sage - directory with extra patched version of files that needed during the install
Use the install_package
command to install a new
package, and use optional_packages
to list all
optional packages available on the central Sage server. The
upgrade
command upgrades all standard packages -
there is no auto-upgrade command for optional packages.
All package management can also be done via the Sage command line.
-
sage.misc.package.
experimental_packages
()¶ Return two lists. The first contains the installed and the second contains the not-installed experimental packages that are available from the Sage repository. You must have an internet connection.
OUTPUT:
- installed experimental packages (as a list)
- NOT installed experimental packages (as a list)
Use
install_package(package_name)
to install or re-install a given package.See also
EXAMPLE:
sage: from sage.misc.package import experimental_packages sage: installed, not_installed = experimental_packages() # optional internet sage: min(installed+not_installed) # optional internet 'PyQt4' sage: max(installed+not_installed) # optional internet 'yassl'
-
sage.misc.package.
install_all_optional_packages
(force=True, dry_run=False)¶ Install all available optional spkg’s in the official Sage spkg repository. Returns a list of all spkg’s that fail to install.
INPUT:
force
– bool (default:True
); whether to force reinstall of spkg’s that are already installed.dry_run
– bool (default:False
); ifTrue
, just list the packages that would be installed in order, but don’t actually install them.
OUTPUT:
list of stringsNote
This is designed mainly for testing purposes. This also doesn’t do anything with respect to dependencies – the packages are installed in alphabetical order. Dependency issues will be dealt with in a future version.
AUTHOR:
– William Stein (2008-12)EXAMPLES:
sage: sage.misc.package.install_all_optional_packages(dry_run=True) # optional - internet Installing ... []
-
sage.misc.package.
install_package
(package=None, force=False)¶ Install a package or return a list of all packages that have been installed into this Sage install.
You must have an internet connection. Also, you will have to restart Sage for the changes to take affect.
It is not needed to provide the version number.
INPUT:
package
– optional; if specified, install the given package. If not, list all installed packages.force
– boolean (default:False
); ifTrue
, reinstall the package given if it is already installed. (Otherwise, an already installed package doesn’t get reinstalled, as with ‘sage -i ...’.)
EXAMPLES:
With no arguments, list the installed packages:
sage: install_package() [...'atlas...'python...]
With an argument, install the named package:
sage: install_package('chomp') # not tested Attempting to download package chomp-20100213.p2 ...
IMPLEMENTATION:
Calls ‘sage -f ...’ to (re)install the package if a package name is given. If no package name is given, simply list the contents of
spkg/installed
.See also
-
sage.misc.package.
is_package_installed
(package)¶ Return true if
package
is installed.EXAMPLES:
sage: is_package_installed('pari') True
Giving just the beginning of the package name is not good enough:
sage: is_package_installed('matplotli') False
Otherwise, installing “pillow” will cause this function to think that “pil” is installed, for example.
-
sage.misc.package.
optional_packages
()¶ Return two lists. The first contains the installed and the second contains the not-installed optional packages that are available from the Sage repository. You must have an internet connection.
OUTPUT:
- installed optional packages (as a list)
- NOT installed optional packages (as a list)
Use
install_package(package_name)
to install or re-install a given package.See also
EXAMPLE:
sage: from sage.misc.package import optional_packages sage: installed, not_installed = optional_packages() # optional internet sage: min(installed+not_installed) # optional internet '4ti2' sage: max(installed+not_installed) # optional internet 'zeromq'
-
sage.misc.package.
package_mesg
(package_name)¶
-
sage.misc.package.
package_versions
(package_type, local=False)¶ Return version information for each Sage package.
INPUT:
package_type
(string) – one of,
or
local
(boolean) – only query local data (no internet needed)
For packages of the given type, return a dictionary whose entries are of the form
'package': (installed, latest)
, whereinstalled
is the installed version (orNone
if not installed) andlatest
is the latest available version. If the package has a directory inSAGE_ROOT/build/pkgs/
, thenlatest
is determined by the filepackage-version.txt
in that directory. Iflocal
is False, then Sage’s servers are queried for package information.EXAMPLES:
sage: std = package_versions('standard', local=True) sage: 'gap' in std True sage: std['zn_poly'] ('0.9.p11', '0.9.p11')
-
sage.misc.package.
standard_packages
()¶ Return two lists. The first contains the installed and the second contains the not-installed standard packages that are available from the Sage repository. You must have an internet connection.
OUTPUT:
- installed standard packages (as a list)
- NOT installed standard packages (as a list)
Use
install_package(package_name)
to install or re-install a given package.See also
EXAMPLE:
sage: from sage.misc.package import standard_packages sage: installed, not_installed = standard_packages() # optional internet sage: installed[0], installed[-1] # optional internet ('atlas', 'zn_poly') sage: 'mercurial' in not_installed # optional internet True
-
sage.misc.package.
upgrade
()¶ Download and build the latest version of Sage.
You must have an internet connection. Also, you will have to restart Sage for the changes to take affect.
This upgrades to the latest version of core packages (optional packages are not automatically upgraded).
This will not work on systems that don’t have a C compiler.
See also