Blame INSTALL.rst.txt

Packit 7a8e5e
Building and installing NumPy
Packit 7a8e5e
+++++++++++++++++++++++++++++
Packit 7a8e5e
Packit 7a8e5e
**IMPORTANT**: the below notes are about building NumPy, which for most users
Packit 7a8e5e
is *not* the recommended way to install NumPy.  Instead, use either a complete
Packit 7a8e5e
scientific Python distribution (recommended) or a binary installer - see
Packit 7a8e5e
http://scipy.org/install.html.
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
.. Contents::
Packit 7a8e5e
Packit 7a8e5e
Prerequisites
Packit 7a8e5e
=============
Packit 7a8e5e
Packit 7a8e5e
Building NumPy requires the following software installed:
Packit 7a8e5e
Packit 7a8e5e
1) For Python 2, Python__ 2.7.x or newer.
Packit 7a8e5e
   For Python 3, Python__ 3.4.x or newer.
Packit 7a8e5e
Packit 7a8e5e
   On Debian and derivative (Ubuntu): python python-dev
Packit 7a8e5e
Packit 7a8e5e
   On Windows: the official python installer on Python__ is enough
Packit 7a8e5e
Packit 7a8e5e
   Make sure that the Python package distutils is installed before
Packit 7a8e5e
   continuing. For example, in Debian GNU/Linux, distutils is included
Packit 7a8e5e
   in the python-dev package.
Packit 7a8e5e
Packit 7a8e5e
   Python must also be compiled with the zlib module enabled.
Packit 7a8e5e
Packit 7a8e5e
2) Cython >= 0.19 (for development versions of numpy, not for released
Packit 7a8e5e
                   versions)
Packit 7a8e5e
3) nose__ (optional) 1.0 or later
Packit 7a8e5e
Packit 7a8e5e
   This is required for testing numpy, but not for using it.
Packit 7a8e5e
Packit 7a8e5e
Python__ http://www.python.org
Packit 7a8e5e
nose__ http://nose.readthedocs.io
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
.. note:: 
Packit 7a8e5e
Packit 7a8e5e
   If you want to build NumPy in order to work on NumPy itself, use
Packit 7a8e5e
   ``runtests.py``.  For more details, see
Packit 7a8e5e
   http://docs.scipy.org/doc/numpy-dev/dev/development_environment.html
Packit 7a8e5e
Packit 7a8e5e
.. note::
Packit 7a8e5e
Packit 7a8e5e
   More extensive information on building NumPy (and Scipy) is maintained at
Packit 7a8e5e
   http://scipy.org/scipylib/building/index.html
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
Basic Installation
Packit 7a8e5e
==================
Packit 7a8e5e
Packit 7a8e5e
To install numpy run::
Packit 7a8e5e
Packit 7a8e5e
    python setup.py build -j 4 install --prefix $HOME/.local
Packit 7a8e5e
Packit 7a8e5e
This will compile numpy on 4 CPUs and install it into the specified prefix.
Packit 7a8e5e
To perform an inplace build that can be run from the source folder run::
Packit 7a8e5e
Packit 7a8e5e
    python setup.py build_ext --inplace -j 4
Packit 7a8e5e
Packit 7a8e5e
The number of build jobs can also be specified via the environment variable
Packit 7a8e5e
NPY_NUM_BUILD_JOBS.
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
Choosing compilers
Packit 7a8e5e
==================
Packit 7a8e5e
Packit 7a8e5e
NumPy needs a C compiler, and for development versions also Cython.  A Fortran
Packit 7a8e5e
compiler isn't needed to build NumPy itself; the ``numpy.f2py`` tests will be
Packit 7a8e5e
skipped when running the test suite if no Fortran compiler is available.  For
Packit 7a8e5e
building Scipy a Fortran compiler is needed though, so we include some details
Packit 7a8e5e
on Fortran compilers in the rest of this section.
Packit 7a8e5e
Packit 7a8e5e
On OS X and Linux, all common compilers will work.  Note that for Fortran,
Packit 7a8e5e
``gfortran`` is strongly preferred over ``g77``, but if you happen to have both
Packit 7a8e5e
installed then ``g77`` will be detected and used first.  To explicitly select
Packit 7a8e5e
``gfortran`` in that case, do::
Packit 7a8e5e
Packit 7a8e5e
    python setup.py build --fcompiler=gnu95
