Skip to content

Commit 5d2a4e1

Browse files
authored
Merge pull request #621 from matplotlib/feature-workflow-improvements
Add general improvements to new workflow
2 parents ca2f095 + d762db0 commit 5d2a4e1

File tree

3 files changed

+59
-41
lines changed

3 files changed

+59
-41
lines changed

.github/workflows/build.yml

+10-37
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
matrix:
2323
package: [basemap_data, basemap_data_hires]
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-22.04
2525
steps:
2626
- uses: actions/checkout@v4
2727

@@ -48,35 +48,7 @@ jobs:
4848
needs: [build_data]
4949
strategy:
5050
matrix:
51-
include:
52-
- os: ubuntu-latest
53-
arch: x86_64
54-
before_all: >-
55-
echo "Starting BEFORE_ALL script" &&
56-
echo "GEOS_DIR set to: ${GEOS_DIR}" &&
57-
cd "{package}" &&
58-
python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)"
59-
- os: macos-13
60-
arch: x86_64
61-
before_all: >-
62-
echo "Starting BEFORE_ALL script" &&
63-
echo "GEOS_DIR set to: ${GEOS_DIR}" &&
64-
cd "{package}" &&
65-
python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)"
66-
- os: macos-14
67-
arch: arm64
68-
before_all: >-
69-
echo "Starting BEFORE_ALL script" &&
70-
echo "GEOS_DIR set to: ${GEOS_DIR}" &&
71-
cd "{package}" &&
72-
python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)"
73-
- os: windows-latest
74-
arch: x86_64
75-
before_all: >-
76-
echo Starting BEFORE_ALL script &&
77-
echo GEOS_DIR set to: %GEOS_DIR% &&
78-
cd "{package}" &&
79-
python -c "import utils; utils.GeosLibrary('%GEOS_VERSION%').build('%GEOS_DIR%', njobs=2)"
51+
os: [ubuntu-22.04, windows-2019, macos-13, macos-14]
8052
runs-on: ${{ matrix.os }}
8153
steps:
8254
- uses: actions/checkout@v4
@@ -87,7 +59,7 @@ jobs:
8759
python-version: "3.9"
8860

8961
- name: Build sdist
90-
if: matrix.os == 'ubuntu-latest'
62+
if: matrix.os == 'ubuntu-22.04'
9163
run: |
9264
cd packages/basemap
9365
python -m pip install build
@@ -96,16 +68,17 @@ jobs:
9668
- name: Build wheels
9769
uses: pypa/[email protected]
9870
env:
99-
CIBW_BUILD_VERBOSITY: 1
71+
CIBW_ARCHS: "native"
10072
CIBW_BUILD: "cp39* cp310* cp311* cp312* cp313*"
101-
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
102-
CIBW_SKIP: "pp* *-musllinux_* *-win32 *-manylinux_i686 *-musllinux_i686 *-linux_aarch64 *-linux_armv7l"
103-
CIBW_BEFORE_ALL: ${{ matrix.before_all }}
73+
CIBW_BUILD_VERBOSITY: 1
74+
CIBW_SKIP: "*-musllinux_*"
75+
CIBW_BEFORE_ALL: "python {project}/.github/workflows/run_before_all.py"
10476
CIBW_TEST_EXTRAS: "test"
10577
CIBW_TEST_COMMAND: "python -m pytest {project}/packages/basemap"
10678
CIBW_ENVIRONMENT: >-
10779
GEOS_VERSION="3.6.5"
10880
GEOS_DIR="$(pwd)/extern"
81+
GEOS_NJOBS=4
10982
PIP_PREFER_BINARY=1
11083
PYTHONUNBUFFERED=1
11184
LD_LIBRARY_PATH="${GEOS_DIR}/lib"
@@ -125,7 +98,7 @@ jobs:
12598
check:
12699
name: Check packages
127100
needs: [build_data, build_basemap]
128-
runs-on: ubuntu-latest
101+
runs-on: ubuntu-22.04
129102
steps:
130103
- uses: actions/download-artifact@v4
131104
with:
@@ -147,7 +120,7 @@ jobs:
147120
upload:
148121
name: Upload packages
149122
needs: [build_data, build_basemap, check]
150-
runs-on: ubuntu-latest
123+
runs-on: ubuntu-22.04
151124
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
152125
steps:
153126
- uses: actions/download-artifact@v4

