GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DOC: Update building docs to use Meson by melissawm · Pull Request #24573 · numpy/numpy

DOC: Update building docs to use Meson #24573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
rgommers merged 6 commits into numpy:main from melissawm:meson-docs
Sep 1, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

DOC: Update building docs to use Meson #24573

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit Hold shift + click to select a range
3ca9e09
DOC: Update building docs to use Meson
melissawm Jul 26, 2023
ef13bc7
DOC: Clean up Meson building documentation
melissawm Aug 31, 2023
8a3054f
DOC: more fixes to build docs
rgommers Sep 1, 2023
d4fab5d
DOC: fixes to ensure all docs commands work
rgommers Sep 1, 2023
27a630e
DOC: remove `spin` usage from user/building.rst
rgommers Sep 1, 2023
0b163c2
DOC: more fixes for compilers and BLAS/LAPACK in INSTALL.rst
rgommers Sep 1, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: Clean up Meson building documentation
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@melissawm @rgommers
melissawm authored and rgommers committed Sep 1, 2023
commit ef13bc7a23b6dee826a815261e27ddbcab2b5160

There are no files selected for viewing

2 changes: 1 addition & 1 deletion 2 doc/RELEASE_WALKTHROUGH.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ repository::

Sanity check::

$ spin test -m full
$ python3 -m spin test -m full

Tag the release and push the tag. This requires write permission for the numpy
repository::
Expand Down
11 changes: 0 additions & 11 deletions 11 doc/source/dev/development_environment.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ For more options including selecting compilers, setting custom compiler flags
and controlling parallelism, see :doc:`scipy:building/compilers_and_options`
(from the SciPy documentation.)

..
NumPy uses a series of tests to probe the compiler and libc libraries for
functions. The results are stored in ``_numpyconfig.h`` and ``config.h`` files
using ``HAVE_XXX`` definitions. These tests are run during the ``build_src``
phase of the ``_multiarray_umath`` module in the ``generate_config_h`` and
``generate_numpyconfig_h`` functions. Since the output of these calls includes
many compiler warnings and errors, by default it is run quietly. If you wish
to see this output, you can run the ``build_src`` stage verbosely::

$ python build build_src -v


Running tests
-------------
Expand Down
32 changes: 1 addition & 31 deletions 32 doc/source/dev/howto_build_docs.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,7 @@ Now you are ready to generate the docs, so write::

This will build NumPy from source if you haven't already, and run Sphinx to
build the ``html`` docs. If all goes well, this will generate a ``build/html``
subdirectory in the ``/doc`` directory, containing the built documentation. If
you get a message about ``installed numpy != current repo git version``, you
must either override the check by setting ``GITVER`` or re-install NumPy.

You can also use the ``Makefile`` under the ``/doc`` directory and run::

make html

If you have built NumPy into a virtual environment and get an error
that says ``numpy not found, cannot build documentation without...``,
you need to override the makefile ``PYTHON`` variable at the command
line, so instead of writing ``make html`` write::

make PYTHON=python html

To build the PDF documentation, do instead::

make latex
make -C build/latex all-pdf

You will need to have LaTeX_ installed for this, inclusive of support for
Greek letters. For example, on Ubuntu xenial ``texlive-lang-greek`` and
``cm-super`` are needed. Also, ``latexmk`` is needed on non-Windows systems.

Instead of the above, you can also do::

make dist

which will rebuild NumPy, install it to a temporary location, and
build the documentation in all formats. This will most likely again
only work on Unix platforms.
subdirectory in the ``/doc`` directory, containing the built documentation.

The documentation for NumPy distributed at https://numpy.org/doc in html and
pdf format is also built with ``make dist``. See `HOWTO RELEASE`_ for details
Expand Down
266 changes: 23 additions & 243 deletions 266 doc/source/user/building.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ Building NumPy requires the following software installed:
them and use them for building. A number of different LAPACK library setups
can be used, including optimized LAPACK libraries such as OpenBLAS or MKL.
The choice and location of these libraries as well as include paths and
other such build options can be specified in a ``site.cfg`` file located in
the NumPy root repository or a ``.numpy-site.cfg`` file in your home
directory. See the ``site.cfg.example`` example file included in the NumPy
repository or sdist for documentation, and below for specifying search
priority from environmental variables.
other such build options can be specified in a ``.pc`` file, as documented in
:ref:`scipy:using-pkg-config-to-detect-libraries-in-a-nonstandard-location`.

4) Cython

Expand Down Expand Up @@ -96,6 +93,12 @@ then run::

spin build

After compilation, NumPy will be installed into ``./build-install``.

The build is done in parallel by default, using the optimal number of parallel processes. You can also control this via the ``-j`` option::

spin build -j4

This does not result in an in-place build, and to run the version of NumPy you
have just built, you can use::

Expand All @@ -105,23 +108,26 @@ and import NumPy as usual.

For more information on the ``spin`` utility, use ``spin --help``.

.. _parallel-builds:

Parallel builds
~~~~~~~~~~~~~~~

It's possible to do a parallel build with the following command::

spin build -j 4

This will compile NumPy on 4 CPUs and install it into ``./build-install``.

Advanced building with Meson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Meson supports the standard environment variables ``CC``, ``CXX`` and ``FC`` to
select specific C, C++ and/or Fortran compilers. These environment variables are
documented in `the reference tables in the Meson docs
<https://mesonbuild.com/Reference-tables.html#compiler-and-linker-flag-environment-variables>`_.

Note that environment variables only get applied from a clean build, because
they affect the configure stage (i.e., meson setup). An incremental rebuild does
not react to changes in environment variables - you have to run
``git clean -xdf`` and do a full rebuild, or run ``meson setup --reconfigure``.

For more options including selecting compilers, setting custom compiler flags
and controlling parallelism, see :doc:`scipy:building/compilers_and_options`
(from the SciPy documentation.)
(from the SciPy documentation) and `the Meson FAQ
<https://mesonbuild.com/howtox.html#set-extra-compiler-and-linker-flags-from-the-outside-when-eg-building-distro-packages>`_.


Testing
-------
Expand Down Expand Up @@ -154,236 +160,10 @@ in the
`meson_options.txt <https://github.com/numpy/numpy/blob/main/meson_options.txt>`_
file.

.. note::

Support for the environment variables described below is still not present
in the Meson workflow at this time.

BLAS
~~~~

Note that both BLAS and CBLAS interfaces are needed for a properly
optimized build of NumPy.

The default order for the libraries are:

1. MKL
2. BLIS
3. OpenBLAS
4. ATLAS
5. BLAS (NetLIB)

The detection of BLAS libraries may be bypassed by defining the environment
variable ``NPY_BLAS_LIBS`` , which should contain the exact linker flags you
want to use (interface is assumed to be Fortran 77). Also define
``NPY_CBLAS_LIBS`` (even empty if CBLAS is contained in your BLAS library) to
trigger use of CBLAS and avoid slow fallback code for matrix calculations.

If you wish to build against OpenBLAS but you also have BLIS available one
may predefine the order of searching via the environment variable
``NPY_BLAS_ORDER`` which is a comma-separated list of the above names which
is used to determine what to search for, for instance::

NPY_BLAS_ORDER=ATLAS,blis,openblas,MKL python setup.py build

will prefer to use ATLAS, then BLIS, then OpenBLAS and as a last resort MKL.
If neither of these exists the build will fail (names are compared
lower case).

Alternatively one may use ``!`` or ``^`` to negate all items::

NPY_BLAS_ORDER='^blas,atlas' python setup.py build

will allow using anything **but** NetLIB BLAS and ATLAS libraries, the order
of the above list is retained.

One cannot mix negation and positives, nor have multiple negations, such
cases will raise an error.

LAPACK
~~~~~~

The default order for the libraries are:

1. MKL
2. OpenBLAS
3. libFLAME
4. ATLAS
5. LAPACK (NetLIB)

The detection of LAPACK libraries may be bypassed by defining the environment
variable ``NPY_LAPACK_LIBS``, which should contain the exact linker flags you
want to use (language is assumed to be Fortran 77).

If you wish to build against OpenBLAS but you also have MKL available one
may predefine the order of searching via the environment variable
``NPY_LAPACK_ORDER`` which is a comma-separated list of the above names,
for instance::

NPY_LAPACK_ORDER=ATLAS,openblas,MKL python setup.py build

will prefer to use ATLAS, then OpenBLAS and as a last resort MKL.
If neither of these exists the build will fail (names are compared
lower case).

Alternatively one may use ``!`` or ``^`` to negate all items::

NPY_LAPACK_ORDER='^lapack' python setup.py build

will allow using anything **but** the NetLIB LAPACK library, the order of
the above list is retained.

One cannot mix negation and positives, nor have multiple negations, such
cases will raise an error.

.. deprecated:: 1.20
The native libraries on macOS, provided by Accelerate, are not fit for use
in NumPy since they have bugs that cause wrong output under easily
reproducible conditions. If the vendor fixes those bugs, the library could
be reinstated, but until then users compiling for themselves should use
another linear algebra library or use the built-in (but slower) default,
see the next section.


Disabling ATLAS and other accelerated libraries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Usage of ATLAS and other accelerated libraries in NumPy can be disabled
via::

NPY_BLAS_ORDER= NPY_LAPACK_ORDER= python setup.py build

or::

BLAS=None LAPACK=None ATLAS=None python setup.py build


64-bit BLAS and LAPACK
~~~~~~~~~~~~~~~~~~~~~~

You can tell Numpy to use 64-bit BLAS/LAPACK libraries by setting the
environment variable::

NPY_USE_BLAS_ILP64=1

when building Numpy. The following 64-bit BLAS/LAPACK libraries are
supported:

1. OpenBLAS ILP64 with ``64_`` symbol suffix (``openblas64_``)
2. OpenBLAS ILP64 without symbol suffix (``openblas_ilp64``)

