Update setup instructions

This commit is contained in:
Sergey B Kirpichev
2023-03-27 06:44:37 +03:00
parent 3ab0f5b42a
commit 4f71a1b7ab
3 changed files with 74 additions and 58 deletions
+8 -1
View File
@@ -13,7 +13,8 @@ import mpmath
# Add any Sphinx extension module names here, as strings.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax',
'sphinx.ext.intersphinx']
# The master toctree document.
master_doc = 'index'
@@ -43,3 +44,9 @@ latex_preamble = r'\usepackage{amsfonts}'
# The name of default reST role, that is, for text marked up `like this`.
default_role = 'math'
# Contains mapping the locations and names of other projects that
# should be linked to in this documentation.
intersphinx_mapping = {
'python3': ('https://docs.python.org/3/', None),
}
+1 -1
View File
@@ -6,7 +6,7 @@ Welcome to mpmath's documentation!
==================================
Mpmath is a Python library for arbitrary-precision floating-point arithmetic.
For general information about mpmath, see the project website http://mpmath.org/
For general information about mpmath, see the project website https://mpmath.org/
These documentation pages include general information as well as docstring listing with extensive use of examples that can be run in the interactive Python interpreter. For quick access to the docstrings of individual functions, use the `index listing <genindex.html>`_, or type ``help(mpmath.function_name)`` in the Python interactive prompt.
+65 -56
View File
@@ -1,129 +1,140 @@
Setting up mpmath
=================
Mpmath requires at least Python 2.7 or 3.5. It has been tested
with CPython 2.7, 3.5 through 3.11 and for PyPy.
Download and installation
-------------------------
Installer
.........
The mpmath setup files can be downloaded from the `Python Package Index <http://pypi.python.org/pypi/mpmath/>`_. Download the source package (available as both .zip and .tar.gz), extract it, open the extracted directory, and run
``python setup.py install``
Using pip
.........
Releases are registered on PyPI, so you can install latest release
of the Mpmath with pip
of the Mpmath with pip::
``pip install mpmath``
pip install mpmath
or some specific version with
or some specific version with::
``pip install mpmath==0.19``
pip install mpmath==0.19
Using setuptools
................
You can install also extra dependencies, e.g. `gmpy
<https://github.com/aleaxit/gmpy>`_ support::
If you have `setuptools <http://pypi.python.org/pypi/setuptools>`_ installed, you can download and install mpmath in one step by running:
pip install mpmath[gmpy]
``easy_install mpmath``
.. tip::
or
``python -m easy_install mpmath``
If you have an old version of mpmath installed already, you may have to pass ``easy_install`` the ``-U`` flag to force an upgrade.
If installation fails, try deleting the following folders: .eggs, mpmath.egg-info, dist, build
Use :mod:`venv` to create isolated Python environment first,
instead of installing everything system-wide.
Debian/Ubuntu
.............
Debian and Ubuntu users can install mpmath with
Debian and Ubuntu users can install mpmath with::
``sudo apt-get install python-mpmath``
sudo apt install python3-mpmath
See `debian <http://packages.debian.org/stable/python/python-mpmath>`_ and `ubuntu <https://launchpad.net/ubuntu/+source/mpmath>`_ package information; please verify that you are getting the latest version.
See `debian <http://packages.debian.org/stable/python/python3-mpmath>`_ and
`ubuntu <https://launchpad.net/ubuntu/+source/mpmath>`_ package information;
please verify that you are getting the latest version.
OpenSUSE
........
Mpmath is provided in the "Science" repository for all recent versions of `openSUSE <http://www.opensuse.org/en/>`_. To add this repository to the YAST software management tool, see http://en.opensuse.org/SDB:Add_package_repositories
Mpmath is provided in the "Science" repository for all recent versions of
`openSUSE <https://www.opensuse.org/>`_. To add this repository to the YAST
software management tool, see
https://en.opensuse.org/SDB:Add_package_repositories
Look up http://download.opensuse.org/repositories/science/ for a list
of supported OpenSUSE versions and use http://download.opensuse.org/repositories/science/openSUSE_11.1/
(or accordingly for your OpenSUSE version) as the repository URL for YAST.
Look up https://download.opensuse.org/repositories/science/ for a list
of supported OpenSUSE versions.
Current development version
...........................
The git repository is https://github.com/mpmath/mpmath
If you are a developer or like to get the latest updates as they come, be sure
to install from git::
git clone git://github.com/mpmath/mpmath.git
cd mpmath
pip install -e .[develop,docs]
Checking that it works
......................
After the setup has completed, you should be able to fire up the interactive Python interpreter and do the following::
After the setup has completed, you should be able to fire up the interactive
Python interpreter and do the following::
>>> from mpmath import *
>>> from mpmath import mp, mpf, pi
>>> mp.dps = 50
>>> print(mpf(2) ** mpf('0.5'))
1.4142135623730950488016887242096980785696718753769
>>> print(2*pi)
6.2831853071795864769252867665590057683943387987502
*Note: if you have are upgrading mpmath from an earlier version, you may have to manually uninstall the old version or remove the old files.*
.. note::
If you have are upgrading mpmath from an earlier version, you may have to
manually uninstall the old version or remove the old files.
Using gmpy (optional)
---------------------
By default, mpmath uses Python integers internally. If `gmpy <http://code.google.com/p/gmpy/>`_ version 1.03 or later is installed on your system, mpmath will automatically detect it and transparently use gmpy integers intead. This makes mpmath much faster, especially at high precision (approximately above 100 digits).
By default, mpmath uses Python integers internally. If `gmpy
<https://github.com/aleaxit/gmpy>`_ version 2.1.0a4 or later is installed on
your system, mpmath will automatically detect it and transparently use gmpy
integers instead. This makes mpmath much faster, especially at high precision
(approximately above 100 digits).
To verify that mpmath uses gmpy, check the internal variable ``BACKEND`` is not equal to 'python':
To verify that mpmath uses gmpy, check the internal variable ``BACKEND`` is not
equal to 'python'.
>>> import mpmath.libmp
>>> mpmath.libmp.BACKEND # doctest:+SKIP
'gmpy'
The gmpy mode can be disabled by setting the MPMATH_NOGMPY environment variable. Note that the mode cannot be switched during runtime; mpmath must be re-imported for this change to take effect.
The gmpy mode can be disabled by setting the ``MPMATH_NOGMPY`` environment
variable. Note that the mode cannot be switched during runtime; mpmath must be
re-imported for this change to take effect.
Running tests
-------------
It is recommended that you run mpmath's full set of unit tests to make sure everything works. The `py.test <https://pytest.org/>`_ is a required dependence for testing. The tests are located in the ``tests`` subdirectory of the main mpmath directory. They can be run using::
It is recommended that you run mpmath's full set of unit tests to make sure
everything works. The `pytest <https://pytest.org/>`_ is a required dependence
for testing. The tests are located in the ``tests`` subdirectory of the mpmath
source tree. They can be run using::
py.test --pyargs mpmath
pytest --pyargs mpmath
Doctests can be run with::
Developers may run tests from the source tree with::
py.test --doctest-modules mpmath
pytest
If any test fails, please send a detailed bug report to the `mpmath issue tracker <https://github.com/mpmath/mpmath/issues>`_.
To run the tests with support for gmpy disabled, set ``MPMATH_NOGMPY`` environment variable.
If any test fails, please send a detailed bug report to the `mpmath issue
tracker <https://github.com/mpmath/mpmath/issues>`_.
To enable extra diagnostics, use, set ``MPMATH_STRICT`` environment variable.
Compiling the documentation
---------------------------
Building the documentation requires `Sphinx <http://sphinx.pocoo.org/>`_.
If you downloaded the source package, the text source for these documentation
pages is included in the ``docs`` directory. The documentation can be compiled
to pretty HTML using `Sphinx <https://www.sphinx-doc.org/>`_::
Use::
python setup.py build_sphinx -c docs -b html,latex
sphinx-build --color -W --keep-going -b html docs build/sphinx/html
The create a PDF::
sphinx-build --color -W --keep-going -b latex docs build/sphinx/latex
make -C build/sphinx/latex all-pdf
Some additional demo scripts are available in the ``demo`` directory included in the source package.
Some additional demo scripts are available in the ``demo`` directory included
in the source package.
Mpmath under Sage
-------------------
Mpmath is a standard package in `Sage <http://sagemath.org/>`_, in version 4.1 or later of Sage.
Mpmath is a standard package in `Sage <https://sagemath.org/>`_, in version 4.1 or later of Sage.
Mpmath is preinstalled a regular Python module, and can be imported as usual within Sage::
----------------------------------------------------------------------
@@ -151,7 +162,7 @@ which permits calling any mpmath function with Sage numbers as input, and gettin
Sage ``RealNumber`` or ``ComplexNumber`` instances
with the appropriate precision back::
sage: w = mpmath.call(mpmath.erf, 2+3*I, prec=100)
sage: w = mpmath.call(mpmath.erf, 2+3*I, prec=100)
sage: w
-20.829461427614568389103088452 + 8.6873182714701631444280787545*I
sage: type(w)
@@ -160,5 +171,3 @@ with the appropriate precision back::
100
See the help for ``sage.libs.mpmath.all`` for further information.