.github/workflows/run_before_all.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#! /usr/bin/env python
2+
"""Helper script to be run by `cibuildwheel` as `before_all` step."""
3+
4+
import os
5+
import sys
6+
7+
HERE = os.path.abspath(__file__)
8+
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
9+
sys.path.insert(0, os.path.join(ROOT, "packages", "basemap"))
10+
import utils # noqa: E402 # pylint: disable=imports
11+
12+
13+
def main():
14+
"""Build the GEOS library based on parsed environment variables."""
15+
16+
geos_version = os.environ.get("GEOS_VERSION", None)
17+
if geos_version is None:
18+
raise ValueError("Undefined environment variable GEOS_VERSION")
19+
20+
geos_dir = os.environ.get("GEOS_DIR", None)
21+
if geos_dir is None:
22+
raise ValueError("Undefined environment variable GEOS_DIR")
23+
24+
geos_njobs = int(os.environ.get("GEOS_NJOBS", 1))
25+
26+
# pylint: disable=consider-using-f-string
27+
print("Running before_all script with the following settings:")
28+
print("GEOS_DIR: {0}".format(geos_dir))
29+
print("GEOS_VERSION: {0}".format(geos_version))
30+
print("GEOS_NJOBS: {0}".format(geos_njobs))
31+
32+
utils.GeosLibrary(geos_version).build(geos_dir, njobs=geos_njobs)
33+
return 0
34+
35+
36+
if __name__ == "__main__":
37+
sys.exit(main())

CHANGELOG.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ https://semver.org/spec/v2.0.0.html
1313
## [Unreleased]
1414

1515
### Added
16-
- Support for Python 3.13 (PR [#619], solves issue [#608]).
17-
- Support for NumPy 2.0 (PR [#614] by @cvanelteren, solves issue
18-
[#604]).
16+
- Python 3.13 support (PR [#619], solves issue [#608]).
17+
- NumPy 2.0 support (PR [#614] by @cvanelteren, solves issue [#604]).
18+
- Automated wheels for x86_64 and arm64 (PR [#620] by @cvanelteren,
19+
solves issue [#608]).
1920

2021
### Changed
2122
- **BREAKING CHANGE**: Set Python minimum supported version to 3.9.
2223
- **BREAKING CHANGE**: Migrate `basemap` libraries to use implicit
2324
namespace packages (PR [#576] by @ksunden).
24-
- Migrate workflows to use `cibuildwheel` (PR [#614] by @cvanelteren).
25+
- Migrate workflows to use `cibuildwheel` (PRs [#614] and [#618] by
26+
@cvanelteren and PR [#621], solves GitHub artifact actions v1 sunset).
2527
- Update library dependencies:
2628
- Upgrade upper limit for `basemap_data` to 3.0.
2729
- Upgrade lower limit for `packaging` to 20.5.
@@ -1154,8 +1156,14 @@ https://semver.org/spec/v2.0.0.html
11541156
- Fix glitches in drawing of parallels and meridians.
11551157

11561158

1159+
[#621]:
1160+
https://github.com/matplotlib/basemap/pull/621
1161+
[#620]:
1162+
https://github.com/matplotlib/basemap/pull/620
11571163
[#619]:
11581164
https://github.com/matplotlib/basemap/pull/619
1165+
[#618]:
1166+
https://github.com/matplotlib/basemap/pull/618
11591167
[#615]:
11601168
https://github.com/matplotlib/basemap/pull/615
11611169
[#614]:

0 commit comments

Comments
 (0)