From a6bee1f790f4177d5096ae2ab570a3511676f96a Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Sun, 12 Nov 2023 19:49:53 -0500 Subject: [PATCH] Build for Windows Fixes #47. --- .github/workflows/cibuildwheel.yml | 10 +++++++++- README.md | 5 ----- meson.build | 5 +++++ pyproject.toml | 5 +++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 468e258..c359c7e 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -29,7 +29,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v4 @@ -40,10 +40,18 @@ jobs: with: platforms: arm64 + # See https://docs.scipy.org/doc/scipy/building/index.html + - name: Install MinGW + if: runner.os == 'Windows' + run: | + choco install rtools -y --no-progress --force --version=4.0.0.20220206 + echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH + - name: Build wheels uses: pypa/cibuildwheel@v2.16 env: CIBW_ARCHS_LINUX: auto aarch64 + CIBW_ARCHS_WINDOWS: AMD64 CIBW_ENVIRONMENT_MACOS: FC=gfortran-11 # Skip musllinux wheels, which take a long time to build because Numpy must be built from source # Skip PyPy wheels diff --git a/README.md b/README.md index beae404..00022b6 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,6 @@ following articles: * The CCMC IGRF code has spatially varying errors of a few percent, which will result in a striped pattern in the resulting particle flux. -* This package does not support Windows yet. If you are a Windows developer, - then please help us out by contributing a pull request! Meanwhile, if you - need to use this package on Windows, then we recommend using Python under - Linux within Windows Subsystem for Linux (WSL), Docker, or a virtual machine. - See https://github.com/nasa/radbelt/issues/47. [International Geomagnetic Reference Field (IGRF)]: https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html [Astropy]: https://www.astropy.org diff --git a/meson.build b/meson.build index 9507b1f..0af56cf 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,11 @@ add_global_arguments( add_languages('fortran') +is_windows = host_machine.system() == 'windows' +if is_windows + add_project_link_arguments('-lquadmath', language : 'c') +endif + py_mod = import('python') py = py_mod.find_installation(pure: false) diff --git a/pyproject.toml b/pyproject.toml index 1c76555..a987fa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ classifiers = [ "Intended Audience :: Science/Research", "License :: OSI Approved", "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Operating System :: Unix", @@ -40,3 +41,7 @@ test = ["pytest-doctestplus"] [tool.cibuildwheel] test-extras = ["test"] test-command = "pytest --pyargs radbelt --doctest-plus" + +[tool.cibuildwheel.windows] +before-build = "pip install delvewheel" +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}"