Skip to content

Commit fecc9a0

Browse files
committed
Add njobs argument to GeosLibrary.build
1 parent 2d1f06d commit fecc9a0

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ jobs:
5555
set -e
5656
. /etc/profile
5757
cd ${{ env.PKGDIR }}
58-
export MAKEFLAGS="-j 16"
59-
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern')"
58+
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern', njobs=16)"
6059
-
6160
name: Upload GEOS artifacts
6261
uses: actions/upload-artifact@v1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
name: Build GEOS from source
4444
run: |
4545
cd ${{ env.PKGDIR }}
46-
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern')"
46+
python -c "import utils; utils.GeosLibrary('3.6.5').build('extern', njobs=16)"
4747
-
4848
name: Upload GEOS artifacts
4949
uses: actions/upload-artifact@v1

packages/basemap/utils/GeosLibrary.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def extract(self, overwrite=True):
139139
for line in lines:
140140
fd.write(line.replace(oldtext, newtext).encode())
141141

142-
def build(self, installdir=None):
142+
def build(self, installdir=None, njobs=1):
143143
"""Build and install GEOS from source."""
144144

145145
# Download and extract zip file if not present.
@@ -165,6 +165,17 @@ def build(self, installdir=None):
165165
else:
166166
config_opts.append("-DCMAKE_BUILD_TYPE=Release")
167167

168+
# Define build options.
169+
build_env = os.environ.copy()
170+
build_opts = [
171+
"--config", "Release",
172+
"--target", "install",
173+
]
174+
if os.name == "nt":
175+
build_opts = ["-j", "{0:d}".format(njobs)] + build_opts
176+
else:
177+
build_env["MAKEFLAGS"] = "-j {0:d}".format(njobs)
178+
168179
# Now move to the GEOS source code folder and build with CMake.
169180
cwd = os.getcwd()
170181
try:
@@ -182,9 +193,7 @@ def build(self, installdir=None):
182193
except OSError:
183194
pass
184195
# Call cmake build and install.
185-
subprocess.call(["cmake",
186-
"--build", ".",
187-
"--config", "Release",
188-
"--target", "install"])
196+
subprocess.call(["cmake", "--build", "."] + build_opts,
197+
env=build_env)
189198
finally:
190199
os.chdir(cwd)

0 commit comments

Comments
 (0)