23
23
import ssl
24
24
import glob
25
25
import shutil
26
+ import struct
26
27
import tempfile
27
28
import contextlib
28
29
import subprocess
@@ -44,7 +45,8 @@ class GeosLibrary(object):
44
45
def __init__ (self , version , root = None ):
45
46
"""Initialise a new :class:`GeosLibrary` instance."""
46
47
47
- self .version = version
48
+ self .version_tuple = tuple (map (int , version .split ("." )))
49
+
48
50
if root is None :
49
51
self .temp = True
50
52
self .root = tempfile .mkdtemp (prefix = "tmp_geoslibrary_" )
@@ -65,6 +67,12 @@ def __del__(self):
65
67
except OSError :
66
68
pass
67
69
70
+ @property
71
+ def version (self ):
72
+ """GEOS library version in string format."""
73
+
74
+ return "." .join (map (str , self .version_tuple ))
75
+
68
76
def download (self ):
69
77
"""Download GEOS zip source code into :class:`GeosLibrary` root."""
70
78
@@ -141,7 +149,7 @@ def extract(self, overwrite=True):
141
149
142
150
# The SVN revision file is not created on the fly before 3.6.0.
143
151
svn_hfile = os .path .join (zipfold , "geos_svn_revision.h" )
144
- if not os .path .exists (svn_hfile ):
152
+ if self . version_tuple < ( 3 , 6 , 0 ) and not os .path .exists (svn_hfile ):
145
153
with io .open (svn_hfile , "wb" ) as fd :
146
154
text = "#define GEOS_SVN_REVISION 0"
147
155
fd .write (text .encode ())
@@ -168,17 +176,26 @@ def build(self, installdir=None, njobs=1):
168
176
]
169
177
if os .name != "nt" :
170
178
config_opts .append ("-DCMAKE_BUILD_TYPE=Release" )
179
+ elif self .version_tuple < (3 , 6 , 0 ):
180
+ config_opts = ["-G" , "NMake Makefiles" ] + config_opts
171
181
172
182
# Define build options.
173
183
build_env = os .environ .copy ()
174
184
build_opts = [
175
185
"--config" , "Release" ,
176
186
"--target" , "install" ,
177
187
]
178
- if os .name == "nt" :
179
- build_opts = ["-j" , "{0:d}" .format (njobs )] + build_opts
180
- else :
188
+ if os .name != "nt" :
181
189
build_env ["MAKEFLAGS" ] = "-j {0:d}" .format (njobs )
190
+ elif self .version_tuple < (3 , 6 , 0 ):
191
+ win64 = (8 * struct .calcsize ("P" ) == 64 )
192
+ build_opts .extend ([
193
+ "--" ,
194
+ "WIN64={0}" .format ("YES" if win64 else "NO" ),
195
+ "BUILD_BATCH={0}" .format ("YES" if njobs > 1 else "NO" )
196
+ ])
197
+ else :
198
+ build_opts = ["-j" , "{0:d}" .format (njobs )] + build_opts
182
199
183
200
# Now move to the GEOS source code folder and build with CMake.
184
201
cwd = os .getcwd ()
0 commit comments