From 3b5334551a16dad4751e77a2ba132b84a2c6c3f1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 28 Apr 2025 14:16:58 -0400 Subject: [PATCH 01/10] ci: try to add Windows Fortran Signed-off-by: Henry Schreiner --- .github/workflows/ci.yml | 5 +---- noxfile.py | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3611056..371f06e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,11 +30,8 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: awvwgk/setup-fortran@main + - uses: fortran-lang/setup-fortran@v1 id: setup-fortran - if: runner.os != 'Windows' - # We aren't using this yet, and takes 4 mins to setup on Windows - # On macOS this causes a bug to be hit on macos-13+ and CMake, gcc14 may fix with: compiler: gcc version: 12 diff --git a/noxfile.py b/noxfile.py index 422f53c..749b158 100644 --- a/noxfile.py +++ b/noxfile.py @@ -11,9 +11,8 @@ "hello-pybind11", "hello-cython", "hello-cmake-package", + "pi-fortran", ] -if not sys.platform.startswith("win"): - hello_list.append("pi-fortran") long_hello_list = [ *hello_list, "pen2-cython", From a1de1fe4484f14635982b27d1bb2fa0729fbb7f7 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 12:30:42 -0400 Subject: [PATCH 02/10] fix(pi-fortran): use GNU toolchain on Windows so gfortran is found scikit-build-core builds with Ninja on Windows, where CMake auto-detects MSVC for C. MSVC has no Fortran compiler, so the gfortran from setup-fortran was never used and configure failed with 'No CMAKE_Fortran_COMPILER could be found'. Force the full GNU toolchain on Windows via a scikit-build-core override. Assisted-by: ClaudeCode:claude-opus-4.8 --- projects/pi-fortran/pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/pi-fortran/pyproject.toml b/projects/pi-fortran/pyproject.toml index 7b3521d..2c82313 100644 --- a/projects/pi-fortran/pyproject.toml +++ b/projects/pi-fortran/pyproject.toml @@ -14,3 +14,11 @@ dependencies = ["numpy>=1.21"] [tool.scikit-build] ninja.version = ">=1.10" cmake.version = ">=3.17.2" + +# On Windows scikit-build-core defaults to the MSVC toolchain, which has no +# Fortran compiler. Force the full GNU toolchain so the gfortran from +# setup-fortran is used (this also stops MSVC auto-activation). +[[tool.scikit-build.overrides]] +if.platform-system = "win32" +cmake.define.CMAKE_C_COMPILER = "gcc" +cmake.define.CMAKE_Fortran_COMPILER = "gfortran" From 4f748d9c0e2e6bd1a3146d45a76d8cb08b8e4e17 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 13:21:09 -0400 Subject: [PATCH 03/10] ci: put MinGW on PATH so Windows finds gfortran setup-fortran installs MinGW via choco, which only edits the persistent machine PATH; GitHub Actions does not reload that into the running job, so gcc/gfortran were absent from PATH and CMake could not find the Fortran compiler (C silently fell back to MSVC). Add the MinGW bin directory to GITHUB_PATH on Windows. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 371f06e..685e1c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,15 @@ jobs: with: compiler: gcc version: 12 + # setup-fortran installs MinGW via choco, which only edits the machine + # PATH registry; GitHub Actions doesn't reload that into the running job, + # so gcc/gfortran aren't found. Put the bin dir on PATH for later steps. + - name: Add MinGW to PATH (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $gfortran = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1 + Split-Path $gfortran.FullName | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 - uses: astral-sh/setup-uv@v8.0.0 - run: uvx nox -s ${{ matrix.session }} From 5c107d613e0e3509aba8a1c9875af3ed3d8f45d1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 13:53:20 -0400 Subject: [PATCH 04/10] ci: point CMake at MinGW compilers by full path on Windows The GITHUB_PATH addition alone did not let CMake find bare gfortran, so set CC/CXX/FC to absolute compiler paths (independent of PATH) and drop the now-redundant pi-fortran override. Keep the bin dir on PATH for the runtime DLLs and add a diagnostic step. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 22 ++++++++++++++++++---- projects/pi-fortran/pyproject.toml | 8 -------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 685e1c6..ab95ef0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,13 +37,27 @@ jobs: version: 12 # setup-fortran installs MinGW via choco, which only edits the machine # PATH registry; GitHub Actions doesn't reload that into the running job, - # so gcc/gfortran aren't found. Put the bin dir on PATH for later steps. - - name: Add MinGW to PATH (Windows) + # so gcc/gfortran aren't found. Point CMake at the compilers by full path + # (CC/CXX/FC) and add the bin dir to PATH for the runtime DLLs. + - name: Set up MinGW Fortran (Windows) if: runner.os == 'Windows' shell: pwsh run: | - $gfortran = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1 - Split-Path $gfortran.FullName | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 + $bin = Split-Path (Get-ChildItem C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1).FullName + Write-Host "MinGW bin: $bin" + $fwd = $bin -replace '\\','/' + "$bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 + "FC=$fwd/gfortran.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + "CC=$fwd/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + "CXX=$fwd/g++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + - name: Diagnose Fortran (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + Write-Host "FC=$env:FC" + Write-Host "PATH=$env:PATH" + where.exe gfortran + & "$env:FC" --version - uses: astral-sh/setup-uv@v8.0.0 - run: uvx nox -s ${{ matrix.session }} diff --git a/projects/pi-fortran/pyproject.toml b/projects/pi-fortran/pyproject.toml index 2c82313..7b3521d 100644 --- a/projects/pi-fortran/pyproject.toml +++ b/projects/pi-fortran/pyproject.toml @@ -14,11 +14,3 @@ dependencies = ["numpy>=1.21"] [tool.scikit-build] ninja.version = ">=1.10" cmake.version = ">=3.17.2" - -# On Windows scikit-build-core defaults to the MSVC toolchain, which has no -# Fortran compiler. Force the full GNU toolchain so the gfortran from -# setup-fortran is used (this also stops MSVC auto-activation). -[[tool.scikit-build.overrides]] -if.platform-system = "win32" -cmake.define.CMAKE_C_COMPILER = "gcc" -cmake.define.CMAKE_Fortran_COMPILER = "gfortran" From 9687c7a2fe8c2de9e310b66547bf70c5d15aa88c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 14:07:04 -0400 Subject: [PATCH 05/10] ci: force MinGW toolchain via CMAKE_ARGS on Windows CC/FC env vars set by setup-fortran are not honored through the uv build chain (CMake kept selecting MSVC and missing gfortran), but -D defines passed via CMAKE_ARGS reach cmake authoritatively. Set full-path CMAKE_C_COMPILER/CMAKE_Fortran_COMPILER there; drop the diagnostic step. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab95ef0..d0f0808 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,11 @@ jobs: with: compiler: gcc version: 12 - # setup-fortran installs MinGW via choco, which only edits the machine - # PATH registry; GitHub Actions doesn't reload that into the running job, - # so gcc/gfortran aren't found. Point CMake at the compilers by full path - # (CC/CXX/FC) and add the bin dir to PATH for the runtime DLLs. + # setup-fortran installs MinGW via choco. The CC/FC env vars it sets are + # not honored through the uv build chain (CMake still picks MSVC), so force + # the GNU toolchain via CMAKE_ARGS, which scikit-build-core passes straight + # to cmake as -D defines. Full paths avoid depending on PATH; the bin dir is + # still added to PATH for the runtime DLLs. - name: Set up MinGW Fortran (Windows) if: runner.os == 'Windows' shell: pwsh @@ -46,18 +47,8 @@ jobs: $bin = Split-Path (Get-ChildItem C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1).FullName Write-Host "MinGW bin: $bin" $fwd = $bin -replace '\\','/' - "$bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 - "FC=$fwd/gfortran.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - "CC=$fwd/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - "CXX=$fwd/g++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - - name: Diagnose Fortran (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - Write-Host "FC=$env:FC" - Write-Host "PATH=$env:PATH" - where.exe gfortran - & "$env:FC" --version + "$bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 + "CMAKE_ARGS=-DCMAKE_C_COMPILER=$fwd/gcc.exe -DCMAKE_Fortran_COMPILER=$fwd/gfortran.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - uses: astral-sh/setup-uv@v8.0.0 - run: uvx nox -s ${{ matrix.session }} From 224e391f8bb17e72cb190ae7c24a7530e2f2c791 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 14:20:18 -0400 Subject: [PATCH 06/10] ci: force Ninja + MinGW for pi-fortran on Windows The Windows runners preset CMAKE_GENERATOR to Visual Studio, which has no Fortran support: it ignored CMAKE_C_COMPILER (C stayed MSVC) and drove gfortran through devenv/.sln, which cannot compile Fortran. Scope a Ninja generator and the MinGW C/Fortran compilers to the pi-fortran nox session so the MSVC-based projects keep using Visual Studio. CI just puts the MinGW bin on PATH for the noxfile lookup. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 12 ++++-------- noxfile.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0f0808..af4473b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,20 +35,16 @@ jobs: with: compiler: gcc version: 12 - # setup-fortran installs MinGW via choco. The CC/FC env vars it sets are - # not honored through the uv build chain (CMake still picks MSVC), so force - # the GNU toolchain via CMAKE_ARGS, which scikit-build-core passes straight - # to cmake as -D defines. Full paths avoid depending on PATH; the bin dir is - # still added to PATH for the runtime DLLs. - - name: Set up MinGW Fortran (Windows) + # setup-fortran installs MinGW via choco, which only edits the machine PATH + # registry; GitHub Actions doesn't reload that into the running job. Put the + # bin dir on PATH so the build (and noxfile compiler lookup) can find it. + - name: Add MinGW to PATH (Windows) if: runner.os == 'Windows' shell: pwsh run: | $bin = Split-Path (Get-ChildItem C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1).FullName Write-Host "MinGW bin: $bin" - $fwd = $bin -replace '\\','/' "$bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 - "CMAKE_ARGS=-DCMAKE_C_COMPILER=$fwd/gcc.exe -DCMAKE_Fortran_COMPILER=$fwd/gfortran.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - uses: astral-sh/setup-uv@v8.0.0 - run: uvx nox -s ${{ matrix.session }} diff --git a/noxfile.py b/noxfile.py index 749b158..7efd4f8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,4 @@ +import shutil import sys import nox @@ -5,6 +6,29 @@ nox.needs_version = ">=2024.4.15" nox.options.default_venv_backend = "uv|virtualenv" + +def _fortran_env(module: str) -> dict[str, str] | None: + """Build environment for a module, if it needs special handling. + + The Windows runners preset CMAKE_GENERATOR to Visual Studio, which has no + Fortran support, so pi-fortran must use Ninja with the MinGW compilers (put + on PATH by the CI workflow). Returns None when no overrides are needed. + """ + if module != "pi-fortran" or not sys.platform.startswith("win"): + return None + gcc = shutil.which("gcc") + gfortran = shutil.which("gfortran") + if not (gcc and gfortran): + return None + return { + "CMAKE_GENERATOR": "Ninja", + "CMAKE_ARGS": ( + f"-DCMAKE_C_COMPILER={gcc.replace(chr(92), '/')} " + f"-DCMAKE_Fortran_COMPILER={gfortran.replace(chr(92), '/')}" + ), + } + + hello_list = [ "hello-pure", "hello-cpp", @@ -32,7 +56,7 @@ def dist(session: nox.Session, module: str) -> None: # Builds SDist and wheel opt = ["--installer=uv"] if session.venv_backend == "uv" else [] - session.run("python", "-m", "build", *opt) + session.run("python", "-m", "build", *opt, env=_fortran_env(module)) @nox.session @@ -41,5 +65,5 @@ def test(session: nox.Session, module: str) -> None: session.cd(f"projects/{module}") session.install("pytest", "pytest-cov") - session.install(".") + session.install(".", env=_fortran_env(module)) session.run("pytest") From 0e3240d51f3ccb71e197213c7cd43338db705e8a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 14:34:08 -0400 Subject: [PATCH 07/10] fix(pi-fortran): normalize f2py include path for Windows numpy.f2py.get_include() returns a backslash path on Windows; passing it into python_add_library made FindPython re-parse it as cmake code and fail with 'Invalid character escape'. Convert it with file(TO_CMAKE_PATH). Assisted-by: ClaudeCode:claude-opus-4.8 --- projects/pi-fortran/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/pi-fortran/CMakeLists.txt b/projects/pi-fortran/CMakeLists.txt index b04d74a..4db43a4 100644 --- a/projects/pi-fortran/CMakeLists.txt +++ b/projects/pi-fortran/CMakeLists.txt @@ -15,6 +15,8 @@ execute_process( OUTPUT_VARIABLE F2PY_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) +# On Windows the path comes back with backslashes, which CMake reads as escapes. +file(TO_CMAKE_PATH "${F2PY_INCLUDE_DIR}" F2PY_INCLUDE_DIR) set(f2py_module_name "pi") set(fortran_src_file "${CMAKE_SOURCE_DIR}/pi/_pi.f") From c44f5f4d1b71dd35159b79a8a59f391edc7cb236 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 16:22:57 -0400 Subject: [PATCH 08/10] fix(pi-fortran): statically link GNU runtime on Windows The MinGW-built module failed to import (DLL load failed) because its libgfortran/libgcc/libwinpthread dependencies were not found; Python 3.8+ ignores PATH for extension DLL resolution. Link the GNU runtime statically so the module is self-contained. Assisted-by: ClaudeCode:claude-opus-4.8 --- projects/pi-fortran/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/pi-fortran/CMakeLists.txt b/projects/pi-fortran/CMakeLists.txt index 4db43a4..70d6b01 100644 --- a/projects/pi-fortran/CMakeLists.txt +++ b/projects/pi-fortran/CMakeLists.txt @@ -43,4 +43,10 @@ target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Python::NumPy) +# With the MinGW toolchain (Windows), statically link the GNU runtime so the +# module has no external libgfortran/libgcc/libwinpthread DLL dependencies. +if(WIN32 AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + target_link_options(${CMAKE_PROJECT_NAME} PRIVATE -static) +endif() + install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION pi) From 4d49276208cbd3408c29cbeeeb64b9a90ba0f295 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 17:30:43 -0400 Subject: [PATCH 09/10] ci: tidy Windows Fortran setup Drop the debug Write-Host and simplify the noxfile compiler-path handling. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 1 - noxfile.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af4473b..b89359f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: shell: pwsh run: | $bin = Split-Path (Get-ChildItem C:\ProgramData\chocolatey\lib\mingw -Recurse -Filter gfortran.exe | Select-Object -First 1).FullName - Write-Host "MinGW bin: $bin" "$bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 - uses: astral-sh/setup-uv@v8.0.0 - run: uvx nox -s ${{ matrix.session }} diff --git a/noxfile.py b/noxfile.py index 7efd4f8..b361a63 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,12 +20,12 @@ def _fortran_env(module: str) -> dict[str, str] | None: gfortran = shutil.which("gfortran") if not (gcc and gfortran): return None + # Forward slashes: backslashes would be read as escapes in CMAKE_ARGS. + gcc = gcc.replace("\\", "/") + gfortran = gfortran.replace("\\", "/") return { "CMAKE_GENERATOR": "Ninja", - "CMAKE_ARGS": ( - f"-DCMAKE_C_COMPILER={gcc.replace(chr(92), '/')} " - f"-DCMAKE_Fortran_COMPILER={gfortran.replace(chr(92), '/')}" - ), + "CMAKE_ARGS": f"-DCMAKE_C_COMPILER={gcc} -DCMAKE_Fortran_COMPILER={gfortran}", } From b48e18724d3923c4ec45e23129a49573ef74b1b8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Jun 2026 18:35:24 -0400 Subject: [PATCH 10/10] refactor(pi-fortran): move Windows toolchain into pyproject override scikit-build-core detects -GNinja from cmake.args and overrides support platform-system conditions, so the generator + MinGW compiler selection moves into pi-fortran's pyproject.toml. This reverts the noxfile env plumbing; CI still adds MinGW to PATH so the bare compilers resolve. Assisted-by: ClaudeCode:claude-opus-4.8 --- .github/workflows/ci.yml | 2 +- noxfile.py | 28 ++-------------------------- projects/pi-fortran/pyproject.toml | 9 +++++++++ 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b89359f..3a496c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: version: 12 # setup-fortran installs MinGW via choco, which only edits the machine PATH # registry; GitHub Actions doesn't reload that into the running job. Put the - # bin dir on PATH so the build (and noxfile compiler lookup) can find it. + # bin dir on PATH so CMake can find gcc/gfortran (see pi-fortran override). - name: Add MinGW to PATH (Windows) if: runner.os == 'Windows' shell: pwsh diff --git a/noxfile.py b/noxfile.py index b361a63..749b158 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,3 @@ -import shutil import sys import nox @@ -6,29 +5,6 @@ nox.needs_version = ">=2024.4.15" nox.options.default_venv_backend = "uv|virtualenv" - -def _fortran_env(module: str) -> dict[str, str] | None: - """Build environment for a module, if it needs special handling. - - The Windows runners preset CMAKE_GENERATOR to Visual Studio, which has no - Fortran support, so pi-fortran must use Ninja with the MinGW compilers (put - on PATH by the CI workflow). Returns None when no overrides are needed. - """ - if module != "pi-fortran" or not sys.platform.startswith("win"): - return None - gcc = shutil.which("gcc") - gfortran = shutil.which("gfortran") - if not (gcc and gfortran): - return None - # Forward slashes: backslashes would be read as escapes in CMAKE_ARGS. - gcc = gcc.replace("\\", "/") - gfortran = gfortran.replace("\\", "/") - return { - "CMAKE_GENERATOR": "Ninja", - "CMAKE_ARGS": f"-DCMAKE_C_COMPILER={gcc} -DCMAKE_Fortran_COMPILER={gfortran}", - } - - hello_list = [ "hello-pure", "hello-cpp", @@ -56,7 +32,7 @@ def dist(session: nox.Session, module: str) -> None: # Builds SDist and wheel opt = ["--installer=uv"] if session.venv_backend == "uv" else [] - session.run("python", "-m", "build", *opt, env=_fortran_env(module)) + session.run("python", "-m", "build", *opt) @nox.session @@ -65,5 +41,5 @@ def test(session: nox.Session, module: str) -> None: session.cd(f"projects/{module}") session.install("pytest", "pytest-cov") - session.install(".", env=_fortran_env(module)) + session.install(".") session.run("pytest") diff --git a/projects/pi-fortran/pyproject.toml b/projects/pi-fortran/pyproject.toml index 7b3521d..c450f6a 100644 --- a/projects/pi-fortran/pyproject.toml +++ b/projects/pi-fortran/pyproject.toml @@ -14,3 +14,12 @@ dependencies = ["numpy>=1.21"] [tool.scikit-build] ninja.version = ">=1.10" cmake.version = ">=3.17.2" + +# Windows defaults to the Visual Studio generator, which has no Fortran support +# and ignores compiler overrides. Use Ninja with the MinGW toolchain instead +# (gcc and gfortran must be on PATH). +[[tool.scikit-build.overrides]] +if.platform-system = "win32" +cmake.args = ["-GNinja"] +cmake.define.CMAKE_C_COMPILER = "gcc" +cmake.define.CMAKE_Fortran_COMPILER = "gfortran"