How-to get decimal.py if I have Python 2.3.x

This texts explains how to obtain a suitable archive file for installation of decimal with Python 2.3.x. Companion file README explains how to perform the installation if the archive you download doesn't do everything for you, and also contains other useful information and pointers.

Module decimal.py already comes with the standard Python 2.4 and newer versions; in these cases you don't need to download it separately. Note that decimal is not officially supported for Python 2.2 and older versions -- if you're into archaeology, you're on your own!

Downloading the necessary files

You can make either of two different choices here: download a module installer archive file, or download the files separately.

In the first case, the procedure is simple, but maybe you won't get the latest version. In the second case, the procedure has more steps, but you'll be sure of getting the module latest version.

Using the installer

Go to http://sourceforge.net/projects/sigefi, to the file releases section, and choose the package type to download:

  • decimal-x.x.win32.exe: Windows only.
  • decimal-x.x-x.rpm: For RPM based Linux distributions.
  • decimal-x.x.tar.gz: The simplest and most general (should work whatever the platform on which you have Python 2.3 installed).

In the first case, just execute the installer. In the second case, do rpm -i decimal-x.x-x.rpm as root.

In the third case, also as root, in any shell/command window, unzip and untar the package, cd to the directory thus created, and execute the installer -- for example, on a typical Linux or Unix installation:

$ gunzip decimal-x.x.tar.gz
$ tar -xf decimal-x.x.tar
$ cd decimal-x.x
$ su [[ enter password appropriately when requested ]]
# python setup.py install
# [[ close the root session with Ctrl-D ]]
$

Alternatively, if your machine is set up appropriately, instead of su followed by the execution of the installer and then the exit from the root session, you can mode compactly use sudo (again, you may have to enter your password appropriately if sudo asks you for it):

$ sudo python setup.py install

This assumes that Python 2.3 is the one found as python on your PATH. Otherwise, equivalently, enter a complete path to it, such as:

$ sudo /weirdly/placed/python2.3 setup.py install

Downloading the files separately

The decimal module itself is just one file: decimal.py, which you can download from the Python CVS:

http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/decimal.py

You can use any browser, or utility programs such as curl, wget, etc, to download this decimal.py file to some location on your machine.

You must then copy this file into your Python installation site-packages directory (for example, depending on your platform and exactly how you installed Python 2.3, C:\Python23\FIXME\site-packages or /usr/lib/python2.3/site-packages). Note that you may need administrator privileges to put the file there, which may mean, as explained previously in this document, using su or sudo or other means yet as appropriate to your installation.

On MacOSX 10.3, Python 2.3 is part of the operating system and is an OSX framework -- but if you work at the Terminal, which basically means at the BSD Unix level underlying MacOSX, you can still treat it as a directory, and (typically with sudo from a user who is an administrator, since root is normally not enabled in a good MacOSX installation) copy decimal.py into the rather long "directory path" named:

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages

Whenever you install anything it's always a good idea to test whatever you have just installed. To test the decimal.py installation you need additional files: test_decimal.py and all of the test files (inside a directory), that you can also download from the Python CVS repository:

http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/test/test_decimal.py http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/test/decimaltestdata/

and then you can proceed to the next section of this document.

Checking that everything is fine

If you chose to download and unpack an archive, in the directory in which you executed the installer you'll already have a test subdirectory. If you downloaded the files separately, or used a self-executing installer format that doesn't come with the tests (so you also downloaded the tests separately from CVS, as per the previous section), you should have downloaded placed, in any appropriate test directory of your choice, the test_decimal.py file and a decimaltestdata subdirectory with data files in it.

In any case, go to that test directory and execute the tests with:

python test_decimal.py

You do NOT need administrator privileges to run the tests, so it's best to run them with a normal, non-privileged user (the tests can't break anything, but "least possible privilege" is a key security practice).

You'll see a lot of messages while different module parts are tested, ending with a message similar to:

OK
doctest (decimal) ... nn tests with zero failures

If there's any problem with the tests, please contact the developers.

Documentation

In the same directory which you entered in order to execute the installer, you'll have a docs subdirectory. Directory docs contains documentation in several formats:

The .tex file was extracted from the Python CVS, and the HTML files were extracted from the on-line Python documentation (modified to get all the Decimal-related links pointing to the downloaded files).

You can also check the documentation online, currently at: http://www.python.org/dev/doc/devel/lib/module-decimal.html.

Acknowledgements

I would like to thanks to Alex Martelli for the help with these docs and his gentle pressure in order to package this Decimal independent distribution.