def initialize_tools(env): from SCons.Tool import FindTool if sys.platform == "win32": if is_python_win64(): env["ICC_ABI"] = "amd64" env["IFORT_ABI"] = "amd64" # Initialize CC tool from distutils info initialize_cc(env) # Initialize F77 tool from distutils info initialize_f77(env) # Initialize CXX tool from distutils info initialize_cxx(env) # Adding default tools for the one we do not customize: mingw is special # according to scons, don't ask me why, but this does not work as expected # for this tool. if not built_with_mingw(env): for i in [DEF_LINKERS, DEF_ASSEMBLERS, DEF_ARS]: t = FindTool(i, env) or i[0] env.Tool(t) else: try: t = FindTool(['g++'], env) #env['LINK'] = None except EnvironmentError: raise RuntimeError('g++ not found: this is necessary with mingw32 '\ 'to build numpy !') # Set ALLOW_UNDEFINED link flags to allow undefined symbols in dynamic # libraries initialize_allow_undefined(env) # Use our own stupid link, because we handle this with conf checkers and # link flags. env['SMARTLINK'] = dumb_link
def _customize_pyext_win32(env, pyext_tool): from SCons.Action import Action from SCons.Node.FS import default_fs env.PrependUnique(LIBPATH = get_pythonlib_dir()) def dummy(target, source, env): return target, source def pyext_runtime(target = None, source = None, env = None): # Action to handle msvc runtime problem with fortran/mingw: normally, # when we link a python extension with mingw, we need to add the msvc # runtime. BUT, if the extensions uses fortran, we should not. # XXX: Is action the right way to do that ? snodes = [default_fs.Entry(s) for s in source] if isfortran(env, snodes) or isf2py(env, snodes): env["PYEXTRUNTIME"] = [get_pythonlib_name()] else: env["PYEXTRUNTIME"] = [get_pythonlib_name(), msvc_runtime_library()] return 0 # We override the default emitter here because SHLIB emitter # does a lot of checks we don't care about and are wrong # anyway for python extensions. env["BUILDERS"]["PythonExtension"].emitter = dummy if built_with_mingw(env): # We are overriding pyext coms here. # XXX: This is ugly pycc, pycxx, pylink = pyext_tool._tool_module().pyext_coms('posix') env['PYEXTCCCOM'] = pycc env['PYEXTCXXCOM'] = pycxx env['PYEXTLINKCOM'] = pylink pyext_runtime_action = Action(pyext_runtime, '') old_action = env['BUILDERS']['PythonExtension'].action env['BUILDERS']['PythonExtension'].action = \ Action([pyext_runtime_action, old_action])
def finalize_env(env): """Call this at the really end of the numpy environment initialization.""" # This will customize some things, to cope with some idiosyncraties with # some tools, and are too specific to be in tools. if built_with_mstools(env): major = get_vs_version(env)[0] # For VS 8 and above (VS 2005), use manifest for DLL # XXX: this has nothing to do here, too if major >= 8: env['LINKCOM'] = [env['LINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest '\ '-outputresource:$TARGET;1'] env['SHLINKCOM'] = [env['SHLINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest '\ '-outputresource:$TARGET;2'] env['LDMODULECOM'] = [env['LDMODULECOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest '\ '-outputresource:$TARGET;2'] if is_f77_gnu(env): env.AppendUnique(F77FLAGS = ['-fno-second-underscore']) if built_with_mingw(env): env.AppendUnique(CFLAGS = '-mno-cygwin')