@@ -83,13 +83,11 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False):
83
83
_xbuild = "\" %s\" " % _find_msbuild_tool ("msbuild.exe" )
84
84
_defines_sep = ";"
85
85
_config = "%sWin" % CONFIG
86
- _npython_exe = "nPython.exe"
87
86
88
87
elif DEVTOOLS == "Mono" :
89
88
_xbuild = "xbuild"
90
89
_defines_sep = ","
91
90
_config = "%sMono" % CONFIG
92
- _npython_exe = "npython"
93
91
94
92
else :
95
93
raise NotImplementedError ("DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS )
@@ -131,6 +129,11 @@ def build_extension(self, ext):
131
129
if sys .platform != "win32" and DEVTOOLS == "Mono" :
132
130
defines .append ("MONO_LINUX" )
133
131
132
+ # Check if --enable-shared was set when Python was built
133
+ enable_shared = get_config_var ("Py_ENABLE_SHARED" )
134
+ if enable_shared == 0 :
135
+ defines .append ("PYTHON_WITHOUT_ENABLE_SHARED" )
136
+
134
137
if hasattr (sys , "abiflags" ):
135
138
if "d" in sys .abiflags :
136
139
defines .append ("PYTHON_WITH_PYDEBUG" )
@@ -191,44 +194,6 @@ def _build_monoclr(self, ext):
191
194
192
195
build_ext .build_extension (self , clr_ext )
193
196
194
- # build the clr python executable
195
- sources = [
196
- "src/monoclr/pynetinit.c" ,
197
- "src/monoclr/python.c" ,
198
- ]
199
-
200
- macros = ext .define_macros [:]
201
- for undef in ext .undef_macros :
202
- macros .append ((undef ,))
203
-
204
- objects = self .compiler .compile (sources ,
205
- output_dir = self .build_temp ,
206
- macros = macros ,
207
- include_dirs = ext .include_dirs ,
208
- debug = self .debug ,
209
- extra_postargs = cflags .split (" " ),
210
- depends = ext .depends )
211
-
212
- output_dir = os .path .dirname (self .get_ext_fullpath (ext .name ))
213
- py_libs = get_config_var ("BLDLIBRARY" )
214
- libs += " " + py_libs
215
-
216
- # Include the directories python's shared libs were installed to. This
217
- # is case python was built with --enable-shared as then npython will need
218
- # to be able to find libpythonX.X.so.
219
- runtime_library_dirs = (get_config_var ("DESTDIRS" ) or "" ).split (" " )
220
- if ext .runtime_library_dirs :
221
- runtime_library_dirs .extend (ext .runtime_library_dirs )
222
-
223
- self .compiler .link_executable (objects ,
224
- _npython_exe ,
225
- output_dir = output_dir ,
226
- libraries = self .get_libraries (ext ),
227
- library_dirs = ext .library_dirs ,
228
- runtime_library_dirs = runtime_library_dirs ,
229
- extra_postargs = libs .split (" " ),
230
- debug = self .debug )
231
-
232
197
233
198
def _install_packages (self ):
234
199
"""install packages using nuget"""
@@ -261,77 +226,6 @@ def install(self):
261
226
self .copy_file (srcfile , destfile )
262
227
263
228
264
- class PythonNET_BuildScripts (build_scripts ):
265
-
266
- def finalize_options (self ):
267
- build_scripts .finalize_options (self )
268
-
269
- # fixup scripts to look in the build_ext output folder
270
- if self .scripts :
271
- build_ext = self .get_finalized_command ("build_ext" )
272
- output_dir = os .path .dirname (build_ext .get_ext_fullpath ("clr" ))
273
- scripts = []
274
- for script in self .scripts :
275
- if os .path .exists (os .path .join (output_dir , script )):
276
- script = os .path .join (output_dir , script )
277
- scripts .append (script )
278
- self .scripts = scripts
279
-
280
- def copy_scripts (self ):
281
- # Look for the npython script as it can't be copied by the base class'
282
- # copy_scripts as it attempts to determine the file encoding as if it
283
- # were a text file.
284
- npython = None
285
- for script in self .scripts :
286
- if os .path .basename (script ) == _npython_exe :
287
- npython = script
288
-
289
- if npython is None :
290
- return build_scripts .copy_scripts (self )
291
-
292
- # Call the base class copy_scripts with anything other than npython
293
- scripts = self .scripts
294
- self .scripts = [x for x in scripts if x != npython ]
295
- try :
296
- base_result = build_scripts .copy_scripts (self )
297
- finally :
298
- self .scripts = scripts
299
-
300
- # Copy npython
301
- outfiles = []
302
- updated_files = []
303
-
304
- script = convert_path (npython )
305
- outfile = os .path .join (self .build_dir , os .path .basename (script ))
306
- outfiles .append (outfile )
307
-
308
- if not self .force and not newer (script , outfile ):
309
- log .debug ("not copying %s (up-to-date)" , script )
310
- else :
311
- updated_files .append (outfile )
312
- self .copy_file (script , outfile )
313
-
314
- if os .name == 'posix' :
315
- for file in outfiles :
316
- if self .dry_run :
317
- log .info ("changing mode of %s" , file )
318
- else :
319
- oldmode = os .stat (file )[stat .ST_MODE ] & 0o7777
320
- newmode = (oldmode | 0o555 ) & 0o7777
321
- if newmode != oldmode :
322
- log .info ("changing mode of %s from %o to %o" ,
323
- file , oldmode , newmode )
324
- os .chmod (file , newmode )
325
-
326
- # Some versions of build_command.copy_scripts return (outfiles, updated_files),
327
- # older versions return None.
328
- if base_result is not None :
329
- base_outfiles , base_updated_files = base_result
330
- outfiles .extend (base_outfiles )
331
- updated_files .extend (base_updated_files )
332
- return outfiles , updated_files
333
-
334
-
335
229
def _check_output (* popenargs , ** kwargs ):
336
230
"""subprocess.check_output from python 2.7.
337
231
Added here to support building for earlier versions
@@ -363,11 +257,9 @@ def _check_output(*popenargs, **kwargs):
363
257
ext_modules = [
364
258
Extension ("clr" , sources = [])
365
259
],
366
- scripts = [_npython_exe ],
367
260
zip_safe = False ,
368
261
cmdclass = {
369
262
"build_ext" : PythonNET_BuildExt ,
370
- "build_scripts" : PythonNET_BuildScripts ,
371
263
"install_lib" : PythonNET_InstallLib ,
372
264
}
373
265
)
0 commit comments