@@ -151,8 +151,7 @@ def f(x):
151
151
ctx = Context (cython_include_dirs , default_options )
152
152
key = code , sys .version_info , sys .executable , Cython .__version__
153
153
module_name = "_cython_magic_" + hashlib .md5 (str (key ).encode ('utf-8' )).hexdigest ()
154
- so_ext = [ ext for ext ,_ ,mod_type in imp .get_suffixes () if mod_type == imp .C_EXTENSION ][0 ]
155
- module_path = os .path .join (lib_dir , module_name + so_ext )
154
+ module_path = os .path .join (lib_dir , module_name + self .so_ext )
156
155
157
156
if not os .path .exists (lib_dir ):
158
157
os .makedirs (lib_dir )
@@ -173,15 +172,7 @@ def f(x):
173
172
extra_compile_args = args .compile_args ,
174
173
libraries = args .lib ,
175
174
)
176
- dist = Distribution ()
177
- config_files = dist .find_config_files ()
178
- try :
179
- config_files .remove ('setup.cfg' )
180
- except ValueError :
181
- pass
182
- dist .parse_config_files (config_files )
183
- build_extension = build_ext (dist )
184
- build_extension .finalize_options ()
175
+ build_extension = self ._get_build_extension ()
185
176
try :
186
177
build_extension .extensions = cythonize ([extension ], ctx = ctx , quiet = quiet )
187
178
except CompileError :
@@ -194,6 +185,27 @@ def f(x):
194
185
module = imp .load_dynamic (module_name , module_path )
195
186
self ._import_all (module )
196
187
188
+ @property
189
+ def so_ext (self ):
190
+ """The extension suffix for compiled modules."""
191
+ try :
192
+ return self ._so_ext
193
+ except AttributeError :
194
+ self ._so_ext = self ._get_build_extension ().get_ext_filename ('' )
195
+ return self ._so_ext
196
+
197
+ def _get_build_extension (self ):
198
+ dist = Distribution ()
199
+ config_files = dist .find_config_files ()
200
+ try :
201
+ config_files .remove ('setup.cfg' )
202
+ except ValueError :
203
+ pass
204
+ dist .parse_config_files (config_files )
205
+ build_extension = build_ext (dist )
206
+ build_extension .finalize_options ()
207
+ return build_extension
208
+
197
209
198
210
_loaded = False
199
211
0 commit comments