This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / docs

Doc

Building from source

docs/building:index

Building NumPy from source requires setting up system-level dependencies (compilers, BLAS/LAPACK libraries, etc.) first, and then invoking a build. The build may be done in order to install NumPy for local usage, develop NumPy itself, or build redistributable binary packages. And it may be desired to customize aspects of how the build is done. This guide will cover all these aspects. In addition, it provides background information on how the NumPy build works, and links to up-to-date guides for generic Python build & packaging documentation that is relevant.

System-level dependencies

NumPy uses compiled code for speed, which means you need compilers and some other system-level (i.e, non-Python / non-PyPI) dependencies to build it on your system.

Building NumPy from source

If you want to only install NumPy from source once and not do any development work, then the recommended way to build and install is to use pip. Otherwise, conda is recommended.

Building from source to use NumPy

Building from source for NumPy development

If you want to build from source in order to work on NumPy itself, first clone the NumPy repository

git clone https://github.com/numpy/numpy.git
cd numpy
git submodule update --init

Then you want to do the following:

  • Create a dedicated development environment (virtual environment or conda environment),

  • Install all needed dependencies (build, and also test, doc and optional dependencies),

  • Build NumPy with the spin developer interface.

Step (3) is always the same, steps (1) and (2) are different between conda and virtual environments:

To build NumPy in an activated development environment, run

spin build

This will install NumPy inside the repository (by default in a build-install directory). You can then run tests (spin test), drop into IPython (spin ipython), or take other development steps like build the html documentation or running benchmarks. The spin interface is self-documenting, so please see spin --help and spin <subcommand> --help for detailed guidance.

Customizing builds

Background information