|
20 | 20 |
|
21 | 21 | import io
|
22 | 22 | import os
|
| 23 | +import sys |
23 | 24 | import ssl
|
24 | 25 | import glob
|
25 | 26 | import shutil
|
@@ -126,8 +127,7 @@ def extract(self, overwrite=True):
|
126 | 127 | if os.path.exists(zipfold):
|
127 | 128 | if not overwrite:
|
128 | 129 | raise OSError("folder '{0}' already exists".format(zipfold))
|
129 |
| - else: |
130 |
| - shutil.rmtree(zipfold) |
| 130 | + shutil.rmtree(zipfold) |
131 | 131 |
|
132 | 132 | # Decompress zip file.
|
133 | 133 | with contextlib.closing(ZipFile(zippath, "r")) as fd:
|
@@ -156,6 +156,27 @@ def extract(self, overwrite=True):
|
156 | 156 | for line in lines:
|
157 | 157 | fd.write(line.replace(oldtext, newtext).encode())
|
158 | 158 |
|
| 159 | + # Apply specific patches for 3.6.0 <= GEOS < 3.7.0 on Windows. |
| 160 | + if (3, 6, 0) <= self.version_tuple < (3, 7, 0) and os.name == "nt": |
| 161 | + autogen_file = os.path.join(zipfold, "autogen.bat") |
| 162 | + subprocess.call([autogen_file], cwd=zipfold) |
| 163 | + cppfile = os.path.join(zipfold, "src", "geomgraph", "DirectedEdgeStar.cpp") |
| 164 | + with io.open(cppfile, "r", encoding="utf-8") as fd: |
| 165 | + lines = fd.readlines() |
| 166 | + with io.open(cppfile, "wb") as fd: |
| 167 | + oldtext = "DirectedEdgeStar::print() const" |
| 168 | + newtext = oldtext.replace(" const", "") |
| 169 | + for line in lines: |
| 170 | + fd.write(line.replace(oldtext, newtext).encode()) |
| 171 | + hfile = os.path.join(zipfold, "include", "geos", "geomgraph", "DirectedEdgeStar.h") |
| 172 | + with io.open(hfile, "r", encoding="utf-8") as fd: |
| 173 | + lines = fd.readlines() |
| 174 | + with io.open(hfile, "wb") as fd: |
| 175 | + oldtext = "virtual std::string print() const;" |
| 176 | + newtext = oldtext.replace(" const", "") |
| 177 | + for line in lines: |
| 178 | + fd.write(line.replace(oldtext, newtext).encode()) |
| 179 | + |
159 | 180 | # Patch CMakeLists to link shared geos_c with static geos.
|
160 | 181 | if self.version_tuple < (3, 8, 0):
|
161 | 182 | cmakefile = os.path.join(zipfold, "capi", "CMakeLists.txt")
|
@@ -221,16 +242,17 @@ def build(self, installdir=None, njobs=1):
|
221 | 242 |
|
222 | 243 | # Define custom configure and build options.
|
223 | 244 | if os.name == "nt":
|
224 |
| - if version < (3, 6, 0): |
| 245 | + if version >= (3, 6, 0) and sys.version_info[:2] >= (3, 3): |
| 246 | + build_opts = ["-j", "{0:d}".format(njobs)] + build_opts |
| 247 | + else: |
225 | 248 | win64 = (8 * struct.calcsize("P") == 64)
|
226 | 249 | config_opts = ["-G", "NMake Makefiles"] + config_opts
|
227 | 250 | build_opts.extend([
|
228 | 251 | "--",
|
229 | 252 | "WIN64={0}".format("YES" if win64 else "NO"),
|
230 | 253 | "BUILD_BATCH={0}".format("YES" if njobs > 1 else "NO"),
|
| 254 | + "MSVC_VER=1400", |
231 | 255 | ])
|
232 |
| - else: |
233 |
| - build_opts = ["-j", "{0:d}".format(njobs)] + build_opts |
234 | 256 | else:
|
235 | 257 | build_env["MAKEFLAGS"] = "-j {0:d}".format(njobs)
|
236 | 258 | if version >= (3, 7, 0):
|
|
0 commit comments