diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1f43644..d3fa1c77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: package: [basemap_data, basemap_data_hires] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -48,35 +48,7 @@ jobs: needs: [build_data] strategy: matrix: - include: - - os: ubuntu-latest - arch: x86_64 - before_all: >- - echo "Starting BEFORE_ALL script" && - echo "GEOS_DIR set to: ${GEOS_DIR}" && - cd "{package}" && - python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)" - - os: macos-13 - arch: x86_64 - before_all: >- - echo "Starting BEFORE_ALL script" && - echo "GEOS_DIR set to: ${GEOS_DIR}" && - cd "{package}" && - python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)" - - os: macos-14 - arch: arm64 - before_all: >- - echo "Starting BEFORE_ALL script" && - echo "GEOS_DIR set to: ${GEOS_DIR}" && - cd "{package}" && - python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)" - - os: windows-latest - arch: x86_64 - before_all: >- - echo Starting BEFORE_ALL script && - echo GEOS_DIR set to: %GEOS_DIR% && - cd "{package}" && - python -c "import utils; utils.GeosLibrary('%GEOS_VERSION%').build('%GEOS_DIR%', njobs=2)" + os: [ubuntu-22.04, windows-2019, macos-13, macos-14] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -87,7 +59,7 @@ jobs: python-version: "3.9" - name: Build sdist - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-22.04' run: | cd packages/basemap python -m pip install build @@ -96,16 +68,17 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.22.0 env: - CIBW_BUILD_VERBOSITY: 1 + CIBW_ARCHS: "native" CIBW_BUILD: "cp39* cp310* cp311* cp312* cp313*" - CIBW_ARCHS_MACOS: ${{ matrix.arch }} - CIBW_SKIP: "pp* *-musllinux_* *-win32 *-manylinux_i686 *-musllinux_i686 *-linux_aarch64 *-linux_armv7l" - CIBW_BEFORE_ALL: ${{ matrix.before_all }} + CIBW_BUILD_VERBOSITY: 1 + CIBW_SKIP: "*-musllinux_*" + CIBW_BEFORE_ALL: "python {project}/.github/workflows/run_before_all.py" CIBW_TEST_EXTRAS: "test" CIBW_TEST_COMMAND: "python -m pytest {project}/packages/basemap" CIBW_ENVIRONMENT: >- GEOS_VERSION="3.6.5" GEOS_DIR="$(pwd)/extern" + GEOS_NJOBS=4 PIP_PREFER_BINARY=1 PYTHONUNBUFFERED=1 LD_LIBRARY_PATH="${GEOS_DIR}/lib" @@ -125,7 +98,7 @@ jobs: check: name: Check packages needs: [build_data, build_basemap] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/download-artifact@v4 with: @@ -147,7 +120,7 @@ jobs: upload: name: Upload packages needs: [build_data, build_basemap, check] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/download-artifact@v4 diff --git a/.github/workflows/run_before_all.py b/.github/workflows/run_before_all.py new file mode 100644 index 00000000..575a2676 --- /dev/null +++ b/.github/workflows/run_before_all.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python +"""Helper script to be run by `cibuildwheel` as `before_all` step.""" + +import os +import sys + +HERE = os.path.abspath(__file__) +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) +sys.path.insert(0, os.path.join(ROOT, "packages", "basemap")) +import utils # noqa: E402 # pylint: disable=imports + + +def main(): + """Build the GEOS library based on parsed environment variables.""" + + geos_version = os.environ.get("GEOS_VERSION", None) + if geos_version is None: + raise ValueError("Undefined environment variable GEOS_VERSION") + + geos_dir = os.environ.get("GEOS_DIR", None) + if geos_dir is None: + raise ValueError("Undefined environment variable GEOS_DIR") + + geos_njobs = int(os.environ.get("GEOS_NJOBS", 1)) + + # pylint: disable=consider-using-f-string + print("Running before_all script with the following settings:") + print("GEOS_DIR: {0}".format(geos_dir)) + print("GEOS_VERSION: {0}".format(geos_version)) + print("GEOS_NJOBS: {0}".format(geos_njobs)) + + utils.GeosLibrary(geos_version).build(geos_dir, njobs=geos_njobs) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/CHANGELOG.md b/CHANGELOG.md index 353ffba0..b14c8acd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,15 +13,17 @@ https://semver.org/spec/v2.0.0.html ## [Unreleased] ### Added -- Support for Python 3.13 (PR [#619], solves issue [#608]). -- Support for NumPy 2.0 (PR [#614] by @cvanelteren, solves issue - [#604]). +- Python 3.13 support (PR [#619], solves issue [#608]). +- NumPy 2.0 support (PR [#614] by @cvanelteren, solves issue [#604]). +- Automated wheels for x86_64 and arm64 (PR [#620] by @cvanelteren, + solves issue [#608]). ### Changed - **BREAKING CHANGE**: Set Python minimum supported version to 3.9. - **BREAKING CHANGE**: Migrate `basemap` libraries to use implicit namespace packages (PR [#576] by @ksunden). -- Migrate workflows to use `cibuildwheel` (PR [#614] by @cvanelteren). +- Migrate workflows to use `cibuildwheel` (PRs [#614] and [#618] by + @cvanelteren and PR [#621], solves GitHub artifact actions v1 sunset). - Update library dependencies: - Upgrade upper limit for `basemap_data` to 3.0. - Upgrade lower limit for `packaging` to 20.5. @@ -1154,8 +1156,14 @@ https://semver.org/spec/v2.0.0.html - Fix glitches in drawing of parallels and meridians. +[#621]: +https://github.com/matplotlib/basemap/pull/621 +[#620]: +https://github.com/matplotlib/basemap/pull/620 [#619]: https://github.com/matplotlib/basemap/pull/619 +[#618]: +https://github.com/matplotlib/basemap/pull/618 [#615]: https://github.com/matplotlib/basemap/pull/615 [#614]: