Skip to content

version information in sage.__version__ #21022

@haraldschilly

Description

@haraldschilly

Almost all python libs I know have libname.__version__. This allows someone to write scripts for checking/listing the version of all available libs.

As of Sage 8.2.beta8, the available ways to get the version are:

$ sage --python
>>> sage.version.version
'8.2.beta8'
>>> from sage.env import SAGE_VERSION
>>> SAGE_VERSION
'8.2.beta8'

After this ticket is merged, the simpler call

>>> sage.__version__
'8.2.beta8'

will work, just like in most Python packages:

$ sage --python
>>> import numpy
>>> numpy.__version__
'1.13.3'
>>> import scipy
>>> scipy.__version__
'0.19.1'
>>> import sympy
>>> sympy.__version__
'1.1.1'

This will provide a way to require a minimum version of Sage, using something like:

import sage
from distutils.version import LooseVersion
installed = LooseVersion(sage.__version__ + '.z')
minwanted = LooseVersion('8.2' + '.z')
assert(installed >= minwanted)

The trick of adding .z ensures correct ordering, because it
makes final version greater than release candidate versions,
which are greater than beta, which are greater than alpha.

For instance:

  • 8.2.z >= 8.2.rc1.z >= 8.2.beta8.z >= 8.2.alpha1.z >= 8.1.z

(even though we don't currently have alpha releases).

CC: @slel

Component: scripts

Keywords: version

Author: Jeroen Demeyer

Branch/Commit: e987a93

Reviewer: Mark Bell

Issue created by migration from https://trac.sagemath.org/ticket/21022

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions