Skip to content

Commit aca10dc

Browse files
authored
Merge pull request numpy#28141 from Mugundanmcw/steps_winarm64
DOC: Add instructions to build NumPy on WoA
2 parents 2f27b5f + 1014d09 commit aca10dc

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

doc/source/building/index.rst

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,68 @@ your system.
220220
try again. The Fortran compiler should be installed as described in
221221
this section.
222222

223+
.. tab-item:: Windows on ARM64
224+
:sync: Windows on ARM64
225+
226+
In Windows on ARM64, the set of a compiler options that are available for
227+
building NumPy are limited. Compilers such as GCC and GFortran are not yet
228+
supported for Windows on ARM64. Currently, the NumPy build for Windows on ARM64
229+
is supported with MSVC and LLVM toolchains. The use of a Fortran compiler is
230+
more tricky than on other platforms, because MSVC does not support Fortran, and
231+
gfortran and MSVC can't be used together. If you don't need to run the ``f2py``
232+
tests, simply using MSVC is easiest. Otherwise, you will need the following
233+
set of compilers:
234+
235+
1. MSVC + flang (``cl``, ``flang``)
236+
2. LLVM + flang (``clang-cl``, ``flang``)
237+
238+
First, install Microsoft Visual Studio - the 2022 Community Edition will
239+
work (see the `Visual Studio download site <https://visualstudio.microsoft.com/downloads/>`__).
240+
Ensure that you have installed necessary Visual Studio components for building NumPy
241+
on WoA from `here <https://gist.github.com/Mugundanmcw/c3bb93018d5da9311fb2b222f205ba19>`__.
242+
243+
To use the flang compiler for Windows on ARM64, install Latest LLVM
244+
toolchain for WoA from `here <https://github.com/llvm/llvm-project/releases>`__.
245+
246+
.. tab-set::
247+
248+
.. tab-item:: MSVC
249+
250+
The MSVC installer does not put the compilers on the system path, and
251+
the install location may change. To query the install location, MSVC
252+
comes with a ``vswhere.exe`` command-line utility. And to make the
253+
C/C++ compilers available inside the shell you are using, you need to
254+
run a ``.bat`` file for the correct bitness and architecture (e.g., for
255+
ARM64-based CPUs, use ``vcvarsarm64.bat``).
256+
257+
For detailed guidance, see `Use the Microsoft C++ toolset from the command line
258+
<https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170>`__.
259+
260+
.. tab-item:: LLVM
261+
262+
Similar to MSVC, LLVM does not put the compilers on the system path.
263+
To set system path for LLVM compilers, users may need to use ``set``
264+
command to put compilers on the system path. To check compiler's path
265+
for LLVM's clang-cl, try invoking LLVM's clang-cl compiler in the shell you use
266+
(``clang-cl --version``).
267+
268+
.. note::
269+
270+
Compilers should be on the system path (i.e., the ``PATH`` environment
271+
variable should contain the directory in which the compiler executables
272+
can be found) in order to be found, with the exception of MSVC which
273+
will be found automatically if and only if there are no other compilers
274+
on the ``PATH``. You can use any shell (e.g., Powershell, ``cmd`` or
275+
Git Bash) to invoke a build. To check that this is the case, try
276+
invoking a Fortran compiler in the shell you use (e.g., ``flang
277+
--version``).
278+
279+
.. warning::
280+
281+
Currently, Conda environment is not yet supported officially on `Windows
282+
on ARM64 <https://github.com/conda-forge/conda-forge.github.io/issues/1940>`__.
283+
The present approach uses virtualenv for building NumPy from source on
284+
Windows on ARM64.
223285

224286
Building NumPy from source
225287
--------------------------
@@ -302,7 +364,7 @@ Then you want to do the following:
302364
1. Create a dedicated development environment (virtual environment or conda
303365
environment),
304366
2. Install all needed dependencies (*build*, and also *test*, *doc* and
305-
*optional* dependencies),
367+
*optional* dependencies),
306368
3. Build NumPy with the ``spin`` developer interface.
307369

308370
Step (3) is always the same, steps (1) and (2) are different between conda and
@@ -361,9 +423,25 @@ virtual environments:
361423
python -m venv venv
362424
.\venv\Scripts\activate
363425

426+
.. tab-item:: Windows on ARM64
427+
:sync: Windows on ARM64
428+
429+
::
430+
431+
python -m venv venv
432+
.\venv\Scripts\activate
433+
434+
.. note::
435+
436+
Building NumPy with BLAS and LAPACK functions requires OpenBLAS
437+
library at Runtime. In Windows on ARM64, this can be done by setting
438+
up pkg-config for OpenBLAS dependency. The build steps for OpenBLAS
439+
for Windows on ARM64 can be found `here <http://www.openmathlib.org/OpenBLAS/docs/install/#windows-on-arm>`__.
440+
441+
364442
Then install the Python-level dependencies from PyPI with::
365443

366-
python -m pip install -r requirements/all_requirements.txt
444+
python -m pip install -r requirements/build_requirements.txt
367445

368446
To build NumPy in an activated development environment, run::
369447

0 commit comments

Comments
 (0)