Skip to content

Commit ea603c2

Browse files
authored
Merge pull request numpy#30964 from HaoZeke/doc/fortran-compiler-dedup
DOC: Consolidate Fortran compiler instructions into F2PY docs
2 parents 3f199ea + 3c49728 commit ea603c2

1 file changed

Lines changed: 31 additions & 95 deletions

File tree

doc/source/building/index.rst

Lines changed: 31 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -140,66 +140,26 @@ your system.
140140
.. tab-item:: Windows
141141
:sync: windows
142142

143-
On Windows, the use of a Fortran compiler is more tricky than on other
144-
platforms, because MSVC does not support Fortran, and gfortran and MSVC
145-
can't be used together. If you don't need to run the ``f2py`` tests, simply
146-
using MSVC is easiest. Otherwise, you will need one of these sets of
147-
compilers:
148-
149-
1. MSVC + Intel Fortran (``ifort``)
150-
2. Intel compilers (``icc``, ``ifort``)
151-
3. Mingw-w64 compilers (``gcc``, ``g++``, ``gfortran``)
152-
153143
Compared to macOS and Linux, building NumPy on Windows is a little more
154-
difficult, due to the need to set up these compilers. It is not possible to
155-
just call a one-liner on the command prompt as you would on other
156-
platforms.
157-
158-
First, install Microsoft Visual Studio - the 2019 Community Edition or any
159-
newer version will work (see the
144+
difficult, due to the need to set up compilers. First, install Microsoft
145+
Visual Studio - the 2019 Community Edition or any newer version will work
146+
(see the
160147
`Visual Studio download site <https://visualstudio.microsoft.com/downloads/>`__).
161-
This is needed even if you use the MinGW-w64 or Intel compilers, in order
162-
to ensure you have the Windows Universal C Runtime (the other components of
163-
Visual Studio are not needed when using Mingw-w64, and can be deselected if
164-
desired, to save disk space). The recommended version of the UCRT is
165-
>= 10.0.22621.0.
166-
167-
.. tab-set::
168-
169-
.. tab-item:: MSVC
170-
171-
The MSVC installer does not put the compilers on the system path, and
172-
the install location may change. To query the install location, MSVC
173-
comes with a ``vswhere.exe`` command-line utility. And to make the
174-
C/C++ compilers available inside the shell you are using, you need to
175-
run a ``.bat`` file for the correct bitness and architecture (e.g., for
176-
64-bit Intel CPUs, use ``vcvars64.bat``).
177-
178-
If using a Conda environment while a version of Visual Studio 2019+ is
179-
installed that includes the MSVC v142 package (VS 2019 C++ x86/x64
180-
build tools), activating the conda environment should cause Visual
181-
Studio to be found and the appropriate .bat file executed to set
182-
these variables.
183-
184-
For detailed guidance, see `Use the Microsoft C++ toolset from the command line
185-
<https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170>`__.
148+
This is needed to ensure you have the Windows Universal C Runtime. The
149+
recommended version of the UCRT is >= 10.0.22621.0.
186150

187-
.. tab-item:: Intel
151+
The MSVC installer does not put the compilers on the system path, and
152+
the install location may change. To query the install location, MSVC
153+
comes with a ``vswhere.exe`` command-line utility. And to make the
154+
C/C++ compilers available inside the shell you are using, you need to
155+
run a ``.bat`` file for the correct bitness and architecture (e.g., for
156+
64-bit Intel CPUs, use ``vcvars64.bat``).
188157

189-
Similar to MSVC, the Intel compilers are designed to be used with an
190-
activation script (``Intel\oneAPI\setvars.bat``) that you run in the
191-
shell you are using. This makes the compilers available on the path.
192-
For detailed guidance, see
193-
`Get Started with the Intel® oneAPI HPC Toolkit for Windows
194-
<https://www.intel.com/content/www/us/en/docs/oneapi-hpc-toolkit/get-started-guide-windows/2023-1/overview.html>`__.
158+
For detailed guidance, see `Use the Microsoft C++ toolset from the command line
159+
<https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170>`__.
195160

196-
.. tab-item:: MinGW-w64
197-
198-
There are several sources of binaries for MinGW-w64. We recommend the
199-
RTools versions, which can be installed with Chocolatey (see
200-
Chocolatey install instructions `here <https://chocolatey.org/install>`_)::
201-
202-
choco install rtools -y --no-progress --force --version=4.0.0.20220206
161+
If you don't need ``f2py``, MSVC alone is sufficient. For Fortran compiler
162+
setup (needed for ``f2py``), see :ref:`F2PY and Windows <f2py-windows>`.
203163

204164
.. note::
205165

@@ -208,62 +168,40 @@ your system.
208168
can be found) in order to be found, with the exception of MSVC which
209169
will be found automatically if and only if there are no other compilers
210170
on the ``PATH``. You can use any shell (e.g., Powershell, ``cmd`` or
211-
Git Bash) to invoke a build. To check that this is the case, try
212-
invoking a Fortran compiler in the shell you use (e.g., ``gfortran
213-
--version`` or ``ifort --version``).
171+
Git Bash) to invoke a build.
214172

215173
.. warning::
216174

217175
When using a conda environment it is possible that the environment
218176
creation will not work due to an outdated Fortran compiler. If that
219177
happens, remove the ``compilers`` entry from ``environment.yml`` and
220178
try again. The Fortran compiler should be installed as described in
221-
this section.
179+
the :ref:`F2PY Windows documentation <f2py-windows>`.
222180

223181
.. tab-item:: Windows on ARM64
224182
:sync: Windows on ARM64
225183

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``)
184+
In Windows on ARM64, the compiler options available for building NumPy are
185+
limited. GCC and gfortran are not yet supported. Currently, the NumPy build
186+
for Windows on ARM64 is supported with MSVC and LLVM toolchains.
237187

238188
First, install Microsoft Visual Studio - the 2022 Community Edition will
239189
work (see the `Visual Studio download site <https://visualstudio.microsoft.com/downloads/>`__).
240190
Ensure that you have installed necessary Visual Studio components for building NumPy
241191
on WoA from `here <https://gist.github.com/Mugundanmcw/c3bb93018d5da9311fb2b222f205ba19>`__.
242192

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>`__.
193+
The MSVC installer does not put the compilers on the system path, and
194+
the install location may change. To query the install location, MSVC
195+
comes with a ``vswhere.exe`` command-line utility. And to make the
196+
C/C++ compilers available inside the shell you are using, you need to
197+
run a ``.bat`` file for the correct bitness and architecture (e.g., for
198+
ARM64-based CPUs, use ``vcvarsarm64.bat``).
259199

260-
.. tab-item:: LLVM
200+
For detailed guidance, see `Use the Microsoft C++ toolset from the command line
201+
<https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170>`__.
261202

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``).
203+
If you don't need ``f2py``, MSVC alone is sufficient. For Fortran compiler
204+
setup (needed for ``f2py``), see :ref:`F2PY and Windows <f2py-windows>`.
267205

268206
.. note::
269207

@@ -272,9 +210,7 @@ your system.
272210
can be found) in order to be found, with the exception of MSVC which
273211
will be found automatically if and only if there are no other compilers
274212
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``).
213+
Git Bash) to invoke a build.
278214

279215
.. warning::
280216

0 commit comments

Comments
 (0)