Packit 7a8e5e
Packit 7a8e5e
Windows
Packit 7a8e5e
-------
Packit 7a8e5e
Packit 7a8e5e
On Windows, building from source can be difficult.  Currently the most robust
Packit 7a8e5e
option is to use the Intel compilers, or alternatively MSVC (the same version
Packit 7a8e5e
as used to build Python itself) with Intel ifort.  Intel itself maintains a
Packit 7a8e5e
good `application note <https://software.intel.com/en-us/articles/numpyscipy-with-intel-mkl>`_
Packit 7a8e5e
on this.
Packit 7a8e5e
Packit 7a8e5e
If you want to use a free compiler toolchain, the recommended compiler is MingwPy__.
Packit 7a8e5e
The older MinGW32 compiler set used to produce older .exe installers for NumPy
Packit 7a8e5e
itself is still available at https://github.com/numpy/numpy-vendor, but not
Packit 7a8e5e
recommended for use anymore.
Packit 7a8e5e
Packit 7a8e5e
MingwPy__ http://mingwpy.github.io
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
Building with optimized BLAS support
Packit 7a8e5e
====================================
Packit 7a8e5e
Packit 7a8e5e
Configuring which BLAS/LAPACK is used if you have multiple libraries installed,
Packit 7a8e5e
or you have only one installed but in a non-standard location, is done via a
Packit 7a8e5e
``site.cfg`` file.  See the ``site.cfg.example`` shipped with NumPy for more
Packit 7a8e5e
details.
Packit 7a8e5e
Packit 7a8e5e
Windows
Packit 7a8e5e
-------
Packit 7a8e5e
Packit 7a8e5e
The Intel compilers work with Intel MKL, see the application note linked above. 
Packit 7a8e5e
MingwPy__ works with OpenBLAS.
Packit 7a8e5e
For an overview of the state of BLAS/LAPACK libraries on Windows, see 
Packit 7a8e5e
`here <http://mingwpy.github.io/blas_lapack.html>`_.
Packit 7a8e5e
Packit 7a8e5e
OS X
Packit 7a8e5e
----
Packit 7a8e5e
Packit 7a8e5e
OS X ships the Accelerate framework, which NumPy can build against without any
Packit 7a8e5e
manual configuration.  Other BLAS/LAPACK implementations (OpenBLAS, Intel MKL,
Packit 7a8e5e
ATLAS) will also work.
Packit 7a8e5e
Packit 7a8e5e
Ubuntu/Debian
Packit 7a8e5e
-------------
Packit 7a8e5e
Packit 7a8e5e
For best performance a development package providing BLAS and CBLAS should be
Packit 7a8e5e
installed.  Some of the options available are:
Packit 7a8e5e
Packit 7a8e5e
- ``libblas-dev``: reference BLAS (not very optimized)
Packit 7a8e5e
- ``libatlas-base-dev``: generic tuned ATLAS, it is recommended to tune it to
Packit 7a8e5e
  the available hardware, see /usr/share/doc/libatlas3-base/README.Debian for
Packit 7a8e5e
  instructions
Packit 7a8e5e
- ``libopenblas-base``: fast and runtime detected so no tuning required but a
Packit 7a8e5e
  very recent version is needed (>=0.2.15 is recommended).  Older versions of
Packit 7a8e5e
  OpenBLAS suffered from correctness issues on some CPUs.
Packit 7a8e5e
Packit 7a8e5e
The package linked to when numpy is loaded can be chosen after installation via
Packit 7a8e5e
the alternatives mechanism::
Packit 7a8e5e
Packit 7a8e5e
    update-alternatives --config libblas.so.3
Packit 7a8e5e
    update-alternatives --config liblapack.so.3
Packit 7a8e5e
Packit 7a8e5e
Or by preloading a specific BLAS library with::
Packit 7a8e5e
Packit 7a8e5e
    LD_PRELOAD=/usr/lib/atlas-base/atlas/libblas.so.3 python ...
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
Build issues
Packit 7a8e5e
============
Packit 7a8e5e
Packit 7a8e5e
If you run into build issues and need help, the NumPy
Packit 7a8e5e
`mailing list <http://scipy.org/scipylib/mailing-lists.html>`_ is the best
Packit 7a8e5e
place to ask.  If the issue is clearly a bug in NumPy, please file an issue (or
Packit 7a8e5e
even better, a pull request) at https://github.com/numpy/numpy.