Skip to content

Commit fa8ca92

Browse files
authored
Merge pull request #565 from matplotlib/bugfix-msvc-issue
Ensure that _geoslib is built with MSVC 14.0 for Windows Python3
2 parents 882f739 + bdbc6c8 commit fa8ca92

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

.github/workflows/basemap-for-windows.yml

+25-20
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ jobs:
9393
["x64", "x86"]
9494
msvc-toolset:
9595
["9.0", "14.0"]
96+
include:
97+
- msvc-toolset: "9.0"
98+
python-version: "2.7"
99+
- msvc-toolset: "14.0"
100+
python-version: "3.5"
96101
max-parallel: 4
97102
fail-fast: false
98103
needs: lint
@@ -106,26 +111,26 @@ jobs:
106111
path: .
107112
-
108113
name: Set MSVC toolset
109-
uses: pylegacy/actions/setup-msvc@v1
114+
uses: pylegacy/actions/setup-msvc@v2
110115
with:
111-
architecture: ${{ matrix.arch }}
112-
version: ${{ matrix.msvc-toolset }}
116+
arch: ${{ matrix.arch }}
117+
toolset: ${{ matrix.msvc-toolset }}
113118
-
114119
name: Set CMake
115120
uses: jwlawson/[email protected]
116121
with:
117-
cmake-version: "3.14.7"
122+
cmake-version: "3.24.2"
118123
-
119124
name: Set Python
120125
uses: actions/setup-python@v4
121126
with:
122127
architecture: ${{ matrix.arch }}
123-
python-version: "3.6"
128+
python-version: ${{ matrix.python-version }}
124129
-
125130
name: Build GEOS from source
126131
run: |
127132
cd ${{ env.PKGDIR }}
128-
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern', njobs=16)"
133+
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern', toolset='${{ matrix.msvc-toolset }}', njobs=16)"
129134
-
130135
name: Upload GEOS artifacts
131136
uses: actions/upload-artifact@v1
@@ -151,20 +156,6 @@ jobs:
151156
with:
152157
name: checkout
153158
path: .
154-
-
155-
name: Set MSVC toolset version
156-
run: |
157-
if ("${{ matrix.python-version }}" -eq "2.7") {
158-
echo "msvc-toolset=9.0" >> $env:GITHUB_ENV
159-
} else {
160-
echo "msvc-toolset=14.0" >> $env:GITHUB_ENV
161-
}
162-
-
163-
name: Set MSVC toolset
164-
uses: pylegacy/actions/setup-msvc@v1
165-
with:
166-
architecture: ${{ matrix.arch }}
167-
version: ${{ env.msvc-toolset }}
168159
-
169160
name: Set Python
170161
uses: actions/setup-python@v4
@@ -186,6 +177,20 @@ jobs:
186177
}
187178
$env:SETUPTOOLS_USE_DISTUTILS = "stdlib"
188179
python -m pip install "numpy == ${pkgvers}"
180+
-
181+
name: Set MSVC toolset version
182+
run: |
183+
if ("${{ matrix.python-version }}" -eq "2.7") {
184+
echo "msvc-toolset=9.0" >> $env:GITHUB_ENV
185+
} else {
186+
echo "msvc-toolset=14.0" >> $env:GITHUB_ENV
187+
}
188+
-
189+
name: Set MSVC toolset
190+
uses: pylegacy/actions/setup-msvc@v2
191+
with:
192+
arch: ${{ matrix.arch }}
193+
toolset: ${{ env.msvc-toolset }}
189194
-
190195
name: Download GEOS artifacts
191196
uses: actions/download-artifact@v1

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ https://semver.org/spec/v2.0.0.html
2121
### Changed
2222
- Upgrade bundled GEOS library to 3.6.5.
2323

24+
### Fixed
25+
- Set MSVC 14.0 (VS2015) to build the `_geoslib` module in the
26+
precompiled Windows wheels (PR [#565]).
27+
2428
## [1.3.6] - 2022-10-31
2529

2630
### Added
@@ -32,8 +36,8 @@ https://semver.org/spec/v2.0.0.html
3236
- Upgrade `pyproj` upper pin to 3.5.
3337

3438
### Fixed
35-
- Set MSVC 14.0 (VS2015) to build the precompiled Windows wheels in
36-
GitHub workflows (PR [#564]).
39+
- Set MSVC 14.0 (VS2015) to build the GEOS library bundled in the
40+
precompiled Windows wheels (PR [#564]).
3741

3842
## [1.3.5] - 2022-10-25
3943

@@ -959,6 +963,8 @@ https://semver.org/spec/v2.0.0.html
959963
- Fix glitches in drawing of parallels and meridians.
960964

961965

966+
[#565]:
967+
https://github.com/matplotlib/basemap/pull/565
962968
[#564]:
963969
https://github.com/matplotlib/basemap/pull/564
964970
[#563]:

packages/basemap/utils/GeosLibrary.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,18 @@ def build(self, installdir=None, toolset=None, njobs=1):
242242

243243
# Define custom configure and build options.
244244
if os.name == "nt":
245-
config_opts += ["-DCMAKE_CXX_FLAGS='/wd4251 /wd4458 /wd4530 /EHsc'"]
245+
win64 = (8 * struct.calcsize("P") == 64)
246+
config_opts += ["-DCMAKE_CXX_FLAGS='/wd4251 /wd4355 /wd4458 /wd4530 /EHsc'"]
246247
if version >= (3, 6, 0) and sys.version_info[:2] >= (3, 3):
248+
config_opts = ["-A", "x64" if win64 else "Win32"] + config_opts
247249
if toolset is not None:
248-
config_opts += ["-DCMAKE_GENERATOR_TOOLSET={0}".format(toolset)]
250+
try:
251+
msvc = "v{0:d}".format(int(float(toolset) * 10))
252+
except (TypeError, ValueError):
253+
msvc = toolset
254+
config_opts += ["-DCMAKE_GENERATOR_TOOLSET={0}".format(msvc)]
249255
build_opts = ["-j", "{0:d}".format(njobs)] + build_opts
250256
else:
251-
win64 = (8 * struct.calcsize("P") == 64)
252257
config_opts = ["-G", "NMake Makefiles"] + config_opts
253258
build_opts.extend([
254259
"--",

0 commit comments

Comments
 (0)