The order in which they are preferred is determined by
``NPY_BLAS_ILP64_ORDER`` and ``NPY_LAPACK_ILP64_ORDER`` environment
variables. The default value is ``openblas64_,openblas_ilp64``.

.. note::

Using non-symbol-suffixed 64-bit BLAS/LAPACK in a program that also
uses 32-bit BLAS/LAPACK can cause crashes under certain conditions
(e.g. with embedded Python interpreters on Linux).

The 64-bit OpenBLAS with ``64_`` symbol suffix is obtained by
compiling OpenBLAS with settings::

make INTERFACE64=1 SYMBOLSUFFIX=64_

The symbol suffix avoids the symbol name clashes between 32-bit and
64-bit BLAS/LAPACK libraries.

Cross compilation
-----------------

Although ``numpy.distutils`` and ``setuptools`` do not directly support cross
compilation, it is possible to build NumPy on one system for different
architectures with minor modifications to the build environment. This may be
desirable, for example, to use the power of a high-performance desktop to
create a NumPy package for a low-power, single-board computer. Because the
``setup.py`` scripts are unaware of cross-compilation environments and tend to
make decisions based on the environment detected on the build system, it is
best to compile for the same type of operating system that runs on the builder.
Attempting to compile a Mac version of NumPy on Windows, for example, is likely
to be met with challenges not considered here.

For the purpose of this discussion, the nomenclature adopted by `meson`_ will
be used: the "build" system is that which will be running the NumPy build
process, while the "host" is the platform on which the compiled package will be
run. A native Python interpreter, the setuptools and Cython packages and the
desired cross compiler must be available for the build system. In addition, a
Python interpreter and its development headers as well as any external linear
algebra libraries must be available for the host platform. For convenience, it
is assumed that all host software is available under a separate prefix
directory, here called ``$CROSS_PREFIX``.
For cross compilation instructions, see :doc:`scipy:cross_compilation` and the
`Meson documentation <meson>`_.

.. _meson: https://mesonbuild.com/Cross-compilation.html#cross-compilation

When building and installing NumPy for a host system, the ``CC`` environment
variable must provide the path the cross compiler that will be used to build
NumPy C extensions. It may also be necessary to set the ``LDSHARED``
environment variable to the path to the linker that can link compiled objects
for the host system. The compiler must be told where it can find Python
libraries and development headers. On Unix-like systems, this generally
requires adding, *e.g.*, the following parameters to the ``CFLAGS`` environment
variable::

-I${CROSS_PREFIX}/usr/include
-I${CROSS_PREFIX}/usr/include/python3.y

for Python version 3.y. (Replace the "y" in this path with the actual minor
number of the installed Python runtime.) Likewise, the linker should be told
where to find host libraries by adding a parameter to the ``LDFLAGS``
environment variable::

-L${CROSS_PREFIX}/usr/lib

To make sure Python-specific system configuration options are provided for the
intended host and not the build system, set::

_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_${ARCH_TRIPLET}

where ``${ARCH_TRIPLET}`` is an architecture-dependent suffix appropriate for
the host architecture. (This should be the name of a ``_sysconfigdata`` file,
without the ``.py`` extension, found in the host Python library directory.)

When using external linear algebra libraries, include and library directories
should be provided for the desired libraries in ``site.cfg`` as described
above and in the comments of the ``site.cfg.example`` file included in the
NumPy repository or sdist. In this example, set::

include_dirs = ${CROSS_PREFIX}/usr/include
library_dirs = ${CROSS_PREFIX}/usr/lib

under appropriate sections of the file to allow ``numpy.distutils`` to find the
libraries.

As of NumPy 1.22.0, a vendored copy of SVML will be built on ``x86_64`` Linux
hosts to provide AVX-512 acceleration of floating-point operations. When using
an ``x86_64`` Linux build system to cross compile NumPy for hosts other than
``x86_64`` Linux, set the environment variable ``NPY_DISABLE_SVML`` to prevent
the NumPy build script from incorrectly attempting to cross-compile this
platform-specific library::

NPY_DISABLE_SVML=1

With the environment configured, NumPy may be built as it is natively::

python setup.py build

When the ``wheel`` package is available, the cross-compiled package may be
packed into a wheel for installation on the host with::

python setup.py bdist_wheel

It may be possible to use ``pip`` to build a wheel, but ``pip`` configures its
own environment; adapting the ``pip`` environment to cross-compilation is
beyond the scope of this guide.

The cross-compiled package may also be installed into the host prefix for
cross-compilation of other packages using, *e.g.*, the command::

python setup.py install --prefix=${CROSS_PREFIX}

When cross compiling other packages that depend on NumPy, the host
npy-pkg-config file must be made available. For further discussion, refer to
`numpy distutils documentation`_.

.. _numpy distutils documentation: https://numpy.org/devdocs/reference/distutils.html#numpy.distutils.misc_util.Configuration.add_npy_pkg_config
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.